From ab22da8ce8b08f06e01e325c277f19072717fe9c Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sat, 3 Aug 2019 16:59:30 +0200 Subject: [PATCH 1/2] annotate some unwraps with better messages --- src/bin/cargo-miri.rs | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/bin/cargo-miri.rs b/src/bin/cargo-miri.rs index 351da554b7b..72bc630e7fa 100644 --- a/src/bin/cargo-miri.rs +++ b/src/bin/cargo-miri.rs @@ -249,7 +249,10 @@ fn setup(ask_user: bool) { println!("Installing xargo: `cargo install xargo -f`"); } - if !cargo().args(&["install", "xargo", "-f"]).status().unwrap().success() { + if !cargo().args(&["install", "xargo", "-f"]).status() + .expect("failed to install xargo") + .success() + { show_error(format!("Failed to install xargo")); } } @@ -257,7 +260,9 @@ fn setup(ask_user: bool) { // Then, unless `XARGO_RUST_SRC` is set, we also need rust-src. // Let's see if it is already installed. if std::env::var("XARGO_RUST_SRC").is_err() { - let sysroot = Command::new("rustc").args(&["--print", "sysroot"]).output().unwrap().stdout; + let sysroot = Command::new("rustc").args(&["--print", "sysroot"]).output() + .expect("failed to get rustc sysroot") + .stdout; let sysroot = std::str::from_utf8(&sysroot).unwrap(); let src = Path::new(sysroot.trim_end_matches('\n')).join("lib").join("rustlib").join("src"); if !src.exists() { @@ -266,7 +271,10 @@ fn setup(ask_user: bool) { } else { println!("Installing rust-src component: `rustup component add rust-src`"); } - if !Command::new("rustup").args(&["component", "add", "rust-src"]).status().unwrap().success() { + if !Command::new("rustup").args(&["component", "add", "rust-src"]).status() + .expect("failed to install rust-src component") + .success() + { show_error(format!("Failed to install rust-src component")); } } @@ -313,7 +321,9 @@ path = "lib.rs" if let Some(ref target) = target { command.arg("--target").arg(&target); } - if !command.status().unwrap().success() + if !command.status() + .expect("failed to run xargo") + .success() { show_error(format!("Failed to run xargo")); } From 10f46336af2dea648c3b2ecf999d789d33bbfdd0 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sat, 3 Aug 2019 17:20:16 +0200 Subject: [PATCH 2/2] set RUSTC_DEBUG_ASSERTIONS for when we are in bootstrap --- src/bin/cargo-miri.rs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/bin/cargo-miri.rs b/src/bin/cargo-miri.rs index 72bc630e7fa..1c0d23336e6 100644 --- a/src/bin/cargo-miri.rs +++ b/src/bin/cargo-miri.rs @@ -310,17 +310,21 @@ version = "0.0.0" path = "lib.rs" "#).unwrap(); File::create(dir.join("lib.rs")).unwrap(); - // Run xargo. + // Prepare xargo invocation. let target = get_arg_flag_value("--target"); let print_env = !ask_user && has_arg_flag("--env"); // whether we just print the necessary environment variable let mut command = xargo(); - command.arg("build").arg("-q") - .current_dir(&dir) - .env("RUSTFLAGS", miri::miri_default_args().join(" ")) - .env("XARGO_HOME", dir.to_str().unwrap()); + command.arg("build").arg("-q"); + command.current_dir(&dir); + command.env("RUSTFLAGS", miri::miri_default_args().join(" ")); + command.env("XARGO_HOME", dir.to_str().unwrap()); + // In bootstrap, make sure we don't get debug assertons into our libstd. + command.env("RUSTC_DEBUG_ASSERTIONS", "false"); + // Handle target flag. if let Some(ref target) = target { command.arg("--target").arg(&target); } + // Finally run it! if !command.status() .expect("failed to run xargo") .success()