From 3d9dea5dc1c5932f3ac04cf01a5c7b1cc9616f32 Mon Sep 17 00:00:00 2001 From: "Mark R. Tuttle" Date: Sun, 23 May 2021 19:03:18 +0000 Subject: [PATCH] Use canonical filenames in source locations --- compiler/rustc_codegen_llvm/src/gotoc/utils.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) 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`.