Skip to main content

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 std::iter;
6
7use either::Either;
8use rustc_abi::{FIRST_VARIANT, FieldIdx};
9use rustc_data_structures::fx::FxHashSet;
10use rustc_index::IndexSlice;
11use rustc_middle::ty::{self, Instance, Ty};
12use rustc_middle::{bug, mir, span_bug};
13use rustc_span::Spanned;
14use rustc_target::callconv::FnAbi;
15use tracing::field::Empty;
16use tracing::{info, instrument, trace};
17
18use super::{
19    EnteredTraceSpan, FnArg, FnVal, ImmTy, Immediate, InterpCx, InterpResult, Machine,
20    MemPlaceMeta, PlaceTy, Projectable, RetagMode, interp_ok, throw_ub, throw_unsup_format,
21};
22use crate::{enter_trace_span, util};
23
24struct EvaluatedCalleeAndArgs<'tcx, M: Machine<'tcx>> {
25    callee: FnVal<'tcx, M::ExtraFnVal>,
26    args: Vec<FnArg<'tcx, M::Provenance>>,
27    fn_sig: ty::FnSig<'tcx>,
28    fn_abi: &'tcx FnAbi<'tcx, Ty<'tcx>>,
29    /// True if the function is marked as `#[track_caller]` ([`ty::InstanceKind::requires_caller_location`])
30    with_caller_location: bool,
31}
32
33impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
34    /// Returns `true` as long as there are more things to do.
35    ///
36    /// This is used by [priroda](https://github.com/oli-obk/priroda)
37    ///
38    /// This is marked `#inline(always)` to work around adversarial codegen when `opt-level = 3`
39    #[inline(always)]
40    pub fn step(&mut self) -> InterpResult<'tcx, bool> {
41        if self.stack().is_empty() {
42            return interp_ok(false);
43        }
44
45        let Either::Left(loc) = self.frame().loc else {
46            // We are unwinding and this fn has no cleanup code.
47            // Just go on unwinding.
48            {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event compiler/rustc_const_eval/src/interpret/step.rs:48",
                        "rustc_const_eval::interpret::step",
                        ::tracing::Level::TRACE,
                        ::tracing_core::__macro_support::Option::Some("compiler/rustc_const_eval/src/interpret/step.rs"),
                        ::tracing_core::__macro_support::Option::Some(48u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_const_eval::interpret::step"),
                        ::tracing_core::field::FieldSet::new(&["message"],
                            ::tracing_core::callsite::Identifier(&__CALLSITE)),
                        ::tracing::metadata::Kind::EVENT)
                };
            ::tracing::callsite::DefaultCallsite::new(&META)
        };
    let enabled =
        ::tracing::Level::TRACE <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::TRACE <=
                    ::tracing::level_filters::LevelFilter::current() &&
            {
                let interest = __CALLSITE.interest();
                !interest.is_never() &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest)
            };
    if enabled {
        (|value_set: ::tracing::field::ValueSet|
                    {
                        let meta = __CALLSITE.metadata();
                        ::tracing::Event::dispatch(meta, &value_set);
                        ;
                    })({
                #[allow(unused_imports)]
                use ::tracing::field::{debug, display, Value};
                __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("unwinding: skipping frame")
                                            as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};trace!("unwinding: skipping frame");
49            self.return_from_current_stack_frame(/* unwinding */ true)?;
50            return interp_ok(true);
51        };
52        let basic_block = &self.body().basic_blocks[loc.block];
53
54        if let Some(stmt) = basic_block.statements.get(loc.statement_index) {
55            let old_frames = self.frame_idx();
56            self.eval_statement(stmt)?;
57            // Make sure we are not updating `statement_index` of the wrong frame.
58            {
    match (&old_frames, &self.frame_idx()) {
        (left_val, right_val) => {
            if !(*left_val == *right_val) {
                let kind = ::core::panicking::AssertKind::Eq;
                ::core::panicking::assert_failed(kind, &*left_val,
                    &*right_val, ::core::option::Option::None);
            }
        }
    }
};assert_eq!(old_frames, self.frame_idx());
59            // Advance the program counter.
60            self.frame_mut().loc.as_mut().left().unwrap().statement_index += 1;
61            return interp_ok(true);
62        }
63
64        M::before_terminator(self)?;
65
66        let terminator = basic_block.terminator();
67        self.eval_terminator(terminator)?;
68        if !self.stack().is_empty() {
69            if let Either::Left(loc) = self.frame().loc {
70                {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event compiler/rustc_const_eval/src/interpret/step.rs:70",
                        "rustc_const_eval::interpret::step", ::tracing::Level::INFO,
                        ::tracing_core::__macro_support::Option::Some("compiler/rustc_const_eval/src/interpret/step.rs"),
                        ::tracing_core::__macro_support::Option::Some(70u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_const_eval::interpret::step"),
                        ::tracing_core::field::FieldSet::new(&["message"],
                            ::tracing_core::callsite::Identifier(&__CALLSITE)),
                        ::tracing::metadata::Kind::EVENT)
                };
            ::tracing::callsite::DefaultCallsite::new(&META)
        };
    let enabled =
        ::tracing::Level::INFO <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::INFO <=
                    ::tracing::level_filters::LevelFilter::current() &&
            {
                let interest = __CALLSITE.interest();
                !interest.is_never() &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest)
            };
    if enabled {
        (|value_set: ::tracing::field::ValueSet|
                    {
                        let meta = __CALLSITE.metadata();
                        ::tracing::Event::dispatch(meta, &value_set);
                        ;
                    })({
                #[allow(unused_imports)]
                use ::tracing::field::{debug, display, Value};
                __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("// executing {0:?}",
                                                    loc.block) as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};info!("// executing {:?}", loc.block);
71            }
72        }
73        interp_ok(true)
74    }
75
76    /// Runs the interpretation logic for the given `mir::Statement` at the current frame and
77    /// statement counter.
78    ///
79    /// This does NOT move the statement counter forward, the caller has to do that!
80    pub fn eval_statement(&mut self, stmt: &mir::Statement<'tcx>) -> InterpResult<'tcx> {
81        let _trace = <M as
        crate::interpret::Machine>::enter_trace_span(||
        {
            use ::tracing::__macro_support::Callsite as _;
            static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                {
                    static META: ::tracing::Metadata<'static> =
                        {
                            ::tracing_core::metadata::Metadata::new("step",
                                "rustc_const_eval::interpret::step", ::tracing::Level::INFO,
                                ::tracing_core::__macro_support::Option::Some("compiler/rustc_const_eval/src/interpret/step.rs"),
                                ::tracing_core::__macro_support::Option::Some(81u32),
                                ::tracing_core::__macro_support::Option::Some("rustc_const_eval::interpret::step"),
                                ::tracing_core::field::FieldSet::new(&[{
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("step")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("step");
                                                    NAME.as_str()
                                                },
                                                {
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("stmt")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("stmt");
                                                    NAME.as_str()
                                                },
                                                {
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("span")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("span");
                                                    NAME.as_str()
                                                },
                                                {
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("tracing_separate_thread")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("tracing_separate_thread");
                                                    NAME.as_str()
                                                }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                ::tracing::metadata::Kind::SPAN)
                        };
                    ::tracing::callsite::DefaultCallsite::new(&META)
                };
            let mut interest = ::tracing::subscriber::Interest::never();
            if ::tracing::Level::INFO <=
                                ::tracing::level_filters::STATIC_MAX_LEVEL &&
                            ::tracing::Level::INFO <=
                                ::tracing::level_filters::LevelFilter::current() &&
                        { interest = __CALLSITE.interest(); !interest.is_never() }
                    &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest) {
                let meta = __CALLSITE.metadata();
                ::tracing::Span::new(meta,
                    &{
                            #[allow(unused_imports)]
                            use ::tracing::field::{debug, display, Value};
                            meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::display(&"eval_statement")
                                                        as &dyn ::tracing::field::Value)),
                                            (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&stmt.kind)
                                                        as &dyn ::tracing::field::Value)),
                                            (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&stmt.source_info.span)
                                                        as &dyn ::tracing::field::Value)),
                                            (::tracing::__macro_support::Option::Some(&Empty as
                                                        &dyn ::tracing::field::Value))])
                        })
            } else {
                let span =
                    ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                {};
                span
            }
        })enter_trace_span!(
82            M,
83            step::eval_statement,
84            stmt = ?stmt.kind,
85            span = ?stmt.source_info.span,
86            tracing_separate_thread = Empty,
87        )
88        .or_if_tracing_disabled(|| {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event compiler/rustc_const_eval/src/interpret/step.rs:88",
                        "rustc_const_eval::interpret::step", ::tracing::Level::INFO,
                        ::tracing_core::__macro_support::Option::Some("compiler/rustc_const_eval/src/interpret/step.rs"),
                        ::tracing_core::__macro_support::Option::Some(88u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_const_eval::interpret::step"),
                        ::tracing_core::field::FieldSet::new(&["message"],
                            ::tracing_core::callsite::Identifier(&__CALLSITE)),
                        ::tracing::metadata::Kind::EVENT)
                };
            ::tracing::callsite::DefaultCallsite::new(&META)
        };
    let enabled =
        ::tracing::Level::INFO <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::INFO <=
                    ::tracing::level_filters::LevelFilter::current() &&
            {
                let interest = __CALLSITE.interest();
                !interest.is_never() &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest)
            };
    if enabled {
        (|value_set: ::tracing::field::ValueSet|
                    {
                        let meta = __CALLSITE.metadata();
                        ::tracing::Event::dispatch(meta, &value_set);
                        ;
                    })({
                #[allow(unused_imports)]
                use ::tracing::field::{debug, display, Value};
                __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("{0:?}",
                                                    stmt.kind) as &dyn ::tracing::field::Value))])
            });
    } else { ; }
}info!("{:?}", stmt.kind));
89
90        use rustc_middle::mir::StatementKind::*;
91
92        match &stmt.kind {
93            Assign((place, rvalue)) => self.eval_rvalue_into_place(rvalue, *place)?,
94
95            SetDiscriminant { place, variant_index } => {
96                let dest =
97                    self.eval_place(**place, /* skip_validity_for_simple_deref */ false)?;
98                self.write_discriminant(*variant_index, &dest)?;
99            }
100
101            // Mark locals as alive
102            StorageLive(local) => {
103                self.storage_live(*local)?;
104            }
105
106            // Mark locals as dead
107            StorageDead(local) => {
108                self.storage_dead(*local)?;
109            }
110
111            // No dynamic semantics attached to `FakeRead`; MIR
112            // interpreter is solely intended for borrowck'ed code.
113            FakeRead(..) => {}
114
115            Intrinsic(intrinsic) => self.eval_nondiverging_intrinsic(intrinsic)?,
116
117            // Evaluate the place expression, without reading from it.
118            PlaceMention(place) => {
119                let _ =
120                    self.eval_place(**place, /* skip_validity_for_simple_deref */ false)?;
121            }
122
123            // This exists purely to guide borrowck lifetime inference, and does not have
124            // an operational effect.
125            AscribeUserType(..) => {}
126
127            // Currently, Miri discards Coverage statements. Coverage statements are only injected
128            // via an optional compile time MIR pass and have no side effects. Since Coverage
129            // statements don't exist at the source level, it is safe for Miri to ignore them, even
130            // for undefined behavior (UB) checks.
131            //
132            // A coverage counter inside a const expression (for example, a counter injected in a
133            // const function) is discarded when the const is evaluated at compile time. Whether
134            // this should change, and/or how to implement a const eval counter, is a subject of the
135            // following issue:
136            //
137            // FIXME(#73156): Handle source code coverage in const eval
138            Coverage(..) => {}
139
140            ConstEvalCounter => {
141                M::increment_const_eval_counter(self)?;
142            }
143
144            // Defined to do nothing. These are added by optimization passes, to avoid changing the
145            // size of MIR constantly.
146            Nop => {}
147
148            // Only used for temporary lifetime lints
149            BackwardIncompatibleDropHint { .. } => {}
150        }
151
152        interp_ok(())
153    }
154
155    /// Evaluate an assignment statement.
156    ///
157    /// There is no separate `eval_rvalue` function. Instead, the code for handling each rvalue
158    /// type writes its results directly into the memory specified by the place.
159    pub fn eval_rvalue_into_place(
160        &mut self,
161        rvalue: &mir::Rvalue<'tcx>,
162        place: mir::Place<'tcx>,
163    ) -> InterpResult<'tcx> {
164        // We can skip validity because we'll write to the place which checks everything we care
165        // about for references, and the pointee must be sized so there's nothing to check for raw
166        // pointers.
167        let dest = self.eval_place(place, /* skip_validity_for_simple_deref */ true)?;
168        // FIXME: ensure some kind of non-aliasing between LHS and RHS?
169        // Also see https://github.com/rust-lang/rust/issues/68364.
170
171        use rustc_middle::mir::Rvalue::*;
172        match *rvalue {
173            ThreadLocalRef(did) => {
174                let ptr = M::thread_local_static_pointer(self, did)?;
175                self.write_pointer(ptr, &dest)?;
176            }
177
178            Use(ref operand, with_retag) => {
179                // Avoid recomputing the layout
180                let op = self.eval_operand(operand, Some(dest.layout))?;
181                let mode = if with_retag.yes() { RetagMode::Default } else { RetagMode::None };
182                M::with_retag_mode(self, mode, |ecx| ecx.copy_op(&op, &dest))?;
183            }
184
185            CopyForDeref(_) => ::rustc_middle::util::bug::bug_fmt(format_args!("`CopyForDeref` in runtime MIR"))bug!("`CopyForDeref` in runtime MIR"),
186
187            BinaryOp(bin_op, (ref left, ref right)) => {
188                let layout = util::binop_left_homogeneous(bin_op).then_some(dest.layout);
189                let left = self.read_immediate(&self.eval_operand(left, layout)?)?;
190                let layout = util::binop_right_homogeneous(bin_op).then_some(left.layout);
191                let right = self.read_immediate(&self.eval_operand(right, layout)?)?;
192                let result = self.binary_op(bin_op, &left, &right)?;
193                {
    match (&result.layout, &dest.layout) {
        (left_val, right_val) => {
            if !(*left_val == *right_val) {
                let kind = ::core::panicking::AssertKind::Eq;
                ::core::panicking::assert_failed(kind, &*left_val,
                    &*right_val,
                    ::core::option::Option::Some(format_args!("layout mismatch for result of {0:?}",
                            bin_op)));
            }
        }
    }
};assert_eq!(result.layout, dest.layout, "layout mismatch for result of {bin_op:?}");
194                self.write_immediate(*result, &dest)?;
195            }
196
197            UnaryOp(un_op, ref operand) => {
198                let layout = util::unop_homogeneous(un_op).then_some(dest.layout);
199                let val = self.read_immediate(&self.eval_operand(operand, layout)?)?;
200                let result = self.unary_op(un_op, &val)?;
201                {
    match (&result.layout, &dest.layout) {
        (left_val, right_val) => {
            if !(*left_val == *right_val) {
                let kind = ::core::panicking::AssertKind::Eq;
                ::core::panicking::assert_failed(kind, &*left_val,
                    &*right_val,
                    ::core::option::Option::Some(format_args!("layout mismatch for result of {0:?}",
                            un_op)));
            }
        }
    }
};assert_eq!(result.layout, dest.layout, "layout mismatch for result of {un_op:?}");
202                self.write_immediate(*result, &dest)?;
203            }
204
205            Aggregate(ref kind, ref operands) => {
206                self.write_aggregate(kind, operands, &dest)?;
207            }
208
209            Repeat(ref operand, _) => {
210                self.write_repeat(operand, &dest)?;
211            }
212
213            Ref(_, borrow_kind, place) => {
214                // `x = &*ptr` does not need a validity check on `ptr` because we will already
215                // check `x` below.
216                let src = self.eval_place(place, /* skip_validity_for_simple_deref */ true)?;
217                let place = self.force_allocation(&src)?;
218                let mut val = ImmTy::from_immediate(place.to_ref(self), dest.layout);
219                // A fresh reference was created, make sure it gets retagged with the right mode.
220                let mode = if borrow_kind.is_two_phase_borrow() {
221                    RetagMode::TwoPhase
222                } else {
223                    RetagMode::Default
224                };
225                M::with_retag_mode(self, mode, |ecx| {
226                    // If validation is disabled, we still want to do this retag. This is because
227                    // const-eval disables validation for performance reasons but wants to retag
228                    // shared references. So we add a bit of a hack here to do the retag manually
229                    // if the write would not incur validation.
230                    if !M::enforce_validity(ecx, val.layout) {
231                        if let Some(new_val) = M::retag_ptr_value(ecx, &val, val.layout.ty)? {
232                            val = new_val;
233                        }
234                    }
235                    // Now do the actual write.
236                    ecx.write_immediate(*val, &dest)
237                })?;
238            }
239
240            Reborrow(_, mutability, place) => {
241                let op = self.eval_place_to_op(place, None)?;
242                if mutability.is_not() {
243                    // Shared generic reborrows use `CoerceShared`: a bitwise copy into a
244                    // distinct same-layout target ADT.
245                    self.copy_op_allow_transmute(&op, &dest)?;
246                } else {
247                    self.copy_op(&op, &dest)?;
248                }
249            }
250
251            RawPtr(kind, place) => {
252                // Figure out whether this is an addr_of of an already raw place.
253                let place_base_raw = if place.is_indirect_first_projection() {
254                    let ty = self.frame().body.local_decls[place.local].ty;
255                    ty.is_raw_ptr()
256                } else {
257                    // Not a deref, and thus not raw.
258                    false
259                };
260
261                let src =
262                    self.eval_place(place, /* skip_validity_for_simple_deref */ false)?;
263                let place = self.force_allocation(&src)?;
264                let mut val = ImmTy::from_immediate(place.to_ref(self), dest.layout);
265                if !place_base_raw && !kind.is_fake() {
266                    // If this was not already raw, it needs retagging -- except for "fake"
267                    // raw borrows whose defining property is that they do not get retagged.
268                    val = M::with_retag_mode(self, RetagMode::Raw, |ecx| {
269                        interp_ok(M::retag_ptr_value(ecx, &val, val.layout.ty)?.unwrap_or(val))
270                    })?;
271                }
272                // This writes a raw pointer so it will not do any retags.
273                self.write_immediate(*val, &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        {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event compiler/rustc_const_eval/src/interpret/step.rs:298",
                        "rustc_const_eval::interpret::step",
                        ::tracing::Level::TRACE,
                        ::tracing_core::__macro_support::Option::Some("compiler/rustc_const_eval/src/interpret/step.rs"),
                        ::tracing_core::__macro_support::Option::Some(298u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_const_eval::interpret::step"),
                        ::tracing_core::field::FieldSet::new(&["message"],
                            ::tracing_core::callsite::Identifier(&__CALLSITE)),
                        ::tracing::metadata::Kind::EVENT)
                };
            ::tracing::callsite::DefaultCallsite::new(&META)
        };
    let enabled =
        ::tracing::Level::TRACE <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::TRACE <=
                    ::tracing::level_filters::LevelFilter::current() &&
            {
                let interest = __CALLSITE.interest();
                !interest.is_never() &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest)
            };
    if enabled {
        (|value_set: ::tracing::field::ValueSet|
                    {
                        let meta = __CALLSITE.metadata();
                        ::tracing::Event::dispatch(meta, &value_set);
                        ;
                    })({
                #[allow(unused_imports)]
                use ::tracing::field::{debug, display, Value};
                __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("{0:?}",
                                                    self.dump_place(&dest)) as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};trace!("{:?}", self.dump_place(&dest));
299
300        interp_ok(())
301    }
302
303    /// Writes the aggregate to the destination.
304    #[allow(clippy :: suspicious_else_formatting)]
{
    let __tracing_attr_span;
    let __tracing_attr_guard;
    if ::tracing::Level::TRACE <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::TRACE <=
                    ::tracing::level_filters::LevelFilter::current() ||
            { false } {
        __tracing_attr_span =
            {
                use ::tracing::__macro_support::Callsite as _;
                static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                    {
                        static META: ::tracing::Metadata<'static> =
                            {
                                ::tracing_core::metadata::Metadata::new("write_aggregate",
                                    "rustc_const_eval::interpret::step",
                                    ::tracing::Level::TRACE,
                                    ::tracing_core::__macro_support::Option::Some("compiler/rustc_const_eval/src/interpret/step.rs"),
                                    ::tracing_core::__macro_support::Option::Some(304u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_const_eval::interpret::step"),
                                    ::tracing_core::field::FieldSet::new(&[{
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("kind")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("kind");
                                                        NAME.as_str()
                                                    },
                                                    {
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("operands")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("operands");
                                                        NAME.as_str()
                                                    },
                                                    {
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("dest")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("dest");
                                                        NAME.as_str()
                                                    }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                    ::tracing::metadata::Kind::SPAN)
                            };
                        ::tracing::callsite::DefaultCallsite::new(&META)
                    };
                let mut interest = ::tracing::subscriber::Interest::never();
                if ::tracing::Level::TRACE <=
                                    ::tracing::level_filters::STATIC_MAX_LEVEL &&
                                ::tracing::Level::TRACE <=
                                    ::tracing::level_filters::LevelFilter::current() &&
                            { interest = __CALLSITE.interest(); !interest.is_never() }
                        &&
                        ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                            interest) {
                    let meta = __CALLSITE.metadata();
                    ::tracing::Span::new(meta,
                        &{
                                #[allow(unused_imports)]
                                use ::tracing::field::{debug, display, Value};
                                meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&kind)
                                                            as &dyn ::tracing::field::Value)),
                                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&operands)
                                                            as &dyn ::tracing::field::Value)),
                                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&dest)
                                                            as &dyn ::tracing::field::Value))])
                            })
                } else {
                    let span =
                        ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                    {};
                    span
                }
            };
        __tracing_attr_guard = __tracing_attr_span.enter();
    }

    #[warn(clippy :: suspicious_else_formatting)]
    {

        #[allow(unknown_lints, unreachable_code, clippy ::
        diverging_sub_expression, clippy :: empty_loop, clippy ::
        let_unit_value, clippy :: let_with_type_underscore, clippy ::
        needless_return, clippy :: unreachable)]
        if false {
            let __tracing_attr_fake_return: InterpResult<'tcx> = loop {};
            return __tracing_attr_fake_return;
        }
        {
            let (variant_index, variant_dest, active_field_index) =
                match *kind {
                    mir::AggregateKind::Adt(_, variant_index, _, _,
                        active_field_index) => {
                        let variant_dest =
                            self.project_downcast(dest, variant_index)?;
                        (variant_index, variant_dest, active_field_index)
                    }
                    mir::AggregateKind::RawPtr(..) => {
                        let [data, meta] =
                            &operands.raw else {
                                ::rustc_middle::util::bug::bug_fmt(format_args!("{0:?} should have 2 operands, had {1:?}",
                                        kind, operands));
                            };
                        let data = self.eval_operand(data, None)?;
                        let data = self.read_pointer(&data)?;
                        let meta = self.eval_operand(meta, None)?;
                        let meta =
                            if meta.layout.is_zst() {
                                MemPlaceMeta::None
                            } else { MemPlaceMeta::Meta(self.read_scalar(&meta)?) };
                        let ptr_imm =
                            Immediate::new_pointer_with_meta(data, meta, self);
                        let ptr = ImmTy::from_immediate(ptr_imm, dest.layout);
                        self.copy_op(&ptr, dest)?;
                        return interp_ok(());
                    }
                    _ => (FIRST_VARIANT, dest.clone(), None),
                };
            if active_field_index.is_some() {
                {
                    match (&operands.len(), &1) {
                        (left_val, right_val) => {
                            if !(*left_val == *right_val) {
                                let kind = ::core::panicking::AssertKind::Eq;
                                ::core::panicking::assert_failed(kind, &*left_val,
                                    &*right_val, ::core::option::Option::None);
                            }
                        }
                    }
                };
            }
            for (field_index, operand) in operands.iter_enumerated() {
                let field_index = active_field_index.unwrap_or(field_index);
                let field_dest =
                    self.project_field(&variant_dest, field_index)?;
                let op = self.eval_operand(operand, Some(field_dest.layout))?;
                self.copy_op_no_validate(&op, &field_dest, false)?;
            }
            self.write_discriminant(variant_index, dest)?;
            if M::enforce_validity(self, dest.layout()) {
                self.validate_place(dest,
                        M::enforce_validity_recursively(self, dest.layout()),
                        true)?;
            }
            interp_ok(())
        }
    }
}#[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        let (variant_index, variant_dest, active_field_index) = match *kind {
312            mir::AggregateKind::Adt(_, variant_index, _, _, active_field_index) => {
313                let variant_dest = self.project_downcast(dest, variant_index)?;
314                (variant_index, variant_dest, active_field_index)
315            }
316            mir::AggregateKind::RawPtr(..) => {
317                // Pointers don't have "fields" in the normal sense, so the
318                // projection-based code below would either fail in projection
319                // or in type mismatches. Instead, build an `Immediate` from
320                // the parts and write that to the destination.
321                let [data, meta] = &operands.raw else {
322                    bug!("{kind:?} should have 2 operands, had {operands:?}");
323                };
324                let data = self.eval_operand(data, None)?;
325                let data = self.read_pointer(&data)?;
326                let meta = self.eval_operand(meta, None)?;
327                let meta = if meta.layout.is_zst() {
328                    MemPlaceMeta::None
329                } else {
330                    MemPlaceMeta::Meta(self.read_scalar(&meta)?)
331                };
332                let ptr_imm = Immediate::new_pointer_with_meta(data, meta, self);
333                let ptr = ImmTy::from_immediate(ptr_imm, dest.layout);
334                self.copy_op(&ptr, dest)?;
335                return interp_ok(());
336            }
337            _ => (FIRST_VARIANT, dest.clone(), None),
338        };
339        if active_field_index.is_some() {
340            assert_eq!(operands.len(), 1);
341        }
342        for (field_index, operand) in operands.iter_enumerated() {
343            let field_index = active_field_index.unwrap_or(field_index);
344            let field_dest = self.project_field(&variant_dest, field_index)?;
345            let op = self.eval_operand(operand, Some(field_dest.layout))?;
346            // We validate manually below so we don't have to do it here.
347            self.copy_op_no_validate(&op, &field_dest, /*allow_transmute*/ false)?;
348        }
349        self.write_discriminant(variant_index, dest)?;
350        // Validate that the entire thing is valid, and reset padding that might be in between the
351        // fields.
352        if M::enforce_validity(self, dest.layout()) {
353            self.validate_place(
354                dest,
355                M::enforce_validity_recursively(self, dest.layout()),
356                /*reset_provenance_and_padding*/ true,
357            )?;
358        }
359        interp_ok(())
360    }
361
362    /// Repeats `operand` into the destination. `dest` must have array type, and that type
363    /// determines how often `operand` is repeated.
364    fn write_repeat(
365        &mut self,
366        operand: &mir::Operand<'tcx>,
367        dest: &PlaceTy<'tcx, M::Provenance>,
368    ) -> InterpResult<'tcx> {
369        let src = self.eval_operand(operand, None)?;
370        if !src.layout.is_sized() {
    ::core::panicking::panic("assertion failed: src.layout.is_sized()")
};assert!(src.layout.is_sized());
371        let dest = self.force_allocation(&dest)?;
372        let length = dest.len(self)?;
373
374        if length == 0 {
375            // Nothing to copy... but let's still make sure that `dest` as a place is valid.
376            self.get_place_alloc_mut(&dest)?;
377        } else {
378            // Write the src to the first element.
379            let first = self.project_index(&dest, 0)?;
380            self.copy_op(&src, &first)?;
381
382            // This is performance-sensitive code for big static/const arrays! So we
383            // avoid writing each operand individually and instead just make many copies
384            // of the first element.
385            let elem_size = first.layout.size;
386            let first_ptr = first.ptr();
387            let rest_ptr = first_ptr.wrapping_offset(elem_size, self);
388            // No alignment requirement since `copy_op` above already checked it.
389            self.mem_copy_repeatedly(
390                first_ptr,
391                rest_ptr,
392                elem_size,
393                length - 1,
394                /*nonoverlapping:*/ true,
395            )?;
396        }
397
398        interp_ok(())
399    }
400
401    /// Evaluate the arguments of a function call
402    fn eval_fn_call_argument(
403        &mut self,
404        op: &mir::Operand<'tcx>,
405        move_definitely_disjoint: bool,
406    ) -> InterpResult<'tcx, FnArg<'tcx, M::Provenance>> {
407        interp_ok(match op {
408            mir::Operand::Copy(_) | mir::Operand::Constant(_) | mir::Operand::RuntimeChecks(_) => {
409                // Make a regular copy.
410                let op = self.eval_operand(op, None)?;
411                FnArg::Copy(op)
412            }
413            mir::Operand::Move(place) => {
414                // We will read from this place, which checks everything there is to check,
415                // so we can skip the extra validity check here.
416                let place =
417                    self.eval_place(*place, /* skip_validity_for_simple_deref */ true)?;
418                if move_definitely_disjoint {
419                    // We still have to ensure that no *other* pointers are used to access this place,
420                    // so *if* it is in memory then we have to treat it as `InPlace`.
421                    // Use `place_to_op` to guarantee that we notice it being in memory.
422                    let op = self.place_to_op(&place)?;
423                    match op.as_mplace_or_imm() {
424                        Either::Left(mplace) => FnArg::InPlace(mplace),
425                        Either::Right(_imm) => FnArg::Copy(op),
426                    }
427                } else {
428                    // We have to force this into memory to detect aliasing among `Move` arguments.
429                    FnArg::InPlace(self.force_allocation(&place)?)
430                }
431            }
432        })
433    }
434
435    /// Shared part of `Call` and `TailCall` implementation — finding and evaluating all the
436    /// necessary information about callee and arguments to make a call.
437    fn eval_callee_and_args(
438        &mut self,
439        terminator: &mir::Terminator<'tcx>,
440        func: &mir::Operand<'tcx>,
441        args: &[Spanned<mir::Operand<'tcx>>],
442        dest: &mir::Place<'tcx>,
443    ) -> InterpResult<'tcx, EvaluatedCalleeAndArgs<'tcx, M>> {
444        let func = self.eval_operand(func, None)?;
445
446        // Evaluating function call arguments. The tricky part here is dealing with `Move`
447        // arguments: we have to ensure no two such arguments alias. This would be most easily done
448        // by just forcing them all into memory and then doing the usual in-place argument
449        // protection, but then we'd force *a lot* of arguments into memory. So we do some syntactic
450        // pre-processing here where if all `move` arguments are syntactically distinct local
451        // variables (and none is indirect), we can skip the in-memory forcing.
452        // We have to include `dest` in that list so that we can detect aliasing of an in-place
453        // argument with the return place.
454        let move_definitely_disjoint = 'move_definitely_disjoint: {
455            let mut previous_locals = FxHashSet::<mir::Local>::default();
456            for place in args
457                .iter()
458                .filter_map(|a| {
459                    // We only have to care about `Move` arguments.
460                    if let mir::Operand::Move(place) = &a.node { Some(place) } else { None }
461                })
462                .chain(iter::once(dest))
463            {
464                if place.is_indirect_first_projection() {
465                    // An indirect in-place argument could alias with anything else...
466                    break 'move_definitely_disjoint false;
467                }
468                if !previous_locals.insert(place.local) {
469                    // This local is the base for two arguments! They might overlap.
470                    break 'move_definitely_disjoint false;
471                }
472            }
473            // We found no violation so they are all definitely disjoint.
474            true
475        };
476        let args = args
477            .iter()
478            .map(|arg| self.eval_fn_call_argument(&arg.node, move_definitely_disjoint))
479            .collect::<InterpResult<'tcx, Vec<_>>>()?;
480
481        let fn_sig_binder = {
482            let _trace = <M as
        crate::interpret::Machine>::enter_trace_span(||
        {
            use ::tracing::__macro_support::Callsite as _;
            static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                {
                    static META: ::tracing::Metadata<'static> =
                        {
                            ::tracing_core::metadata::Metadata::new("fn_sig",
                                "rustc_const_eval::interpret::step", ::tracing::Level::INFO,
                                ::tracing_core::__macro_support::Option::Some("compiler/rustc_const_eval/src/interpret/step.rs"),
                                ::tracing_core::__macro_support::Option::Some(482u32),
                                ::tracing_core::__macro_support::Option::Some("rustc_const_eval::interpret::step"),
                                ::tracing_core::field::FieldSet::new(&[{
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("ty")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("ty");
                                                    NAME.as_str()
                                                }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                ::tracing::metadata::Kind::SPAN)
                        };
                    ::tracing::callsite::DefaultCallsite::new(&META)
                };
            let mut interest = ::tracing::subscriber::Interest::never();
            if ::tracing::Level::INFO <=
                                ::tracing::level_filters::STATIC_MAX_LEVEL &&
                            ::tracing::Level::INFO <=
                                ::tracing::level_filters::LevelFilter::current() &&
                        { interest = __CALLSITE.interest(); !interest.is_never() }
                    &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest) {
                let meta = __CALLSITE.metadata();
                ::tracing::Span::new(meta,
                    &{
                            #[allow(unused_imports)]
                            use ::tracing::field::{debug, display, Value};
                            meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&func.layout.ty.kind())
                                                        as &dyn ::tracing::field::Value))])
                        })
            } else {
                let span =
                    ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                {};
                span
            }
        })enter_trace_span!(M, "fn_sig", ty = ?func.layout.ty.kind());
