From 9860bfc56a9f45a991a7c28cf3665f31e2815f3f Mon Sep 17 00:00:00 2001 From: LeSeulArtichaut Date: Tue, 11 Feb 2020 20:16:53 +0100 Subject: [PATCH 1/3] Canonicalize file path when creating a `FileName::Real` --- src/librustc_interface/passes.rs | 6 +++--- src/librustc_span/lib.rs | 6 +++++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/librustc_interface/passes.rs b/src/librustc_interface/passes.rs index 6224c4654d695..a059bee8a8742 100644 --- a/src/librustc_interface/passes.rs +++ b/src/librustc_interface/passes.rs @@ -557,13 +557,13 @@ fn write_out_deps( for cnum in resolver.cstore().crates_untracked() { let source = resolver.cstore().crate_source_untracked(cnum); if let Some((path, _)) = source.dylib { - files.push(escape_dep_filename(&FileName::Real(path))); + files.push(escape_dep_filename(&path.into())); } if let Some((path, _)) = source.rlib { - files.push(escape_dep_filename(&FileName::Real(path))); + files.push(escape_dep_filename(&path.into())); } if let Some((path, _)) = source.rmeta { - files.push(escape_dep_filename(&FileName::Real(path))); + files.push(escape_dep_filename(&path.into())); } } }); diff --git a/src/librustc_span/lib.rs b/src/librustc_span/lib.rs index 8f00b76001f04..37dcd169267a2 100644 --- a/src/librustc_span/lib.rs +++ b/src/librustc_span/lib.rs @@ -123,7 +123,11 @@ impl std::fmt::Display for FileName { impl From for FileName { fn from(p: PathBuf) -> Self { assert!(!p.to_string_lossy().ends_with('>')); - FileName::Real(p) + if cfg!(not(windows)) { + FileName::Real(p.canonlicalize().unwrap_or(p)) + } else { + FileName::Real(p) + } } } From d68420bd9b0267cf539e78be0909f85a3f2b9443 Mon Sep 17 00:00:00 2001 From: LeSeulArtichaut Date: Tue, 11 Feb 2020 21:41:20 +0100 Subject: [PATCH 2/3] Use `.into()` to create a `FileName::Real` --- src/librustc_span/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustc_span/lib.rs b/src/librustc_span/lib.rs index 37dcd169267a2..da8d5d25f444c 100644 --- a/src/librustc_span/lib.rs +++ b/src/librustc_span/lib.rs @@ -124,7 +124,7 @@ impl From for FileName { fn from(p: PathBuf) -> Self { assert!(!p.to_string_lossy().ends_with('>')); if cfg!(not(windows)) { - FileName::Real(p.canonlicalize().unwrap_or(p)) + FileName::Real(p.canonicalize().unwrap_or(p)) } else { FileName::Real(p) } From b7d992bb20df12d77a95ba719ce32321cb5dc994 Mon Sep 17 00:00:00 2001 From: LeSeulArtichaut Date: Sun, 16 Feb 2020 12:02:35 +0100 Subject: [PATCH 3/3] Fix test failures due to normalization --- src/test/ui/consts/miri_unleashed/mutable_const2.stderr | 2 +- src/test/ui/consts/miri_unleashed/mutable_references_ice.stderr | 2 +- src/test/ui/pattern/const-pat-ice.stderr | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/test/ui/consts/miri_unleashed/mutable_const2.stderr b/src/test/ui/consts/miri_unleashed/mutable_const2.stderr index 3eb8e0ec18288..2c4b6868567f2 100644 --- a/src/test/ui/consts/miri_unleashed/mutable_const2.stderr +++ b/src/test/ui/consts/miri_unleashed/mutable_const2.stderr @@ -10,7 +10,7 @@ error: internal compiler error: mutable allocation in constant LL | const MUTABLE_BEHIND_RAW: *mut i32 = &UnsafeCell::new(42) as *const _ as *mut _; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -thread 'rustc' panicked at 'no errors encountered even though `delay_span_bug` issued', src/librustc_errors/lib.rs:355:17 +thread 'rustc' panicked at 'no errors encountered even though `delay_span_bug` issued', $SRC_DIR/librustc_errors/lib.rs:LL:COL note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace error: internal compiler error: unexpected panic diff --git a/src/test/ui/consts/miri_unleashed/mutable_references_ice.stderr b/src/test/ui/consts/miri_unleashed/mutable_references_ice.stderr index c292fcef7f660..41f45434d4caa 100644 --- a/src/test/ui/consts/miri_unleashed/mutable_references_ice.stderr +++ b/src/test/ui/consts/miri_unleashed/mutable_references_ice.stderr @@ -6,7 +6,7 @@ LL | x: &UnsafeCell::new(42), thread 'rustc' panicked at 'assertion failed: `(left != right)` left: `Const`, - right: `Const`: UnsafeCells are not allowed behind references in constants. This should have been prevented statically by const qualification. If this were allowed one would be able to change a constant at one use site and other use sites could observe that mutation.', src/librustc_mir/interpret/intern.rs:LL:CC + right: `Const`: UnsafeCells are not allowed behind references in constants. This should have been prevented statically by const qualification. If this were allowed one would be able to change a constant at one use site and other use sites could observe that mutation.', $SRC_DIR/librustc_mir/interpret/intern.rs:LL:COL note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace error: internal compiler error: unexpected panic diff --git a/src/test/ui/pattern/const-pat-ice.stderr b/src/test/ui/pattern/const-pat-ice.stderr index d0018cef5f033..a4fa25ceee75f 100644 --- a/src/test/ui/pattern/const-pat-ice.stderr +++ b/src/test/ui/pattern/const-pat-ice.stderr @@ -1,4 +1,4 @@ -thread 'rustc' panicked at 'assertion failed: rows.iter().all(|r| r.len() == v.len())', src/librustc_mir_build/hair/pattern/_match.rs:LL:CC +thread 'rustc' panicked at 'assertion failed: rows.iter().all(|r| r.len() == v.len())', $SRC_DIR/librustc_mir_build/hair/pattern/_match.rs:LL:COL note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace error: internal compiler error: unexpected panic