Skip to content

Commit d254394

Browse files
authored
Rollup merge of #87427 - RalfJung:no-mir-for, r=oli-obk
get rid of NoMirFor error variant The only place where we throw that error, it is very quickly caught again and turned into a different error. So raise that other error immediately.
2 parents 90f6d7b + 3b9f811 commit d254394

File tree

2 files changed

+4
-18
lines changed

2 files changed

+4
-18
lines changed

compiler/rustc_middle/src/mir/interpret/error.rs

-3
Original file line numberDiff line numberDiff line change
@@ -402,8 +402,6 @@ impl fmt::Display for UndefinedBehaviorInfo<'_> {
402402
pub enum UnsupportedOpInfo {
403403
/// Free-form case. Only for errors that are never caught!
404404
Unsupported(String),
405-
/// Could not find MIR for a function.
406-
NoMirFor(DefId),
407405
/// Encountered a pointer where we needed raw bytes.
408406
ReadPointerAsBytes,
409407
//
@@ -421,7 +419,6 @@ impl fmt::Display for UnsupportedOpInfo {
421419
match self {
422420
Unsupported(ref msg) => write!(f, "{}", msg),
423421
ReadExternStatic(did) => write!(f, "cannot read from extern static ({:?})", did),
424-
NoMirFor(did) => write!(f, "no MIR body is available for {:?}", did),
425422
ReadPointerAsBytes => write!(f, "unable to turn pointer into raw bytes",),
426423
ThreadLocalStatic(did) => write!(f, "cannot access thread local static ({:?})", did),
427424
}

compiler/rustc_mir/src/const_eval/machine.rs

+4-15
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,9 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for CompileTimeInterpreter<'mir,
212212
if ecx.tcx.is_ctfe_mir_available(def.did) {
213213
Ok(ecx.tcx.mir_for_ctfe_opt_const_arg(def))
214214
} else {
215-
throw_unsup!(NoMirFor(def.did))
215+
let path = ecx.tcx.def_path_str(def.did);
216+
Err(ConstEvalErrKind::NeedsRfc(format!("calling extern function `{}`", path))
217+
.into())
216218
}
217219
}
218220
_ => Ok(ecx.tcx.instance_mir(instance)),
@@ -247,20 +249,7 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for CompileTimeInterpreter<'mir,
247249
}
248250
}
249251
// This is a const fn. Call it.
250-
Ok(Some(match ecx.load_mir(instance.def, None) {
251-
Ok(body) => body,
252-
Err(err) => {
253-
if let err_unsup!(NoMirFor(did)) = err.kind() {
254-
let path = ecx.tcx.def_path_str(*did);
255-
return Err(ConstEvalErrKind::NeedsRfc(format!(
256-
"calling extern function `{}`",
257-
path
258-
))
259-
.into());
260-
}
261-
return Err(err);
262-
}
263-
}))
252+
Ok(Some(ecx.load_mir(instance.def, None)?))
264253
}
265254

266255
fn call_intrinsic(

0 commit comments

Comments
 (0)