483            func.layout.ty.fn_sig(*self.tcx)
484        };
485        let fn_sig = self.tcx.normalize_erasing_late_bound_regions(self.typing_env, fn_sig_binder);
486        let extra_args = &args[fn_sig.inputs().len()..];
487        let extra_args =
488            self.tcx.mk_type_list_from_iter(extra_args.iter().map(|arg| arg.layout().ty));
489
490        let (callee, fn_abi, with_caller_location) = match *func.layout.ty.kind() {
491            ty::FnPtr(..) => {
492                let fn_ptr = self.read_pointer(&func)?;
493                let fn_val = self.get_ptr_fn(fn_ptr)?;
494                (fn_val, self.fn_abi_of_fn_ptr(fn_sig_binder, extra_args)?, false)
495            }
496            ty::FnDef(def_id, args) => {
497                let instance = self.resolve(def_id, args.no_bound_vars().unwrap())?;
498                (
499                    FnVal::Instance(instance),
500                    self.fn_abi_of_instance_no_deduced_attrs(instance, extra_args)?,
501                    instance.def.requires_caller_location(*self.tcx),
502                )
503            }
504            _ => {
505                ::rustc_middle::util::bug::span_bug_fmt(terminator.source_info.span,
    format_args!("invalid callee of type {0}", func.layout.ty))span_bug!(terminator.source_info.span, "invalid callee of type {}", func.layout.ty)
506            }
507        };
508
509        interp_ok(EvaluatedCalleeAndArgs { callee, args, fn_sig, fn_abi, with_caller_location })
510    }
511
512    fn eval_terminator(&mut self, terminator: &mir::Terminator<'tcx>) -> InterpResult<'tcx> {
513        let _trace = <M as
        crate::interpret::Machine>::enter_trace_span(||
        {
            use ::tracing::__macro_support::Callsite as _;
            static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                {
                    static META: ::tracing::Metadata<'static> =
                        {
                            ::tracing_core::metadata::Metadata::new("step",
                                "rustc_const_eval::interpret::step", ::tracing::Level::INFO,
                                ::tracing_core::__macro_support::Option::Some("compiler/rustc_const_eval/src/interpret/step.rs"),
                                ::tracing_core::__macro_support::Option::Some(513u32),
                                ::tracing_core::__macro_support::Option::Some("rustc_const_eval::interpret::step"),
                                ::tracing_core::field::FieldSet::new(&[{
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("step")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("step");
                                                    NAME.as_str()
                                                },
                                                {
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("terminator")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("terminator");
                                                    NAME.as_str()
                                                },
                                                {
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("span")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("span");
                                                    NAME.as_str()
                                                },
                                                {
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("tracing_separate_thread")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("tracing_separate_thread");
                                                    NAME.as_str()
                                                }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                ::tracing::metadata::Kind::SPAN)
                        };
                    ::tracing::callsite::DefaultCallsite::new(&META)
                };
            let mut interest = ::tracing::subscriber::Interest::never();
            if ::tracing::Level::INFO <=
                                ::tracing::level_filters::STATIC_MAX_LEVEL &&
                            ::tracing::Level::INFO <=
                                ::tracing::level_filters::LevelFilter::current() &&
                        { interest = __CALLSITE.interest(); !interest.is_never() }
                    &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest) {
                let meta = __CALLSITE.metadata();
                ::tracing::Span::new(meta,
                    &{
                            #[allow(unused_imports)]
                            use ::tracing::field::{debug, display, Value};
                            meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::display(&"eval_terminator")
                                                        as &dyn ::tracing::field::Value)),
                                            (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&terminator.kind)
                                                        as &dyn ::tracing::field::Value)),
                                            (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&terminator.source_info.span)
                                                        as &dyn ::tracing::field::Value)),
                                            (::tracing::__macro_support::Option::Some(&Empty as
                                                        &dyn ::tracing::field::Value))])
                        })
            } else {
                let span =
                    ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                {};
                span
            }
        })enter_trace_span!(
514            M,
515            step::eval_terminator,
516            terminator = ?terminator.kind,
517            span = ?terminator.source_info.span,
518            tracing_separate_thread = Empty,
519        )
520        .or_if_tracing_disabled(|| {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event compiler/rustc_const_eval/src/interpret/step.rs:520",
                        "rustc_const_eval::interpret::step", ::tracing::Level::INFO,
                        ::tracing_core::__macro_support::Option::Some("compiler/rustc_const_eval/src/interpret/step.rs"),
                        ::tracing_core::__macro_support::Option::Some(520u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_const_eval::interpret::step"),
                        ::tracing_core::field::FieldSet::new(&["message"],
                            ::tracing_core::callsite::Identifier(&__CALLSITE)),
                        ::tracing::metadata::Kind::EVENT)
                };
            ::tracing::callsite::DefaultCallsite::new(&META)
        };
    let enabled =
        ::tracing::Level::INFO <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::INFO <=
                    ::tracing::level_filters::LevelFilter::current() &&
            {
                let interest = __CALLSITE.interest();
                !interest.is_never() &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest)
            };
    if enabled {
        (|value_set: ::tracing::field::ValueSet|
                    {
                        let meta = __CALLSITE.metadata();
                        ::tracing::Event::dispatch(meta, &value_set);
                        ;
                    })({
                #[allow(unused_imports)]
                use ::tracing::field::{debug, display, Value};
                __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("{0:?}",
                                                    terminator.kind) as &dyn ::tracing::field::Value))])
            });
    } else { ; }
}info!("{:?}", terminator.kind));
521
522        use rustc_middle::mir::TerminatorKind::*;
523        match terminator.kind {
524            Return => {
525                self.return_from_current_stack_frame(/* unwinding */ false)?
526            }
527
528            Goto { target } => self.go_to_block(target),
529
530            SwitchInt { ref discr, ref targets } => {
531                let discr = self.read_immediate(&self.eval_operand(discr, None)?)?;
532                {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event compiler/rustc_const_eval/src/interpret/step.rs:532",
                        "rustc_const_eval::interpret::step",
                        ::tracing::Level::TRACE,
                        ::tracing_core::__macro_support::Option::Some("compiler/rustc_const_eval/src/interpret/step.rs"),
                        ::tracing_core::__macro_support::Option::Some(532u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_const_eval::interpret::step"),
                        ::tracing_core::field::FieldSet::new(&["message"],
                            ::tracing_core::callsite::Identifier(&__CALLSITE)),
                        ::tracing::metadata::Kind::EVENT)
                };
            ::tracing::callsite::DefaultCallsite::new(&META)
        };
    let enabled =
        ::tracing::Level::TRACE <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::TRACE <=
                    ::tracing::level_filters::LevelFilter::current() &&
            {
                let interest = __CALLSITE.interest();
                !interest.is_never() &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest)
            };
    if enabled {
        (|value_set: ::tracing::field::ValueSet|
                    {
                        let meta = __CALLSITE.metadata();
                        ::tracing::Event::dispatch(meta, &value_set);
                        ;
                    })({
                #[allow(unused_imports)]
                use ::tracing::field::{debug, display, Value};
                __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("SwitchInt({0:?})",
                                                    *discr) as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};trace!("SwitchInt({:?})", *discr);
533
534                // Branch to the `otherwise` case by default, if no match is found.
535                let mut target_block = targets.otherwise();
536
537                for (const_int, target) in targets.iter() {
538                    // Compare using MIR BinOp::Eq, to also support pointer values.
539                    // (Avoiding `self.binary_op` as that does some redundant layout computation.)
540                    let res = self.binary_op(
541                        mir::BinOp::Eq,
542                        &discr,
543                        &ImmTy::from_uint(const_int, discr.layout),
544                    )?;
545                    if res.to_scalar().to_bool()? {
546                        target_block = target;
547                        break;
548                    }
549                }
550
551                self.go_to_block(target_block);
552            }
553
554            Call {
555                ref func,
556                ref args,
557                destination,
558                target,
559                unwind,
560                call_source: _,
561                fn_span: _,
562            } => {
563                let old_stack = self.frame_idx();
564                let old_loc = self.frame().loc;
565
566                // Evaluation order consistent with assignment: destination first.
567                let dest_place =
568                    self.eval_place(destination, /* skip_validity_for_simple_deref */ false)?;
569                let EvaluatedCalleeAndArgs { callee, args, fn_sig, fn_abi, with_caller_location } =
570                    self.eval_callee_and_args(terminator, func, args, &destination)?;
571
572                self.init_fn_call(
573                    callee,
574                    (fn_sig.abi(), fn_abi),
575                    &args,
576                    with_caller_location,
577                    &dest_place,
578                    target,
579                    if fn_abi.can_unwind { unwind } else { mir::UnwindAction::Unreachable },
580                )?;
581                // Sanity-check that `eval_fn_call` either pushed a new frame or
582                // did a jump to another block. We disable the sanity check for functions that
583                // can't return, since Miri sometimes does have to keep the location the same
584                // for those (which is fine since execution will continue on a different thread).
585                if target.is_some() && self.frame_idx() == old_stack && self.frame().loc == old_loc
586                {
587                    ::rustc_middle::util::bug::span_bug_fmt(terminator.source_info.span,
    format_args!("evaluating this call made no progress"));span_bug!(terminator.source_info.span, "evaluating this call made no progress");
588                }
589            }
590
591            TailCall { ref func, ref args, fn_span: _ } => {
592                let old_frame_idx = self.frame_idx();
593
594                let EvaluatedCalleeAndArgs { callee, args, fn_sig, fn_abi, with_caller_location } =
595                    self.eval_callee_and_args(terminator, func, args, &mir::Place::return_place())?;
596
597                self.init_fn_tail_call(
598                    callee,
599                    (fn_sig.abi(), fn_abi),
600                    &args,
601                    with_caller_location,
602                )?;
603
604                if self.frame_idx() != old_frame_idx {
605                    ::rustc_middle::util::bug::span_bug_fmt(terminator.source_info.span,
    format_args!("evaluating this tail call pushed a new stack frame"));span_bug!(
606                        terminator.source_info.span,
607                        "evaluating this tail call pushed a new stack frame"
608                    );
609                }
610            }
611
612            Drop { place, target, unwind, replace: _, drop } => {
613                if !drop.is_none() {
    {
        ::core::panicking::panic_fmt(format_args!("Async Drop must be expanded or reset to sync in runtime MIR"));
    }
};assert!(
614                    drop.is_none(),
615                    "Async Drop must be expanded or reset to sync in runtime MIR"
616                );
617                let place =
618                    self.eval_place(place, /* skip_validity_for_simple_deref */ false)?;
619                let instance = {
620                    let _trace =
621                        <M as
        crate::interpret::Machine>::enter_trace_span(||
        {
            use ::tracing::__macro_support::Callsite as _;
            static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                {
                    static META: ::tracing::Metadata<'static> =
                        {
                            ::tracing_core::metadata::Metadata::new("resolve",
                                "rustc_const_eval::interpret::step", ::tracing::Level::INFO,
                                ::tracing_core::__macro_support::Option::Some("compiler/rustc_const_eval/src/interpret/step.rs"),
                                ::tracing_core::__macro_support::Option::Some(621u32),
                                ::tracing_core::__macro_support::Option::Some("rustc_const_eval::interpret::step"),
                                ::tracing_core::field::FieldSet::new(&[{
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("resolve")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("resolve");
                                                    NAME.as_str()
                                                },
                                                {
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("ty")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("ty");
                                                    NAME.as_str()
                                                }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                ::tracing::metadata::Kind::SPAN)
                        };
                    ::tracing::callsite::DefaultCallsite::new(&META)
                };
            let mut interest = ::tracing::subscriber::Interest::never();
            if ::tracing::Level::INFO <=
                                ::tracing::level_filters::STATIC_MAX_LEVEL &&
                            ::tracing::Level::INFO <=
                                ::tracing::level_filters::LevelFilter::current() &&
                        { interest = __CALLSITE.interest(); !interest.is_never() }
                    &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest) {
                let meta = __CALLSITE.metadata();
                ::tracing::Span::new(meta,
                    &{
                            #[allow(unused_imports)]
                            use ::tracing::field::{debug, display, Value};
                            meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::display(&"resolve_drop_glue")
                                                        as &dyn ::tracing::field::Value)),
                                            (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&place.layout.ty)
                                                        as &dyn ::tracing::field::Value))])
                        })
            } else {
                let span =
                    ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                {};
                span
            }
        })enter_trace_span!(M, resolve::resolve_drop_glue, ty = ?place.layout.ty);
