Skip to content

Commit 000c451

Browse files
markrtuttleMark R. Tuttle
authored andcommitted
Use canonical filenames in source locations (rust-lang#142)
Co-authored-by: Mark R. Tuttle <[email protected]>
1 parent 9315177 commit 000c451

File tree

1 file changed

+6
-6
lines changed
  • compiler/rustc_codegen_llvm/src/gotoc

1 file changed

+6
-6
lines changed

compiler/rustc_codegen_llvm/src/gotoc/utils.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,12 @@ impl<'tcx> GotocCtx<'tcx> {
4343
let lo = smap.lookup_char_pos(sp.lo());
4444
let line = lo.line;
4545
let col = 1 + lo.col_display;
46-
Location::new(
47-
lo.file.name.prefer_remapped().to_string_lossy().to_string(),
48-
self.fname_option(),
49-
line,
50-
Some(col),
51-
)
46+
let filename0 = lo.file.name.prefer_remapped().to_string_lossy().to_string();
47+
let filename1 = match std::fs::canonicalize(filename0.clone()) {
48+
Ok(pathbuf) => pathbuf.to_str().unwrap().to_string(),
49+
Err(_) => filename0,
50+
};
51+
Location::new(filename1, self.fname_option(), line, Some(col))
5252
}
5353

5454
/// Dereference a boxed type `std::boxed::Box<T>` to get a `*T`.

0 commit comments

Comments
 (0)