about summary refs log tree commit diff
diff options
context:
space:
mode:
authorCorey Farwell <coreyf@rwell.org>2016-10-10 19:28:16 -0400
committerCorey Farwell <coreyf@rwell.org>2016-10-10 19:28:16 -0400
commit3a15475d363d60ba5ab947c6f8595c0a437623b4 (patch)
treeb0a745e167d966a556c5ab11cceef3a038b423c2
parent6d620843f62b6cf3182528ffcaa877eba461bfbb (diff)
downloadrust-3a15475d363d60ba5ab947c6f8595c0a437623b4.tar.gz
rust-3a15475d363d60ba5ab947c6f8595c0a437623b4.zip
Convert `String` generating functions into `&str` constants.
-rw-r--r--src/librustc/session/filesearch.rs28
1 files changed, 10 insertions, 18 deletions
diff --git a/src/librustc/session/filesearch.rs b/src/librustc/session/filesearch.rs
index a3eea324fd8..ad10b7e8081 100644
--- a/src/librustc/session/filesearch.rs
+++ b/src/librustc/session/filesearch.rs
@@ -124,7 +124,7 @@ impl<'a> FileSearch<'a> {
     pub fn get_tools_search_paths(&self) -> Vec<PathBuf> {
         let mut p = PathBuf::from(self.sysroot);
         p.push(&find_libdir(self.sysroot));
-        p.push(&rustlibdir());
+        p.push(RUST_LIB_DIR);
         p.push(&self.triple);
         p.push("bin");
         vec![p]
@@ -134,7 +134,7 @@ impl<'a> FileSearch<'a> {
 pub fn relative_target_lib_path(sysroot: &Path, target_triple: &str) -> PathBuf {
     let mut p = PathBuf::from(&find_libdir(sysroot));
     assert!(p.is_relative());
-    p.push(&rustlibdir());
+    p.push(RUST_LIB_DIR);
     p.push(target_triple);
     p.push("lib");
     p
@@ -176,31 +176,23 @@ fn find_libdir(sysroot: &Path) -> String {
     // "lib" (i.e. non-default), this value is used (see issue #16552).
 
     match option_env!("CFG_LIBDIR_RELATIVE") {
-        Some(libdir) if libdir != "lib" => return libdir.to_string(),
-        _ => if sysroot.join(&primary_libdir_name()).join(&rustlibdir()).exists() {
-            return primary_libdir_name();
+        Some(libdir) if libdir != "lib" => return libdir.into(),
+        _ => if sysroot.join(PRIMARY_LIB_DIR).join(RUST_LIB_DIR).exists() {
+            return PRIMARY_LIB_DIR.into();
         } else {
-            return secondary_libdir_name();
+            return SECONDARY_LIB_DIR.into();
         }
     }
 
     #[cfg(target_pointer_width = "64")]
-    fn primary_libdir_name() -> String {
-        "lib64".to_string()
-    }
+    const PRIMARY_LIB_DIR: &'static str = "lib64";
 
     #[cfg(target_pointer_width = "32")]
-    fn primary_libdir_name() -> String {
-        "lib32".to_string()
-    }
+    const PRIMARY_LIB_DIR: &'static str = "lib32";
 
-    fn secondary_libdir_name() -> String {
-        "lib".to_string()
-    }
+    const SECONDARY_LIB_DIR: &'static str = "lib";
 }
 
 // The name of rustc's own place to organize libraries.
 // Used to be "rustc", now the default is "rustlib"
-pub fn rustlibdir() -> String {
-    "rustlib".to_string()
-}
+const RUST_LIB_DIR: &'static str = "rustlib";