Remove FileMatch
.
It's returned from `FileSearch::search` but it's only used to print some debug info.
This commit is contained in:
parent
f916f3a36b
commit
47b5d95db8
2 changed files with 6 additions and 17 deletions
|
@ -223,7 +223,7 @@ use rustc_data_structures::sync::MetadataRef;
|
||||||
use rustc_errors::{struct_span_err, FatalError};
|
use rustc_errors::{struct_span_err, FatalError};
|
||||||
use rustc_session::config::{self, CrateType};
|
use rustc_session::config::{self, CrateType};
|
||||||
use rustc_session::cstore::{CrateSource, MetadataLoader};
|
use rustc_session::cstore::{CrateSource, MetadataLoader};
|
||||||
use rustc_session::filesearch::{FileDoesntMatch, FileMatches, FileSearch};
|
use rustc_session::filesearch::FileSearch;
|
||||||
use rustc_session::search_paths::PathKind;
|
use rustc_session::search_paths::PathKind;
|
||||||
use rustc_session::utils::CanonicalizedPath;
|
use rustc_session::utils::CanonicalizedPath;
|
||||||
use rustc_session::Session;
|
use rustc_session::Session;
|
||||||
|
@ -396,7 +396,7 @@ impl<'a> CrateLocator<'a> {
|
||||||
// The goal of this step is to look at as little metadata as possible.
|
// The goal of this step is to look at as little metadata as possible.
|
||||||
self.filesearch.search(|spf, kind| {
|
self.filesearch.search(|spf, kind| {
|
||||||
let file = match &spf.file_name_str {
|
let file = match &spf.file_name_str {
|
||||||
None => return FileDoesntMatch,
|
None => return,
|
||||||
Some(file) => file,
|
Some(file) => file,
|
||||||
};
|
};
|
||||||
let (hash, found_kind) = if file.starts_with(&rlib_prefix) && file.ends_with(".rlib") {
|
let (hash, found_kind) = if file.starts_with(&rlib_prefix) && file.ends_with(".rlib") {
|
||||||
|
@ -415,7 +415,7 @@ impl<'a> CrateLocator<'a> {
|
||||||
staticlibs
|
staticlibs
|
||||||
.push(CrateMismatch { path: spf.path.clone(), got: "static".to_string() });
|
.push(CrateMismatch { path: spf.path.clone(), got: "static".to_string() });
|
||||||
}
|
}
|
||||||
return FileDoesntMatch;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
info!("lib candidate: {}", spf.path.display());
|
info!("lib candidate: {}", spf.path.display());
|
||||||
|
@ -423,7 +423,7 @@ impl<'a> CrateLocator<'a> {
|
||||||
let (rlibs, rmetas, dylibs) = candidates.entry(hash.to_string()).or_default();
|
let (rlibs, rmetas, dylibs) = candidates.entry(hash.to_string()).or_default();
|
||||||
let path = fs::canonicalize(&spf.path).unwrap_or_else(|_| spf.path.clone());
|
let path = fs::canonicalize(&spf.path).unwrap_or_else(|_| spf.path.clone());
|
||||||
if seen_paths.contains(&path) {
|
if seen_paths.contains(&path) {
|
||||||
return FileDoesntMatch;
|
return;
|
||||||
};
|
};
|
||||||
seen_paths.insert(path.clone());
|
seen_paths.insert(path.clone());
|
||||||
match found_kind {
|
match found_kind {
|
||||||
|
@ -431,7 +431,6 @@ impl<'a> CrateLocator<'a> {
|
||||||
CrateFlavor::Rmeta => rmetas.insert(path, kind),
|
CrateFlavor::Rmeta => rmetas.insert(path, kind),
|
||||||
CrateFlavor::Dylib => dylibs.insert(path, kind),
|
CrateFlavor::Dylib => dylibs.insert(path, kind),
|
||||||
};
|
};
|
||||||
FileMatches
|
|
||||||
});
|
});
|
||||||
self.crate_rejections.via_kind.extend(staticlibs);
|
self.crate_rejections.via_kind.extend(staticlibs);
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
//! A module for searching for libraries
|
//! A module for searching for libraries
|
||||||
|
|
||||||
pub use self::FileMatch::*;
|
|
||||||
|
|
||||||
use std::env;
|
use std::env;
|
||||||
use std::fs;
|
use std::fs;
|
||||||
use std::iter::FromIterator;
|
use std::iter::FromIterator;
|
||||||
|
@ -45,21 +43,13 @@ impl<'a> FileSearch<'a> {
|
||||||
|
|
||||||
pub fn search<F>(&self, mut pick: F)
|
pub fn search<F>(&self, mut pick: F)
|
||||||
where
|
where
|
||||||
F: FnMut(&SearchPathFile, PathKind) -> FileMatch,
|
F: FnMut(&SearchPathFile, PathKind),
|
||||||
{
|
{
|
||||||
for search_path in self.search_paths() {
|
for search_path in self.search_paths() {
|
||||||
debug!("searching {}", search_path.dir.display());
|
debug!("searching {}", search_path.dir.display());
|
||||||
for spf in search_path.files.iter() {
|
for spf in search_path.files.iter() {
|
||||||
debug!("testing {}", spf.path.display());
|
debug!("testing {}", spf.path.display());
|
||||||
let maybe_picked = pick(spf, search_path.kind);
|
pick(spf, search_path.kind);
|
||||||
match maybe_picked {
|
|
||||||
FileMatches => {
|
|
||||||
debug!("picked {}", spf.path.display());
|
|
||||||
}
|
|
||||||
FileDoesntMatch => {
|
|
||||||
debug!("rejected {}", spf.path.display());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue