]> git.proxmox.com Git - rustc.git/blobdiff - src/librustc_session/filesearch.rs
New upstream version 1.44.1+dfsg1
[rustc.git] / src / librustc_session / filesearch.rs
index 05e6da43ea7a9cab916bca1a7ffcbb8104b669c9..e98746231fb307e0510d2bb601dc243074df66b6 100644 (file)
@@ -7,7 +7,7 @@ use std::env;
 use std::fs;
 use std::path::{Path, PathBuf};
 
-use crate::search_paths::{PathKind, SearchPath};
+use crate::search_paths::{PathKind, SearchPath, SearchPathFile};
 use log::debug;
 use rustc_fs_util::fix_windows_verbatim_for_gcc;
 
@@ -43,28 +43,28 @@ impl<'a> FileSearch<'a> {
 
     pub fn search<F>(&self, mut pick: F)
     where
-        F: FnMut(&Path, PathKind) -> FileMatch,
+        F: FnMut(&SearchPathFile, PathKind) -> FileMatch,
     {
         for search_path in self.search_paths() {
             debug!("searching {}", search_path.dir.display());
-            fn is_rlib(p: &Path) -> bool {
-                p.extension() == Some("rlib".as_ref())
+            fn is_rlib(spf: &SearchPathFile) -> bool {
+                if let Some(f) = &spf.file_name_str { f.ends_with(".rlib") } else { false }
             }
             // Reading metadata out of rlibs is faster, and if we find both
             // an rlib and a dylib we only read one of the files of
             // metadata, so in the name of speed, bring all rlib files to
             // the front of the search list.
-            let files1 = search_path.files.iter().filter(|p| is_rlib(p));
-            let files2 = search_path.files.iter().filter(|p| !is_rlib(p));
-            for path in files1.chain(files2) {
-                debug!("testing {}", path.display());
-                let maybe_picked = pick(path, search_path.kind);
+            let files1 = search_path.files.iter().filter(|spf| is_rlib(&spf));
+            let files2 = search_path.files.iter().filter(|spf| !is_rlib(&spf));
+            for spf in files1.chain(files2) {
+                debug!("testing {}", spf.path.display());
+                let maybe_picked = pick(spf, search_path.kind);
                 match maybe_picked {
                     FileMatches => {
-                        debug!("picked {}", path.display());
+                        debug!("picked {}", spf.path.display());
                     }
                     FileDoesntMatch => {
-                        debug!("rejected {}", path.display());
+                        debug!("rejected {}", spf.path.display());
                     }
                 }
             }
@@ -143,8 +143,8 @@ fn find_libdir(sysroot: &Path) -> Cow<'static, str> {
     // FIXME: This is a quick hack to make the rustc binary able to locate
     // Rust libraries in Linux environments where libraries might be installed
     // to lib64/lib32. This would be more foolproof by basing the sysroot off
-    // of the directory where librustc is located, rather than where the rustc
-    // binary is.
+    // of the directory where `librustc_driver` is located, rather than
+    // where the rustc binary is.
     // If --libdir is set during configuration to the value other than
     // "lib" (i.e., non-default), this value is used (see issue #16552).