make Machine::load_mir infallible

it doesn't need to return an `InterpResult`.
This commit is contained in:
Deadbeef 2025-07-07 19:56:56 +08:00
parent 75d5834a6c
commit be6cd11d1b
3 changed files with 6 additions and 6 deletions

View file

@ -331,10 +331,10 @@ impl<'tcx> interpret::Machine<'tcx> for CompileTimeMachine<'tcx> {
fn load_mir(
ecx: &InterpCx<'tcx, Self>,
instance: ty::InstanceKind<'tcx>,
) -> InterpResult<'tcx, &'tcx mir::Body<'tcx>> {
) -> &'tcx mir::Body<'tcx> {
match instance {
ty::InstanceKind::Item(def) => interp_ok(ecx.tcx.mir_for_ctfe(def)),
_ => interp_ok(ecx.tcx.instance_mir(instance)),
ty::InstanceKind::Item(def) => ecx.tcx.mir_for_ctfe(def),
_ => ecx.tcx.instance_mir(instance),
}
}

View file

@ -272,7 +272,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
let def = instance.def_id();
&self.tcx.promoted_mir(def)[promoted]
} else {
M::load_mir(self, instance)?
M::load_mir(self, instance)
};
// do not continue if typeck errors occurred (can only occur in local crate)
if let Some(err) = body.tainted_by_errors {

View file

@ -189,8 +189,8 @@ pub trait Machine<'tcx>: Sized {
fn load_mir(
ecx: &InterpCx<'tcx, Self>,
instance: ty::InstanceKind<'tcx>,
) -> InterpResult<'tcx, &'tcx mir::Body<'tcx>> {
interp_ok(ecx.tcx.instance_mir(instance))
) -> &'tcx mir::Body<'tcx> {
ecx.tcx.instance_mir(instance)
}
/// Entry point to all function calls.