Skip to content

Commit dc9b611

Browse files
committed
Move eval_body call inside a match
1 parent 586d704 commit dc9b611

File tree

1 file changed

+13
-20
lines changed

1 file changed

+13
-20
lines changed

compiler/rustc_const_eval/src/interpret/terminator.rs

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -548,24 +548,8 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
548548
| ty::InstanceDef::CloneShim(..)
549549
| ty::InstanceDef::FnPtrAddrShim(..)
550550
| ty::InstanceDef::ThreadLocalShim(..)
551-
| ty::InstanceDef::Item(_) => {
552-
// We need MIR for this fn
553-
let body = match M::find_mir_or_extra_fn(self, instance)? {
554-
Either::Left(b) => b,
555-
Either::Right(f) => {
556-
return M::call_extra_fn(
557-
self,
558-
f,
559-
(caller_abi, caller_fn_abi),
560-
args,
561-
destination,
562-
target,
563-
unwind,
564-
);
565-
}
566-
};
567-
568-
self.eval_body(
551+
| ty::InstanceDef::Item(_) => match M::find_mir_or_extra_fn(self, instance)? {
552+
Either::Left(body) => self.eval_body(
569553
instance,
570554
body,
571555
(caller_abi, caller_fn_abi),
@@ -574,8 +558,17 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
574558
destination,
575559
target,
576560
unwind,
577-
)
578-
}
561+
),
562+
Either::Right(f) => M::call_extra_fn(
563+
self,
564+
f,
565+
(caller_abi, caller_fn_abi),
566+
args,
567+
destination,
568+
target,
569+
unwind,
570+
),
571+
},
579572
// `InstanceDef::Virtual` does not have callable MIR. Calls to `Virtual` instances must be
580573
// codegen'd / interpreted as virtual calls through the vtable.
581574
ty::InstanceDef::Virtual(def_id, idx) => {

0 commit comments

Comments
 (0)