diff --git a/compiler/rustc_codegen_llvm/src/gotoc/utils.rs b/compiler/rustc_codegen_llvm/src/gotoc/utils.rs index 6f7d22b78b89..1f7eaafc665a 100644 --- a/compiler/rustc_codegen_llvm/src/gotoc/utils.rs +++ b/compiler/rustc_codegen_llvm/src/gotoc/utils.rs @@ -43,12 +43,12 @@ impl<'tcx> GotocCtx<'tcx> { let lo = smap.lookup_char_pos(sp.lo()); let line = lo.line; let col = 1 + lo.col_display; - Location::new( - lo.file.name.prefer_remapped().to_string_lossy().to_string(), - self.fname_option(), - line, - Some(col), - ) + let filename0 = lo.file.name.prefer_remapped().to_string_lossy().to_string(); + let filename1 = match std::fs::canonicalize(filename0.clone()) { + Ok(pathbuf) => pathbuf.to_str().unwrap().to_string(), + Err(_) => filename0, + }; + Location::new(filename1, self.fname_option(), line, Some(col)) } /// Dereference a boxed type `std::boxed::Box` to get a `*T`.