Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 7cd1d78

Browse files
committed
only complain about runtime toolchain mismatch when there actually is a runtime toolchain
1 parent 800273c commit 7cd1d78

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

src/bin/miri.rs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -220,16 +220,17 @@ fn compile_time_sysroot() -> Option<String> {
220220
let toolchain = option_env!("RUSTUP_TOOLCHAIN").or(option_env!("MULTIRUST_TOOLCHAIN"));
221221
Some(match (home, toolchain) {
222222
(Some(home), Some(toolchain)) => {
223-
// Check that at runtime, we are still in this toolchain.
224-
let toolchain_runtime =
225-
env::var_os("RUSTUP_TOOLCHAIN").or_else(|| env::var_os("MULTIRUST_TOOLCHAIN"));
226-
if !matches!(toolchain_runtime, Some(r) if r == toolchain) {
227-
show_error(format!(
228-
"This Miri got built with local toolchain `{toolchain}`, but now is being run under a different toolchain. \n\
223+
// Check that at runtime, we are still in this toolchain (if there is any toolchain).
224+
if let Some(toolchain_runtime) =
225+
env::var_os("RUSTUP_TOOLCHAIN").or_else(|| env::var_os("MULTIRUST_TOOLCHAIN"))
226+
{
227+
if toolchain_runtime != toolchain {
228+
show_error(format!(
229+
"This Miri got built with local toolchain `{toolchain}`, but now is being run under a different toolchain. \n\
229230
Make sure to run Miri in the toolchain it got built with, e.g. via `cargo +{toolchain} miri`."
230-
));
231+
));
232+
}
231233
}
232-
233234
format!("{}/toolchains/{}", home, toolchain)
234235
}
235236
_ => option_env!("RUST_SYSROOT")

0 commit comments

Comments
 (0)