Skip to content

Commit 26d7e9b

Browse files
committed
Auto merge of #1300 - RalfJung:rust-src, r=RalfJung
Rust bootstrap sysroot now has src in the same place as rust-src So we can remove a special hack. I checked this locally to confirm it works. Cc rust-lang/rust#70642 @eddyb
2 parents 0e8a1a4 + bd9ec74 commit 26d7e9b

File tree

2 files changed

+14
-29
lines changed

2 files changed

+14
-29
lines changed

rust-version

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
537ccdf3ac44c8c7a8d36cbdbe6fb224afabb7ae
1+
6050e523bae6de61de4e060facc43dc512adaccd

src/bin/cargo-miri.rs

+13-28
Original file line numberDiff line numberDiff line change
@@ -301,34 +301,19 @@ fn setup(ask_user: bool) {
301301
.stdout;
302302
let sysroot = std::str::from_utf8(&sysroot).unwrap();
303303
let sysroot = Path::new(sysroot.trim_end_matches('\n'));
304-
// First try: `$SYSROOT/lib/rustlib/src/rust`; test if that contains `Cargo.lock`.
305-
let rustup_src = sysroot.join("lib").join("rustlib").join("src").join("rust");
306-
let base_dir = if rustup_src.join("Cargo.lock").exists() {
307-
// Just use this.
308-
rustup_src
309-
} else {
310-
// Maybe this is a local toolchain built with `x.py` and linked into `rustup`?
311-
// Second try: `$SYSROOT/../../..`; test if that contains `x.py`.
312-
let local_src = sysroot.parent().and_then(Path::parent).and_then(Path::parent);
313-
match local_src {
314-
Some(local_src) if local_src.join("x.py").exists() => {
315-
// Use this.
316-
PathBuf::from(local_src)
317-
}
318-
_ => {
319-
// Fallback: Ask the user to install the `rust-src` component, and use that.
320-
let mut cmd = Command::new("rustup");
321-
cmd.args(&["component", "add", "rust-src"]);
322-
ask_to_run(
323-
cmd,
324-
ask_user,
325-
"install the rustc-src component for the selected toolchain",
326-
);
327-
rustup_src
328-
}
329-
}
330-
};
331-
base_dir.join("src") // Xargo wants the src-subdir
304+
// Check for `$SYSROOT/lib/rustlib/src/rust/src`; test if that contains `libstd/lib.rs`.
305+
let rustup_src = sysroot.join("lib").join("rustlib").join("src").join("rust").join("src");
306+
if !rustup_src.join("libstd").join("lib.rs").exists() {
307+
// Ask the user to install the `rust-src` component, and use that.
308+
let mut cmd = Command::new("rustup");
309+
cmd.args(&["component", "add", "rust-src"]);
310+
ask_to_run(
311+
cmd,
312+
ask_user,
313+
"install the rustc-src component for the selected toolchain",
314+
);
315+
}
316+
rustup_src
332317
}
333318
};
334319
if !rust_src.exists() {

0 commit comments

Comments
 (0)