Skip to content

Commit cde05ee

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 cde05ee

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

src/bootstrap/builder.rs

+12
Original file line numberDiff line numberDiff line change
@@ -1718,6 +1718,18 @@ 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 = env::var("CARGO_HOME").unwrap_or_else(|_| {
1727+
let home_var = if cfg!(windows) { "USERPROFILE" } else { "HOME" };
1728+
env::var(home_var).unwrap()
1729+
});
1730+
rustflags.arg(&format!("--remap-path-prefix={cargo_home}=/cargo/FAKE_PREFIX"));
1731+
}
1732+
17211733
if let Some(map_to) = self.build.debuginfo_map_to(GitRepo::Rustc) {
17221734
let map = format!("{}={}", self.build.src.display(), map_to);
17231735
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)