diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index bc80c8246ad0f..b1ca193c4a38e 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -2332,6 +2332,20 @@ impl<'test> TestCx<'test> { // eg. /home/user/rust/build normalize_path(parent_build_dir, "$BUILD_DIR"); + // e.g. /home/user/.cargo + if let Ok(cargo_home) = home::cargo_home() { + let mut from = cargo_home.display().to_string(); + if json { + from = from.replace("\\", "\\\\"); + } + // In CI, `$CARGO_HOME` is `/cargo`, but some paths in output contain `.../cargo...` + // Try to normalize only paths beginning with `$CARGO_HOME` + for prefix in [' ', '\n', '\'', '"'] { + normalized = + normalized.replace(&format!("{prefix}{from}"), &format!("{prefix}{from}")); + } + } + if json { // escaped newlines in json strings should be readable // in the stderr files. There's no point int being correct, diff --git a/tests/ui/issues/issue-21763.rs b/tests/ui/issues/issue-21763.rs index 1d0a0705cbbd9..5beb1d8b8c476 100644 --- a/tests/ui/issues/issue-21763.rs +++ b/tests/ui/issues/issue-21763.rs @@ -1,7 +1,5 @@ // Regression test for HashMap only impl'ing Send/Sync if its contents do -//@ normalize-stderr-test: "\S+[\\/]hashbrown\S+" -> "$$HASHBROWN_SRC_LOCATION" - use std::collections::HashMap; use std::rc::Rc; diff --git a/tests/ui/issues/issue-21763.stderr b/tests/ui/issues/issue-21763.stderr index 135b705eeeff2..c69c0a2d40f31 100644 --- a/tests/ui/issues/issue-21763.stderr +++ b/tests/ui/issues/issue-21763.stderr @@ -1,5 +1,5 @@ error[E0277]: `Rc<()>` cannot be sent between threads safely - --> $DIR/issue-21763.rs:11:11 + --> $DIR/issue-21763.rs:9:11 | LL | foo::, Rc<()>>>(); | ^^^^^^^^^^^^^^^^^^^^^^^ `Rc<()>` cannot be sent between threads safely @@ -8,11 +8,11 @@ LL | foo::, Rc<()>>>(); = note: required because it appears within the type `(Rc<()>, Rc<()>)` = note: required for `hashbrown::raw::RawTable<(Rc<()>, Rc<()>)>` to implement `Send` note: required because it appears within the type `hashbrown::map::HashMap, Rc<()>, RandomState>` - --> $HASHBROWN_SRC_LOCATION + --> $CARGO_HOME/registry/src/index.crates.io-6f17d22bba15001f/hashbrown-0.15.0/src/map.rs:185:12 note: required because it appears within the type `HashMap, Rc<()>>` --> $SRC_DIR/std/src/collections/hash/map.rs:LL:COL note: required by a bound in `foo` - --> $DIR/issue-21763.rs:8:11 + --> $DIR/issue-21763.rs:6:11 | LL | fn foo() {} | ^^^^ required by this bound in `foo`