Skip to content

Commit f450289

Browse files
committed
Do not store directory at all in SearchPathFile
1 parent 1c3449d commit f450289

2 files changed

Lines changed: 8 additions & 13 deletions

File tree

compiler/rustc_metadata/src/locator.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ impl<'a> CrateLocator<'a> {
438438
}
439439
if let Some(matches) = spf.query(prefix, suffix) {
440440
for (hash, spf) in matches {
441-
let spf_path = spf.path();
441+
let spf_path = spf.path(&search_path.dir);
442442
info!("lib candidate: {}", spf_path.display());
443443

444444
let (rlibs, rmetas, dylibs, interfaces) =
@@ -471,9 +471,10 @@ impl<'a> CrateLocator<'a> {
471471
.flatten()
472472
{
473473
for (_, spf) in static_matches {
474-
crate_rejections
475-
.via_kind
476-
.push(CrateMismatch { path: spf.path(), got: "static".to_string() });
474+
crate_rejections.via_kind.push(CrateMismatch {
475+
path: spf.path(&search_path.dir),
476+
got: "static".to_string(),
477+
});
477478
}
478479
}
479480
}

compiler/rustc_session/src/search_paths.rs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,13 @@ impl FilesIndex {
6161
/// UTF-8, and so a non-UTF-8 filename couldn't be one we're looking for.)
6262
#[derive(Clone, Debug)]
6363
pub struct SearchPathFile {
64-
// We store the directory in a shared Arc, as many files can share the same directory.
65-
dir: Arc<Path>,
6664
file_name_str: Arc<str>,
6765
}
6866

6967
impl SearchPathFile {
7068
/// Constructs the full path to the file.
71-
pub fn path(&self) -> PathBuf {
72-
self.dir.join(&*self.file_name_str)
69+
pub fn path(&self, dir: &Path) -> PathBuf {
70+
dir.join(&*self.file_name_str)
7371
}
7472
}
7573

@@ -137,16 +135,12 @@ impl SearchPath {
137135
}
138136

139137
pub fn new(kind: PathKind, dir: PathBuf) -> Self {
140-
let dir_file: Arc<Path> = dir.clone().into();
141138
// Get the files within the directory.
142139
let mut files = match std::fs::read_dir(&dir) {
143140
Ok(files) => files
144141
.filter_map(|e| {
145142
e.ok().and_then(|e| {
146-
e.file_name().to_str().map(|s| {
147-
let file_name_str: Arc<str> = s.into();
148-
SearchPathFile { dir: dir_file.clone(), file_name_str }
149-
})
143+
e.file_name().to_str().map(|s| SearchPathFile { file_name_str: s.into() })
150144
})
151145
})
152146
.collect::<Vec<SearchPathFile>>(),

0 commit comments

Comments
 (0)