From 7cd1d78a4769995546967e413dbbd672c11a153e Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Thu, 21 Jul 2022 09:30:09 -0400 Subject: [PATCH] only complain about runtime toolchain mismatch when there actually is a runtime toolchain --- src/bin/miri.rs | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/bin/miri.rs b/src/bin/miri.rs index 8bd33b591d7..516c730e3fb 100644 --- a/src/bin/miri.rs +++ b/src/bin/miri.rs @@ -220,16 +220,17 @@ fn compile_time_sysroot() -> Option { let toolchain = option_env!("RUSTUP_TOOLCHAIN").or(option_env!("MULTIRUST_TOOLCHAIN")); Some(match (home, toolchain) { (Some(home), Some(toolchain)) => { - // Check that at runtime, we are still in this toolchain. - let toolchain_runtime = - env::var_os("RUSTUP_TOOLCHAIN").or_else(|| env::var_os("MULTIRUST_TOOLCHAIN")); - if !matches!(toolchain_runtime, Some(r) if r == toolchain) { - show_error(format!( - "This Miri got built with local toolchain `{toolchain}`, but now is being run under a different toolchain. \n\ + // Check that at runtime, we are still in this toolchain (if there is any toolchain). + if let Some(toolchain_runtime) = + env::var_os("RUSTUP_TOOLCHAIN").or_else(|| env::var_os("MULTIRUST_TOOLCHAIN")) + { + if toolchain_runtime != toolchain { + show_error(format!( + "This Miri got built with local toolchain `{toolchain}`, but now is being run under a different toolchain. \n\ Make sure to run Miri in the toolchain it got built with, e.g. via `cargo +{toolchain} miri`." - )); + )); + } } - format!("{}/toolchains/{}", home, toolchain) } _ => option_env!("RUST_SYSROOT")