From 46d31f92303c3dd8905aef1b71150acbd46e88c1 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sat, 24 Jul 2021 14:02:09 +0200 Subject: [PATCH] show proper error when using a sysroot without MIR --- src/diagnostics.rs | 2 -- src/eval.rs | 6 ++++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/diagnostics.rs b/src/diagnostics.rs index b5b75a7fc31..cad08a2831a 100644 --- a/src/diagnostics.rs +++ b/src/diagnostics.rs @@ -132,8 +132,6 @@ pub fn report_error<'tcx, 'mir>( }; #[rustfmt::skip] let helps = match e.kind() { - Unsupported(UnsupportedOpInfo::NoMirFor(..)) => - vec![(None, format!("make sure to use a Miri sysroot, which you can prepare with `cargo miri setup`"))], Unsupported(UnsupportedOpInfo::ThreadLocalStatic(_) | UnsupportedOpInfo::ReadExternStatic(_)) => panic!("Error should never be raised by Miri: {:?}", e.kind()), Unsupported(_) => diff --git a/src/eval.rs b/src/eval.rs index ae9ff9c1f5a..02feae4a350 100644 --- a/src/eval.rs +++ b/src/eval.rs @@ -138,6 +138,12 @@ pub fn create_ecx<'mir, 'tcx: 'mir>( EnvVars::init(&mut ecx, config.excluded_env_vars)?; MemoryExtra::init_extern_statics(&mut ecx)?; + // Make sure we have MIR. We check MIR for some stable monomorphic function in libcore. + let sentinel = ecx.resolve_path(&["core", "ascii", "escape_default"]); + if !tcx.is_mir_available(sentinel.def.def_id()) { + tcx.sess.fatal("the current sysroot was built without `-Zalways-encode-mir`. Use `cargo miri setup` to prepare a sysroot that is suitable for Miri."); + } + // Setup first stack-frame let main_instance = ty::Instance::mono(tcx, main_id); let main_mir = ecx.load_mir(main_instance.def, None)?;