rustc_const_eval/interpret/
step.rs

1//! This module contains the `InterpCx` methods for executing a single step of the interpreter.
2//!
3//! The main entry point is the `step` method.
4
5use either::Either;
6use rustc_abi::{FIRST_VARIANT, FieldIdx};
7use rustc_data_structures::fx::FxHashSet;
8use rustc_index::IndexSlice;
9use rustc_middle::ty::{self, Instance, Ty};
10use rustc_middle::{bug, mir, span_bug};
11use rustc_span::source_map::Spanned;
12use rustc_target::callconv::FnAbi;
13use tracing::field::Empty;
14use tracing::{info, instrument, trace};
15
16use super::{
17    FnArg, FnVal, ImmTy, Immediate, InterpCx, InterpResult, Machine, MemPlaceMeta, PlaceTy,
18    Projectable, Scalar, interp_ok, throw_ub, throw_unsup_format,
19};
20use crate::interpret::EnteredTraceSpan;
21use crate::{enter_trace_span, util};
22
23struct EvaluatedCalleeAndArgs<'tcx, M: Machine<'tcx>> {
24    callee: FnVal<'tcx, M::ExtraFnVal>,
25    args: Vec<FnArg<'tcx, M::Provenance>>,
26    fn_sig: ty::FnSig<'tcx>,
27    fn_abi: &'tcx FnAbi<'tcx, Ty<'tcx>>,
28    /// True if the function is marked as `#[track_caller]` ([`ty::InstanceKind::requires_caller_location`])
29    with_caller_location: bool,
30}
31
32impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
33    /// Returns `true` as long as there are more things to do.
34    ///
35    /// This is used by [priroda](https://github.com/oli-obk/priroda)
36    ///
37    /// This is marked `#inline(always)` to work around adversarial codegen when `opt-level = 3`
38    #[inline(always)]
39    pub fn step(&mut self) -> InterpResult<'tcx, bool> {
40        if self.stack().is_empty() {
41            return interp_ok(false);
42        }
43
44        let Either::Left(loc) = self.frame().loc else {
45            // We are unwinding and this fn has no cleanup code.
46            // Just go on unwinding.
47            trace!("unwinding: skipping frame");
48            self.return_from_current_stack_frame(/* unwinding */ true)?;
49            return interp_ok(true);
50        };
51        let basic_block = &self.body().basic_blocks[loc.block];
52
53        if let Some(stmt) = basic_block.statements.get(loc.statement_index) {
54            let old_frames = self.frame_idx();
55            self.eval_statement(stmt)?;
56            // Make sure we are not updating `statement_index` of the wrong frame.
57            assert_eq!(old_frames, self.frame_idx());
58            // Advance the program counter.
59            self.frame_mut().loc.as_mut().left().unwrap().statement_index += 1;
60            return interp_ok(true);
61        }
62
63        M::before_terminator(self)?;
64
65        let terminator = basic_block.terminator();
66        self.eval_terminator(terminator)?;
67        if !self.stack().is_empty() {
68            if let Either::Left(loc) = self.frame().loc {
69                info!("// executing {:?}", loc.block);
70            }
71        }
72        interp_ok(true)
73    }
74
75    /// Runs the interpretation logic for the given `mir::Statement` at the current frame and
76    /// statement counter.
77    ///
78    /// This does NOT move the statement counter forward, the caller has to do that!
79    pub fn eval_statement(&mut self, stmt: &mir::Statement<'tcx>) -> InterpResult<'tcx> {
80        let _trace = enter_trace_span!(
81            M,
82            step::eval_statement,
83            stmt = ?stmt.kind,
84            span = ?stmt.source_info.span,
85            tracing_separate_thread = Empty,
86        )
87        .or_if_tracing_disabled(|| info!(stmt = ?stmt.kind));
88
89        use rustc_middle::mir::StatementKind::*;
90
91        match &stmt.kind {
92            Assign(box (place, rvalue)) => self.eval_rvalue_into_place(rvalue, *place)?,
93
94            SetDiscriminant { place, variant_index } => {
95                let dest = self.eval_place(**place)?;
96                self.write_discriminant(*variant_index, &dest)?;
97            }
98
99            Deinit(place) => {
100                let dest = self.eval_place(**place)?;
101                self.write_uninit(&dest)?;
102            }
103
104            // Mark locals as alive
105            StorageLive(local) => {
106                self.storage_live(*local)?;
107            }
108
109            // Mark locals as dead
110            StorageDead(local) => {
111                self.storage_dead(*local)?;
112            }
113
114            // No dynamic semantics attached to `FakeRead`; MIR
115            // interpreter is solely intended for borrowck'ed code.
116            FakeRead(..) => {}
117
118            // Stacked Borrows.
119            Retag(kind, place) => {
120                let dest = self.eval_place(**place)?;
121                M::retag_place_contents(self, *kind, &dest)?;
122            }
123
124            Intrinsic(box intrinsic) => self.eval_nondiverging_intrinsic(intrinsic)?,
125
126            // Evaluate the place expression, without reading from it.
127            PlaceMention(box place) => {
128                let _ = self.eval_place(*place)?;
129            }
130
131            // This exists purely to guide borrowck lifetime inference, and does not have
132            // an operational effect.
133            AscribeUserType(..) => {}
134
135            // Currently, Miri discards Coverage statements. Coverage statements are only injected
136            // via an optional compile time MIR pass and have no side effects. Since Coverage
137            // statements don't exist at the source level, it is safe for Miri to ignore them, even
138            // for undefined behavior (UB) checks.
139            //
140            // A coverage counter inside a const expression (for example, a counter injected in a
141            // const function) is discarded when the const is evaluated at compile time. Whether
142            // this should change, and/or how to implement a const eval counter, is a subject of the
143            // following issue:
144            //
145            // FIXME(#73156): Handle source code coverage in const eval
146            Coverage(..) => {}
147
148            ConstEvalCounter => {
149                M::increment_const_eval_counter(self)?;
150            }
151
152            // Defined to do nothing. These are added by optimization passes, to avoid changing the
153            // size of MIR constantly.
154            Nop => {}
155
156            // Only used for temporary lifetime lints
157            BackwardIncompatibleDropHint { .. } => {}
158        }
159
160        interp_ok(())
161    }
162
163    /// Evaluate an assignment statement.
164    ///
165    /// There is no separate `eval_rvalue` function. Instead, the code for handling each rvalue
166    /// type writes its results directly into the memory specified by the place.
167    pub fn eval_rvalue_into_place(
168        &mut self,
169        rvalue: &mir::Rvalue<'tcx>,
170        place: mir::Place<'tcx>,
171    ) -> InterpResult<'tcx> {
172        let dest = self.eval_place(place)?;
173        // FIXME: ensure some kind of non-aliasing between LHS and RHS?
174        // Also see https://github.com/rust-lang/rust/issues/68364.
175
176        use rustc_middle::mir::Rvalue::*;
177        match *rvalue {
178            ThreadLocalRef(did) => {
179                let ptr = M::thread_local_static_pointer(self, did)?;
180                self.write_pointer(ptr, &dest)?;
181            }
182
183            Use(ref operand) => {
184                // Avoid recomputing the layout
185                let op = self.eval_operand(operand, Some(dest.layout))?;
186                self.copy_op(&op, &dest)?;
187            }
188
189            CopyForDeref(place) => {
190                let op = self.eval_place_to_op(place, Some(dest.layout))?;
191                self.copy_op(&op, &dest)?;
192            }
193
194            BinaryOp(bin_op, box (ref left, ref right)) => {
195                let layout = util::binop_left_homogeneous(bin_op).then_some(dest.layout);
196                let left = self.read_immediate(&self.eval_operand(left, layout)?)?;
197                let layout = util::binop_right_homogeneous(bin_op).then_some(left.layout);
198                let right = self.read_immediate(&self.eval_operand(right, layout)?)?;
199                let result = self.binary_op(bin_op, &left, &right)?;
200                assert_eq!(result.layout, dest.layout, "layout mismatch for result of {bin_op:?}");
201                self.write_immediate(*result, &dest)?;
202            }
203
204            UnaryOp(un_op, ref operand) => {
205                // The operand always has the same type as the result.
206                let val = self.read_immediate(&self.eval_operand(operand, Some(dest.layout))?)?;
207                let result = self.unary_op(un_op, &val)?;
208                assert_eq!(result.layout, dest.layout, "layout mismatch for result of {un_op:?}");
209                self.write_immediate(*result, &dest)?;
210            }
211
212            NullaryOp(null_op, ty) => {
213                let ty = self.instantiate_from_current_frame_and_normalize_erasing_regions(ty)?;
214                let val = self.nullary_op(null_op, ty)?;
215                self.write_immediate(*val, &dest)?;
216            }
217
218            Aggregate(box ref kind, ref operands) => {
219                self.write_aggregate(kind, operands, &dest)?;
220            }
221
222            Repeat(ref operand, _) => {
223                self.write_repeat(operand, &dest)?;
224            }
225
226            Len(place) => {
227                let src = self.eval_place(place)?;
228                let len = src.len(self)?;
229                self.write_scalar(Scalar::from_target_usize(len, self), &dest)?;
230            }
231
232            Ref(_, borrow_kind, place) => {
233                let src = self.eval_place(place)?;
234                let place = self.force_allocation(&src)?;
235                let val = ImmTy::from_immediate(place.to_ref(self), dest.layout);
236                // A fresh reference was created, make sure it gets retagged.
237                let val = M::retag_ptr_value(
238                    self,
239                    if borrow_kind.allows_two_phase_borrow() {
240                        mir::RetagKind::TwoPhase
241                    } else {
242                        mir::RetagKind::Default
243                    },
244                    &val,
245                )?;
246                self.write_immediate(*val, &dest)?;
247            }
248
249            RawPtr(kind, place) => {
250                // Figure out whether this is an addr_of of an already raw place.
251                let place_base_raw = if place.is_indirect_first_projection() {
252                    let ty = self.frame().body.local_decls[place.local].ty;
253                    ty.is_raw_ptr()
254                } else {
255                    // Not a deref, and thus not raw.
256                    false
257                };
258
259                let src = self.eval_place(place)?;
260                let place = self.force_allocation(&src)?;
261                let mut val = ImmTy::from_immediate(place.to_ref(self), dest.layout);
262                if !place_base_raw && !kind.is_fake() {
263                    // If this was not already raw, it needs retagging -- except for "fake"
264                    // raw borrows whose defining property is that they do not get retagged.
265                    val = M::retag_ptr_value(self, mir::RetagKind::Raw, &val)?;
266                }
267                self.write_immediate(*val, &dest)?;
268            }
269
270            ShallowInitBox(ref operand, _) => {
271                let src = self.eval_operand(operand, None)?;
272                let v = self.read_immediate(&src)?;
273                self.write_immediate(*v, &dest)?;
274            }
275
276            Cast(cast_kind, ref operand, cast_ty) => {
277                let src = self.eval_operand(operand, None)?;
278                let cast_ty =
279                    self.instantiate_from_current_frame_and_normalize_erasing_regions(cast_ty)?;
280                self.cast(&src, cast_kind, cast_ty, &dest)?;
281            }
282
283            Discriminant(place) => {
284                let op = self.eval_place_to_op(place, None)?;
285                let variant = self.read_discriminant(&op)?;
286                let discr = self.discriminant_for_variant(op.layout.ty, variant)?;
287                self.write_immediate(*discr, &dest)?;
288            }
289
290            WrapUnsafeBinder(ref op, _ty) => {
291                // Constructing an unsafe binder acts like a transmute
292                // since the operand's layout does not change.
293                let op = self.eval_operand(op, None)?;
294                self.copy_op_allow_transmute(&op, &dest)?;
295            }
296        }
297
298        trace!("{:?}", self.dump_place(&dest));
299
300        interp_ok(())
301    }
302
303    /// Writes the aggregate to the destination.
304    #[instrument(skip(self), level = "trace")]
305    fn write_aggregate(
306        &mut self,
307        kind: &mir::AggregateKind<'tcx>,
308        operands: &IndexSlice<FieldIdx, mir::Operand<'tcx>>,
309        dest: &PlaceTy<'tcx, M::Provenance>,
310    ) -> InterpResult<'tcx> {
311        self.write_uninit(dest)?; // make sure all the padding ends up as uninit
312        let (variant_index, variant_dest, active_field_index) = match *kind {
313            mir::AggregateKind::Adt(_, variant_index, _, _, active_field_index) => {
314                let variant_dest = self.project_downcast(dest, variant_index)?;
315                (variant_index, variant_dest, active_field_index)
316            }
317            mir::AggregateKind::RawPtr(..) => {
318                // Pointers don't have "fields" in the normal sense, so the
319                // projection-based code below would either fail in projection
320                // or in type mismatches. Instead, build an `Immediate` from
321                // the parts and write that to the destination.
322                let [data, meta] = &operands.raw else {
323                    bug!("{kind:?} should have 2 operands, had {operands:?}");
324                };
325                let data = self.eval_operand(data, None)?;
326                let data = self.read_pointer(&data)?;
327                let meta = self.eval_operand(meta, None)?;
328                let meta = if meta.layout.is_zst() {
329                    MemPlaceMeta::None
330                } else {
331                    MemPlaceMeta::Meta(self.read_scalar(&meta)?)
332                };
333                let ptr_imm = Immediate::new_pointer_with_meta(data, meta, self);
334                let ptr = ImmTy::from_immediate(ptr_imm, dest.layout);
335                self.copy_op(&ptr, dest)?;
336                return interp_ok(());
337            }
338            _ => (FIRST_VARIANT, dest.clone(), None),
339        };
340        if active_field_index.is_some() {
341            assert_eq!(operands.len(), 1);
342        }
343        for (field_index, operand) in operands.iter_enumerated() {
344            let field_index = active_field_index.unwrap_or(field_index);
345            let field_dest = self.project_field(&variant_dest, field_index)?;
346            let op = self.eval_operand(operand, Some(field_dest.layout))?;
347            self.copy_op(&op, &field_dest)?;
348        }
349        self.write_discriminant(variant_index, dest)
350    }
351
352    /// Repeats `operand` into the destination. `dest` must have array type, and that type
353    /// determines how often `operand` is repeated.
354    fn write_repeat(
355        &mut self,
356        operand: &mir::Operand<'tcx>,
357        dest: &PlaceTy<'tcx, M::Provenance>,
358    ) -> InterpResult<'tcx> {
359        let src = self.eval_operand(operand, None)?;
360        assert!(src.layout.is_sized());
361        let dest = self.force_allocation(&dest)?;
362        let length = dest.len(self)?;
363
364        if length == 0 {
365            // Nothing to copy... but let's still make sure that `dest` as a place is valid.
366            self.get_place_alloc_mut(&dest)?;
367        } else {
368            // Write the src to the first element.
369            let first = self.project_index(&dest, 0)?;
370            self.copy_op(&src, &first)?;
371
372            // This is performance-sensitive code for big static/const arrays! So we
373            // avoid writing each operand individually and instead just make many copies
374            // of the first element.
375            let elem_size = first.layout.size;
376            let first_ptr = first.ptr();
377            let rest_ptr = first_ptr.wrapping_offset(elem_size, self);
378            // No alignment requirement since `copy_op` above already checked it.
379            self.mem_copy_repeatedly(
380                first_ptr,
381                rest_ptr,
382                elem_size,
383                length - 1,
384                /*nonoverlapping:*/ true,
385            )?;
386        }
387
388        interp_ok(())
389    }
390
391    /// Evaluate the arguments of a function call
392    fn eval_fn_call_argument(
393        &mut self,
394        op: &mir::Operand<'tcx>,
395        move_definitely_disjoint: bool,
396    ) -> InterpResult<'tcx, FnArg<'tcx, M::Provenance>> {
397        interp_ok(match op {
398            mir::Operand::Copy(_) | mir::Operand::Constant(_) => {
399                // Make a regular copy.
400                let op = self.eval_operand(op, None)?;
401                FnArg::Copy(op)
402            }
403            mir::Operand::Move(place) => {
404                let place = self.eval_place(*place)?;
405                if move_definitely_disjoint {
406                    // We still have to ensure that no *other* pointers are used to access this place,
407                    // so *if* it is in memory then we have to treat it as `InPlace`.
408                    // Use `place_to_op` to guarantee that we notice it being in memory.
409                    let op = self.place_to_op(&place)?;
410                    match op.as_mplace_or_imm() {
411                        Either::Left(mplace) => FnArg::InPlace(mplace),
412                        Either::Right(_imm) => FnArg::Copy(op),
413                    }
414                } else {
415                    // We have to force this into memory to detect aliasing among `Move` arguments.
416                    FnArg::InPlace(self.force_allocation(&place)?)
417                }
418            }
419        })
420    }
421
422    /// Shared part of `Call` and `TailCall` implementation — finding and evaluating all the
423    /// necessary information about callee and arguments to make a call.
424    fn eval_callee_and_args(
425        &mut self,
426        terminator: &mir::Terminator<'tcx>,
427        func: &mir::Operand<'tcx>,
428        args: &[Spanned<mir::Operand<'tcx>>],
429    ) -> InterpResult<'tcx, EvaluatedCalleeAndArgs<'tcx, M>> {
430        let func = self.eval_operand(func, None)?;
431
432        // Evaluating function call arguments. The tricky part here is dealing with `Move`
433        // arguments: we have to ensure no two such arguments alias. This would be most easily done
434        // by just forcing them all into memory and then doing the usual in-place argument
435        // protection, but then we'd force *a lot* of arguments into memory. So we do some syntactic
436        // pre-processing here where if all `move` arguments are syntactically distinct local
437        // variables (and none is indirect), we can skip the in-memory forcing.
438        let move_definitely_disjoint = 'move_definitely_disjoint: {
439            let mut previous_locals = FxHashSet::<mir::Local>::default();
440            for arg in args {
441                let mir::Operand::Move(place) = arg.node else {
442                    continue; // we can skip non-`Move` arguments.
443                };
444                if place.is_indirect_first_projection() {
445                    // An indirect `Move` argument could alias with anything else...
446                    break 'move_definitely_disjoint false;
447                }
448                if !previous_locals.insert(place.local) {
449                    // This local is the base for two arguments! They might overlap.
450                    break 'move_definitely_disjoint false;
451                }
452            }
453            // We found no violation so they are all definitely disjoint.
454            true
455        };
456        let args = args
457            .iter()
458            .map(|arg| self.eval_fn_call_argument(&arg.node, move_definitely_disjoint))
459            .collect::<InterpResult<'tcx, Vec<_>>>()?;
460
461        let fn_sig_binder = {
462            let _trace = enter_trace_span!(M, "fn_sig", ty = ?func.layout.ty.kind());
463            func.layout.ty.fn_sig(*self.tcx)
464        };
465        let fn_sig = self.tcx.normalize_erasing_late_bound_regions(self.typing_env, fn_sig_binder);
466        let extra_args = &args[fn_sig.inputs().len()..];
467        let extra_args =
468            self.tcx.mk_type_list_from_iter(extra_args.iter().map(|arg| arg.layout().ty));
469
470        let (callee, fn_abi, with_caller_location) = match *func.layout.ty.kind() {
471            ty::FnPtr(..) => {
472                let fn_ptr = self.read_pointer(&func)?;
473                let fn_val = self.get_ptr_fn(fn_ptr)?;
474                (fn_val, self.fn_abi_of_fn_ptr(fn_sig_binder, extra_args)?, false)
475            }
476            ty::FnDef(def_id, args) => {
477                let instance = self.resolve(def_id, args)?;
478                (
479                    FnVal::Instance(instance),
480                    self.fn_abi_of_instance(instance, extra_args)?,
481                    instance.def.requires_caller_location(*self.tcx),
482                )
483            }
484            _ => {
485                span_bug!(terminator.source_info.span, "invalid callee of type {}", func.layout.ty)
486            }
487        };
488
489        interp_ok(EvaluatedCalleeAndArgs { callee, args, fn_sig, fn_abi, with_caller_location })
490    }
491
492    fn eval_terminator(&mut self, terminator: &mir::Terminator<'tcx>) -> InterpResult<'tcx> {
493        let _trace = enter_trace_span!(
494            M,
495            step::eval_terminator,
496            terminator = ?terminator.kind,
497            span = ?terminator.source_info.span,
498            tracing_separate_thread = Empty,
499        )
500        .or_if_tracing_disabled(|| info!(terminator = ?terminator.kind));
501
502        use rustc_middle::mir::TerminatorKind::*;
503        match terminator.kind {
504            Return => {
505                self.return_from_current_stack_frame(/* unwinding */ false)?
506            }
507
508            Goto { target } => self.go_to_block(target),
509
510            SwitchInt { ref discr, ref targets } => {
511                let discr = self.read_immediate(&self.eval_operand(discr, None)?)?;
512                trace!("SwitchInt({:?})", *discr);
513
514                // Branch to the `otherwise` case by default, if no match is found.
515                let mut target_block = targets.otherwise();
516
517                for (const_int, target) in targets.iter() {
518                    // Compare using MIR BinOp::Eq, to also support pointer values.
519                    // (Avoiding `self.binary_op` as that does some redundant layout computation.)
520                    let res = self.binary_op(
521                        mir::BinOp::Eq,
522                        &discr,
523                        &ImmTy::from_uint(const_int, discr.layout),
524                    )?;
525                    if res.to_scalar().to_bool()? {
526                        target_block = target;
527                        break;
528                    }
529                }
530
531                self.go_to_block(target_block);
532            }
533
534            Call {
535                ref func,
536                ref args,
537                destination,
538                target,
539                unwind,
540                call_source: _,
541                fn_span: _,
542            } => {
543                let old_stack = self.frame_idx();
544                let old_loc = self.frame().loc;
545
546                let EvaluatedCalleeAndArgs { callee, args, fn_sig, fn_abi, with_caller_location } =
547                    self.eval_callee_and_args(terminator, func, args)?;
548
549                let destination = self.eval_place(destination)?;
550                self.init_fn_call(
551                    callee,
552                    (fn_sig.abi, fn_abi),
553                    &args,
554                    with_caller_location,
555                    &destination,
556                    target,
557                    if fn_abi.can_unwind { unwind } else { mir::UnwindAction::Unreachable },
558                )?;
559                // Sanity-check that `eval_fn_call` either pushed a new frame or
560                // did a jump to another block.
561                if self.frame_idx() == old_stack && self.frame().loc == old_loc {
562                    span_bug!(terminator.source_info.span, "evaluating this call made no progress");
563                }
564            }
565
566            TailCall { ref func, ref args, fn_span: _ } => {
567                let old_frame_idx = self.frame_idx();
568
569                let EvaluatedCalleeAndArgs { callee, args, fn_sig, fn_abi, with_caller_location } =
570                    self.eval_callee_and_args(terminator, func, args)?;
571
572                self.init_fn_tail_call(callee, (fn_sig.abi, fn_abi), &args, with_caller_location)?;
573
574                if self.frame_idx() != old_frame_idx {
575                    span_bug!(
576                        terminator.source_info.span,
577                        "evaluating this tail call pushed a new stack frame"
578                    );
579                }
580            }
581
582            Drop { place, target, unwind, replace: _, drop, async_fut } => {
583                assert!(
584                    async_fut.is_none() && drop.is_none(),
585                    "Async Drop must be expanded or reset to sync in runtime MIR"
586                );
587                let place = self.eval_place(place)?;
588                let instance = {
589                    let _trace =
590                        enter_trace_span!(M, resolve::resolve_drop_in_place, ty = ?place.layout.ty);
591                    Instance::resolve_drop_in_place(*self.tcx, place.layout.ty)
592                };
593                if let ty::InstanceKind::DropGlue(_, None) = instance.def {
594                    // This is the branch we enter if and only if the dropped type has no drop glue
595                    // whatsoever. This can happen as a result of monomorphizing a drop of a
596                    // generic. In order to make sure that generic and non-generic code behaves
597                    // roughly the same (and in keeping with Mir semantics) we do nothing here.
598                    self.go_to_block(target);
599                    return interp_ok(());
600                }
601                trace!("TerminatorKind::drop: {:?}, type {}", place, place.layout.ty);
602                self.init_drop_in_place_call(&place, instance, target, unwind)?;
603            }
604
605            Assert { ref cond, expected, ref msg, target, unwind } => {
606                let ignored =
607                    M::ignore_optional_overflow_checks(self) && msg.is_optional_overflow_check();
608                let cond_val = self.read_scalar(&self.eval_operand(cond, None)?)?.to_bool()?;
609                if ignored || expected == cond_val {
610                    self.go_to_block(target);
611                } else {
612                    M::assert_panic(self, msg, unwind)?;
613                }
614            }
615
616            UnwindTerminate(reason) => {
617                M::unwind_terminate(self, reason)?;
618            }
619
620            // When we encounter Resume, we've finished unwinding
621            // cleanup for the current stack frame. We pop it in order
622            // to continue unwinding the next frame
623            UnwindResume => {
624                trace!("unwinding: resuming from cleanup");
625                // By definition, a Resume terminator means
626                // that we're unwinding
627                self.return_from_current_stack_frame(/* unwinding */ true)?;
628                return interp_ok(());
629            }
630
631            // It is UB to ever encounter this.
632            Unreachable => throw_ub!(Unreachable),
633
634            // These should never occur for MIR we actually run.
635            FalseEdge { .. } | FalseUnwind { .. } | Yield { .. } | CoroutineDrop => span_bug!(
636                terminator.source_info.span,
637                "{:#?} should have been eliminated by MIR pass",
638                terminator.kind
639            ),
640
641            InlineAsm { .. } => {
642                throw_unsup_format!("inline assembly is not supported");
643            }
644        }
645
646        interp_ok(())
647    }
648}