Skip to content

Commit

Permalink
Auto merge of #1856 - RalfJung:no-mir, r=RalfJung
Browse files Browse the repository at this point in the history
show proper error when using a sysroot without MIR

Fixes #1834
  • Loading branch information
bors committed Jul 25, 2021
2 parents 1677946 + 46d31f9 commit eb9e307
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 0 additions & 2 deletions src/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(_) =>
Expand Down
6 changes: 6 additions & 0 deletions src/eval.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)?;
Expand Down

0 comments on commit eb9e307

Please sign in to comment.