Skip to content

Commit eb9e307

Browse files
committed
Auto merge of #1856 - RalfJung:no-mir, r=RalfJung
show proper error when using a sysroot without MIR Fixes #1834
2 parents 1677946 + 46d31f9 commit eb9e307

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/diagnostics.rs

-2
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,6 @@ pub fn report_error<'tcx, 'mir>(
132132
};
133133
#[rustfmt::skip]
134134
let helps = match e.kind() {
135-
Unsupported(UnsupportedOpInfo::NoMirFor(..)) =>
136-
vec![(None, format!("make sure to use a Miri sysroot, which you can prepare with `cargo miri setup`"))],
137135
Unsupported(UnsupportedOpInfo::ThreadLocalStatic(_) | UnsupportedOpInfo::ReadExternStatic(_)) =>
138136
panic!("Error should never be raised by Miri: {:?}", e.kind()),
139137
Unsupported(_) =>

src/eval.rs

+6
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,12 @@ pub fn create_ecx<'mir, 'tcx: 'mir>(
138138
EnvVars::init(&mut ecx, config.excluded_env_vars)?;
139139
MemoryExtra::init_extern_statics(&mut ecx)?;
140140

141+
// Make sure we have MIR. We check MIR for some stable monomorphic function in libcore.
142+
let sentinel = ecx.resolve_path(&["core", "ascii", "escape_default"]);
143+
if !tcx.is_mir_available(sentinel.def.def_id()) {
144+
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.");
145+
}
146+
141147
// Setup first stack-frame
142148
let main_instance = ty::Instance::mono(tcx, main_id);
143149
let main_mir = ecx.load_mir(main_instance.def, None)?;

0 commit comments

Comments
 (0)