Skip to content

Commit 9860bfc

Browse files
Canonicalize file path when creating a FileName::Real
1 parent 8040bc9 commit 9860bfc

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

src/librustc_interface/passes.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -557,13 +557,13 @@ fn write_out_deps(
557557
for cnum in resolver.cstore().crates_untracked() {
558558
let source = resolver.cstore().crate_source_untracked(cnum);
559559
if let Some((path, _)) = source.dylib {
560-
files.push(escape_dep_filename(&FileName::Real(path)));
560+
files.push(escape_dep_filename(&path.into()));
561561
}
562562
if let Some((path, _)) = source.rlib {
563-
files.push(escape_dep_filename(&FileName::Real(path)));
563+
files.push(escape_dep_filename(&path.into()));
564564
}
565565
if let Some((path, _)) = source.rmeta {
566-
files.push(escape_dep_filename(&FileName::Real(path)));
566+
files.push(escape_dep_filename(&path.into()));
567567
}
568568
}
569569
});

src/librustc_span/lib.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,11 @@ impl std::fmt::Display for FileName {
123123
impl From<PathBuf> for FileName {
124124
fn from(p: PathBuf) -> Self {
125125
assert!(!p.to_string_lossy().ends_with('>'));
126-
FileName::Real(p)
126+
if cfg!(not(windows)) {
127+
FileName::Real(p.canonlicalize().unwrap_or(p))
128+
} else {
129+
FileName::Real(p)
130+
}
127131
}
128132
}
129133

0 commit comments

Comments
 (0)