From: Ralf Jung Date: Sat, 4 Apr 2020 10:07:22 +0000 (+0200) Subject: Rust bootstrap sysroot now has src in the same place as rust-src, so remove special... X-Git-Url: https://git.lizzy.rs/?a=commitdiff_plain;h=bd9ec746a59eec97322eb7e7c24eb350ac94dba0;p=rust.git Rust bootstrap sysroot now has src in the same place as rust-src, so remove special hack --- diff --git a/rust-version b/rust-version index e3dc200835f..895cbb5fa9a 100644 --- a/rust-version +++ b/rust-version @@ -1 +1 @@ -537ccdf3ac44c8c7a8d36cbdbe6fb224afabb7ae +6050e523bae6de61de4e060facc43dc512adaccd diff --git a/src/bin/cargo-miri.rs b/src/bin/cargo-miri.rs index 9ef4996992a..083918de0f3 100644 --- a/src/bin/cargo-miri.rs +++ b/src/bin/cargo-miri.rs @@ -301,34 +301,19 @@ fn setup(ask_user: bool) { .stdout; let sysroot = std::str::from_utf8(&sysroot).unwrap(); let sysroot = Path::new(sysroot.trim_end_matches('\n')); - // First try: `$SYSROOT/lib/rustlib/src/rust`; test if that contains `Cargo.lock`. - let rustup_src = sysroot.join("lib").join("rustlib").join("src").join("rust"); - let base_dir = if rustup_src.join("Cargo.lock").exists() { - // Just use this. - rustup_src - } else { - // Maybe this is a local toolchain built with `x.py` and linked into `rustup`? - // Second try: `$SYSROOT/../../..`; test if that contains `x.py`. - let local_src = sysroot.parent().and_then(Path::parent).and_then(Path::parent); - match local_src { - Some(local_src) if local_src.join("x.py").exists() => { - // Use this. - PathBuf::from(local_src) - } - _ => { - // Fallback: Ask the user to install the `rust-src` component, and use that. - let mut cmd = Command::new("rustup"); - cmd.args(&["component", "add", "rust-src"]); - ask_to_run( - cmd, - ask_user, - "install the rustc-src component for the selected toolchain", - ); - rustup_src - } - } - }; - base_dir.join("src") // Xargo wants the src-subdir + // Check for `$SYSROOT/lib/rustlib/src/rust/src`; test if that contains `libstd/lib.rs`. + let rustup_src = sysroot.join("lib").join("rustlib").join("src").join("rust").join("src"); + if !rustup_src.join("libstd").join("lib.rs").exists() { + // Ask the user to install the `rust-src` component, and use that. + let mut cmd = Command::new("rustup"); + cmd.args(&["component", "add", "rust-src"]); + ask_to_run( + cmd, + ask_user, + "install the rustc-src component for the selected toolchain", + ); + } + rustup_src } }; if !rust_src.exists() {