Skip to content

Commit ab22da8

Browse files
committed
annotate some unwraps with better messages
1 parent 9d3fdee commit ab22da8

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

src/bin/cargo-miri.rs

Lines changed: 14 additions & 4 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
}
@@ -313,7 +321,9 @@ path = "lib.rs"
313321
if let Some(ref target) = target {
314322
command.arg("--target").arg(&target);
315323
}
316-
if !command.status().unwrap().success()
324+
if !command.status()
325+
.expect("failed to run xargo")
326+
.success()
317327
{
318328
show_error(format!("Failed to run xargo"));
319329
}

0 commit comments

Comments
 (0)