Skip to content

Commit 702c0ac

Browse files
committed
Remap paths for ~/.cargo in UI tests
Users won't have the original cargo registry from the CI builder available, even if they have `rust-src` installed. Don't show their sources in UI tests even if they're available. As a happy side-effect, this fixes a few UI tests when download-rustc is enabled.
1 parent 993deaa commit 702c0ac

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

src/bootstrap/builder.rs

+10
Original file line numberDiff line numberDiff line change
@@ -1718,6 +1718,16 @@ impl<'a> Builder<'a> {
17181718
cargo.env("RUSTC_HOST_CRT_STATIC", x.to_string());
17191719
}
17201720

1721+
// Users won't have the original cargo registry from the CI builder available, even if they have `rust-src` installed.
1722+
// Don't show their sources in UI tests even if they're available.
1723+
// As a happy side-effect, this fixes a few UI tests when download-rustc is enabled.
1724+
// NOTE: only set this when building std so the error messages are better for rustc itself.
1725+
if mode == Mode::Std {
1726+
let cargo_home =
1727+
env::var("CARGO_HOME").unwrap_or_else(|_| env::var("HOME").unwrap() + "/.cargo");
1728+
rustflags.arg(&format!("--remap-path-prefix={cargo_home}=/cargo/FAKE_PREFIX"));
1729+
}
1730+
17211731
if let Some(map_to) = self.build.debuginfo_map_to(GitRepo::Rustc) {
17221732
let map = format!("{}={}", self.build.src.display(), map_to);
17231733
cargo.env("RUSTC_DEBUGINFO_MAP", map);

tests/ui/issues/issue-21763.stderr

-3
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@ LL | foo::<HashMap<Rc<()>, Rc<()>>>();
99
= note: required for `hashbrown::raw::RawTable<(Rc<()>, Rc<()>)>` to implement `Send`
1010
note: required because it appears within the type `HashMap<Rc<()>, Rc<()>, RandomState>`
1111
--> $HASHBROWN_SRC_LOCATION
12-
|
13-
LL | pub struct HashMap<K, V, S = DefaultHashBuilder, A: Allocator + Clone = Global> {
14-
| ^^^^^^^
1512
note: required because it appears within the type `HashMap<Rc<()>, Rc<()>>`
1613
--> $SRC_DIR/std/src/collections/hash/map.rs:LL:COL
1714
note: required by a bound in `foo`

0 commit comments

Comments
 (0)