Skip to content

Commit a71ebf9

Browse files
committed
Auto merge of #880 - RalfJung:miri-rustc, r=RalfJung
annotate some unwraps with better messages
2 parents 9d3fdee + 10f4633 commit a71ebf9

File tree

1 file changed

+23
-9
lines changed

1 file changed

+23
-9
lines changed

src/bin/cargo-miri.rs

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -249,15 +249,20 @@ fn setup(ask_user: bool) {
249249
println!("Installing xargo: `cargo install xargo -f`");
250250
}
251251

252-
if !cargo().args(&["install", "xargo", "-f"]).status().unwrap().success() {
252+
if !cargo().args(&["install", "xargo", "-f"]).status()
253+
.expect("failed to install xargo")
254+
.success()
255+
{
253256
show_error(format!("Failed to install xargo"));
254257
}
255258
}
256259

257260
// Then, unless `XARGO_RUST_SRC` is set, we also need rust-src.
258261
// Let's see if it is already installed.
259262
if std::env::var("XARGO_RUST_SRC").is_err() {
260-
let sysroot = Command::new("rustc").args(&["--print", "sysroot"]).output().unwrap().stdout;
263+
let sysroot = Command::new("rustc").args(&["--print", "sysroot"]).output()
264+
.expect("failed to get rustc sysroot")
265+
.stdout;
261266
let sysroot = std::str::from_utf8(&sysroot).unwrap();
262267
let src = Path::new(sysroot.trim_end_matches('\n')).join("lib").join("rustlib").join("src");
263268
if !src.exists() {
@@ -266,7 +271,10 @@ fn setup(ask_user: bool) {
266271
} else {
267272
println!("Installing rust-src component: `rustup component add rust-src`");
268273
}
269-
if !Command::new("rustup").args(&["component", "add", "rust-src"]).status().unwrap().success() {
274+
if !Command::new("rustup").args(&["component", "add", "rust-src"]).status()
275+
.expect("failed to install rust-src component")
276+
.success()
277+
{
270278
show_error(format!("Failed to install rust-src component"));
271279
}
272280
}
@@ -302,18 +310,24 @@ version = "0.0.0"
302310
path = "lib.rs"
303311
"#).unwrap();
304312
File::create(dir.join("lib.rs")).unwrap();
305-
// Run xargo.
313+
// Prepare xargo invocation.
306314
let target = get_arg_flag_value("--target");
307315
let print_env = !ask_user && has_arg_flag("--env"); // whether we just print the necessary environment variable
308316
let mut command = xargo();
309-
command.arg("build").arg("-q")
310-
.current_dir(&dir)
311-
.env("RUSTFLAGS", miri::miri_default_args().join(" "))
312-
.env("XARGO_HOME", dir.to_str().unwrap());
317+
command.arg("build").arg("-q");
318+
command.current_dir(&dir);
319+
command.env("RUSTFLAGS", miri::miri_default_args().join(" "));
320+
command.env("XARGO_HOME", dir.to_str().unwrap());
321+
// In bootstrap, make sure we don't get debug assertons into our libstd.
322+
command.env("RUSTC_DEBUG_ASSERTIONS", "false");
323+
// Handle target flag.
313324
if let Some(ref target) = target {
314325
command.arg("--target").arg(&target);
315326
}
316-
if !command.status().unwrap().success()
327+
// Finally run it!
328+
if !command.status()
329+
.expect("failed to run xargo")
330+
.success()
317331
{
318332
show_error(format!("Failed to run xargo"));
319333
}

0 commit comments

Comments
 (0)