Skip to content

Commit d8f2611

Browse files
committed
fix: reorder --remap-path-prefix flags for -Zbuild-std
Order of `--remap-path-prefix` flags is important for `-Zbuild-std`. We want to show `/rustc/<hash>/library/std` instead of `std-0.0.0`.
1 parent d6b46bf commit d8f2611

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/cargo/core/compiler/mod.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -1214,8 +1214,6 @@ fn trim_paths_args(
12141214
}
12151215
remap
12161216
};
1217-
cmd.arg(sysroot_remap);
1218-
12191217
let package_remap = {
12201218
let pkg_root = unit.pkg.root();
12211219
let ws_root = cx.bcx.ws.root();
@@ -1242,7 +1240,11 @@ fn trim_paths_args(
12421240
}
12431241
remap
12441242
};
1243+
1244+
// Order of `--remap-path-prefix` flags is important for `-Zbuild-std`.
1245+
// We want to show `/rustc/<hash>/library/std` instead of `std-0.0.0`.
12451246
cmd.arg(package_remap);
1247+
cmd.arg(sysroot_remap);
12461248

12471249
Ok(())
12481250
}

tests/build-std/main.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -267,8 +267,8 @@ fn remap_path_scope() {
267267
[..]thread '[..]' panicked at [..]src/main.rs:3:[..]",
268268
)
269269
.with_stderr_contains("remap to /rustc/<hash>")
270-
.with_stderr_contains("[..]at std-0.0.0/src/[..]")
270+
.with_stderr_contains("[..]at /rustc/[..]/library/std/src/[..]")
271271
.with_stderr_contains("[..]at src/main.rs:3[..]")
272-
.with_stderr_contains("[..]at core-0.0.0/src/[..]")
272+
.with_stderr_contains("[..]at /rustc/[..]/library/core/src/[..]")
273273
.run();
274274
}

0 commit comments

Comments
 (0)