Auto merge of #880 - RalfJung:miri-rustc, r=RalfJung

annotate some unwraps with better messages
This commit is contained in:
bors 2019-08-03 15:22:09 +00:00
commit a71ebf9066

View File

@ -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"));
}
}
@ -302,18 +310,24 @@ fn setup(ask_user: bool) {
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);
}
if !command.status().unwrap().success()
// Finally run it!
if !command.status()
.expect("failed to run xargo")
.success()
{
show_error(format!("Failed to run xargo"));
}