622                    Instance::resolve_drop_glue(*self.tcx, place.layout.ty)
623                };
624                if let ty::InstanceKind::Shim(ty::ShimKind::DropGlue(_, None)) = instance.def {
625                    // This is the branch we enter if and only if the dropped type has no drop glue
626                    // whatsoever. This can happen as a result of monomorphizing a drop of a
627                    // generic. In order to make sure that generic and non-generic code behaves
628                    // roughly the same (and in keeping with Mir semantics) we do nothing here.
629                    self.go_to_block(target);
630                    return interp_ok(());
631                }
632                {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event compiler/rustc_const_eval/src/interpret/step.rs:632",
                        "rustc_const_eval::interpret::step",
                        ::tracing::Level::TRACE,
                        ::tracing_core::__macro_support::Option::Some("compiler/rustc_const_eval/src/interpret/step.rs"),
                        ::tracing_core::__macro_support::Option::Some(632u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_const_eval::interpret::step"),
                        ::tracing_core::field::FieldSet::new(&["message"],
                            ::tracing_core::callsite::Identifier(&__CALLSITE)),
                        ::tracing::metadata::Kind::EVENT)
                };
            ::tracing::callsite::DefaultCallsite::new(&META)
        };
    let enabled =
        ::tracing::Level::TRACE <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::TRACE <=
                    ::tracing::level_filters::LevelFilter::current() &&
            {
                let interest = __CALLSITE.interest();
                !interest.is_never() &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest)
            };
    if enabled {
        (|value_set: ::tracing::field::ValueSet|
                    {
                        let meta = __CALLSITE.metadata();
                        ::tracing::Event::dispatch(meta, &value_set);
                        ;
                    })({
                #[allow(unused_imports)]
                use ::tracing::field::{debug, display, Value};
                __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("TerminatorKind::drop: {0:?}, type {1}",
                                                    place, place.layout.ty) as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};trace!("TerminatorKind::drop: {:?}, type {}", place, place.layout.ty);
633                self.init_drop_in_place_call(&place, instance, target, unwind)?;
634            }
635
636            Assert { ref cond, expected, ref msg, target, unwind } => {
637                let ignored =
638                    M::ignore_optional_overflow_checks(self) && msg.is_optional_overflow_check();
639                let cond_val = self.read_scalar(&self.eval_operand(cond, None)?)?.to_bool()?;
640                if ignored || expected == cond_val {
641                    self.go_to_block(target);
642                } else {
643                    M::assert_panic(self, msg, unwind)?;
644                }
645            }
646
647            UnwindTerminate(reason) => {
648                M::unwind_terminate(self, reason)?;
649            }
650
651            // When we encounter Resume, we've finished unwinding
652            // cleanup for the current stack frame. We pop it in order
653            // to continue unwinding the next frame
654            UnwindResume => {
655                {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event compiler/rustc_const_eval/src/interpret/step.rs:655",
                        "rustc_const_eval::interpret::step",
                        ::tracing::Level::TRACE,
                        ::tracing_core::__macro_support::Option::Some("compiler/rustc_const_eval/src/interpret/step.rs"),
                        ::tracing_core::__macro_support::Option::Some(655u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_const_eval::interpret::step"),
                        ::tracing_core::field::FieldSet::new(&["message"],
                            ::tracing_core::callsite::Identifier(&__CALLSITE)),
                        ::tracing::metadata::Kind::EVENT)
                };
            ::tracing::callsite::DefaultCallsite::new(&META)
        };
    let enabled =
        ::tracing::Level::TRACE <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::TRACE <=
                    ::tracing::level_filters::LevelFilter::current() &&
            {
                let interest = __CALLSITE.interest();
                !interest.is_never() &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest)
            };
    if enabled {
        (|value_set: ::tracing::field::ValueSet|
                    {
                        let meta = __CALLSITE.metadata();
                        ::tracing::Event::dispatch(meta, &value_set);
                        ;
                    })({
                #[allow(unused_imports)]
                use ::tracing::field::{debug, display, Value};
                __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("unwinding: resuming from cleanup")
                                            as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};trace!("unwinding: resuming from cleanup");
656                // By definition, a Resume terminator means
657                // that we're unwinding
658                self.return_from_current_stack_frame(/* unwinding */ true)?;
659                return interp_ok(());
660            }
661
662            // It is UB to ever encounter this.
663            Unreachable => do yeet ::rustc_middle::mir::interpret::InterpErrorKind::UndefinedBehavior(::rustc_middle::mir::interpret::UndefinedBehaviorInfo::Unreachable)throw_ub!(Unreachable),
664
665            // These should never occur for MIR we actually run.
666            FalseEdge { .. } | FalseUnwind { .. } | Yield { .. } | CoroutineDrop => ::rustc_middle::util::bug::span_bug_fmt(terminator.source_info.span,
    format_args!("{0:#?} should have been eliminated by MIR pass",
        terminator.kind))span_bug!(
667                terminator.source_info.span,
668                "{:#?} should have been eliminated by MIR pass",
669                terminator.kind
670            ),
671
672            InlineAsm { .. } => {
673                do yeet ::rustc_middle::mir::interpret::InterpErrorKind::Unsupported(::rustc_middle::mir::interpret::UnsupportedOpInfo::Unsupported(::alloc::__export::must_use({
                    ::alloc::fmt::format(format_args!("inline assembly is not supported"))
                })));throw_unsup_format!("inline assembly is not supported");
674            }
675        }
676
677        interp_ok(())
678    }
679}