diff --git a/src/tools/miri/cargo-miri/src/setup.rs b/src/tools/miri/cargo-miri/src/setup.rs index a696546954f..2e4f0a71013 100644 --- a/src/tools/miri/cargo-miri/src/setup.rs +++ b/src/tools/miri/cargo-miri/src/setup.rs @@ -137,9 +137,11 @@ pub fn setup(subcommand: &MiriCommand, target: &str, rustc_version: &VersionMeta .rustflags(rustflags) .cargo(cargo_cmd) .build_from_source(&rust_src) - .unwrap_or_else(|_| { - if only_setup { - show_error!("failed to build sysroot, see error details above") + .unwrap_or_else(|err| { + if print_sysroot { + show_error!("failed to build sysroot") + } else if only_setup { + show_error!("failed to build sysroot: {err:?}") } else { show_error!( "failed to build sysroot; run `cargo miri setup` to see the error details"