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.
45use std::iter;
67use 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::source_map::Spanned;
14use rustc_target::callconv::FnAbi;
15use tracing::field::Empty;
16use tracing::{info, instrument, trace};
1718use super::{
19FnArg, FnVal, ImmTy, Immediate, InterpCx, InterpResult, Machine, MemPlaceMeta, PlaceTy,
20Projectable, interp_ok, throw_ub, throw_unsup_format,
21};
22use crate::interpret::EnteredTraceSpan;
23use crate::{enter_trace_span, util};
2425struct EvaluatedCalleeAndArgs<'tcx, M: Machine<'tcx>> {
26 callee: FnVal<'tcx, M::ExtraFnVal>,
27 args: Vec<FnArg<'tcx, M::Provenance>>,
28 fn_sig: ty::FnSig<'tcx>,
29 fn_abi: &'tcx FnAbi<'tcx, Ty<'tcx>>,
30/// True if the function is marked as `#[track_caller]` ([`ty::InstanceKind::requires_caller_location`])
31with_caller_location: bool,
32}
3334impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
35/// Returns `true` as long as there are more things to do.
36 ///
37 /// This is used by [priroda](https://github.com/oli-obk/priroda)
38 ///
39 /// This is marked `#inline(always)` to work around adversarial codegen when `opt-level = 3`
40#[inline(always)]
41pub fn step(&mut self) -> InterpResult<'tcx, bool> {
42if self.stack().is_empty() {
43return interp_ok(false);
44 }
4546let Either::Left(loc) = self.frame().loc else {
47// We are unwinding and this fn has no cleanup code.
48 // Just go on unwinding.
49{
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:49",
"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(49u32),
::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};
let mut iter = __CALLSITE.metadata().fields().iter();
__CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&format_args!("unwinding: skipping frame")
as &dyn Value))])
});
} else { ; }
};trace!("unwinding: skipping frame");
50self.return_from_current_stack_frame(/* unwinding */ true)?;
51return interp_ok(true);
52 };
53let basic_block = &self.body().basic_blocks[loc.block];
5455if let Some(stmt) = basic_block.statements.get(loc.statement_index) {
56let old_frames = self.frame_idx();
57self.eval_statement(stmt)?;
58// Make sure we are not updating `statement_index` of the wrong frame.
59match (&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());
60// Advance the program counter.
61self.frame_mut().loc.as_mut().left().unwrap().statement_index += 1;
62return interp_ok(true);
63 }
6465 M::before_terminator(self)?;
6667let terminator = basic_block.terminator();
68self.eval_terminator(terminator)?;
69if !self.stack().is_empty() {
70if let Either::Left(loc) = self.frame().loc {
71{
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:71",
"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(71u32),
::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};
let mut iter = __CALLSITE.metadata().fields().iter();
__CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&format_args!("// executing {0:?}",
loc.block) as &dyn Value))])
});
} else { ; }
};info!("// executing {:?}", loc.block);
72 }
73 }
74interp_ok(true)
75 }
7677/// Runs the interpretation logic for the given `mir::Statement` at the current frame and
78 /// statement counter.
79 ///
80 /// This does NOT move the statement counter forward, the caller has to do that!
81pub fn eval_statement(&mut self, stmt: &mir::Statement<'tcx>) -> InterpResult<'tcx> {
82let _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(82u32),
::tracing_core::__macro_support::Option::Some("rustc_const_eval::interpret::step"),
::tracing_core::field::FieldSet::new(&["step", "stmt",
"span", "tracing_separate_thread"],
::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};
let mut iter = meta.fields().iter();
meta.fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&display(&"eval_statement")
as &dyn Value)),
(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&debug(&stmt.kind)
as &dyn Value)),
(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&debug(&stmt.source_info.span)
as &dyn Value)),
(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&Empty as
&dyn Value))])
})
} else {
let span =
::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
{};
span
}
})enter_trace_span!(
83 M,
84 step::eval_statement,
85 stmt = ?stmt.kind,
86 span = ?stmt.source_info.span,
87 tracing_separate_thread = Empty,
88 )89 .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:89",
"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(89u32),
::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};
let mut iter = __CALLSITE.metadata().fields().iter();
__CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&format_args!("{0:?}",
stmt.kind) as &dyn Value))])
});
} else { ; }
}info!("{:?}", stmt.kind));
9091use rustc_middle::mir::StatementKind::*;
9293match &stmt.kind {
94Assign(box (place, rvalue)) => self.eval_rvalue_into_place(rvalue, *place)?,
9596SetDiscriminant { place, variant_index } => {
97let dest = self.eval_place(**place)?;
98self.write_discriminant(*variant_index, &dest)?;
99 }
100101// Mark locals as alive
102StorageLive(local) => {
103self.storage_live(*local)?;
104 }
105106// Mark locals as dead
107StorageDead(local) => {
108self.storage_dead(*local)?;
109 }
110111// No dynamic semantics attached to `FakeRead`; MIR
112 // interpreter is solely intended for borrowck'ed code.
113FakeRead(..) => {}
114115// Stacked Borrows.
116Retag(kind, place) => {
117let dest = self.eval_place(**place)?;
118 M::retag_place_contents(self, *kind, &dest)?;
119 }
120121Intrinsic(box intrinsic) => self.eval_nondiverging_intrinsic(intrinsic)?,
122123// Evaluate the place expression, without reading from it.
124PlaceMention(box place) => {
125let _ = self.eval_place(*place)?;
126 }
127128// This exists purely to guide borrowck lifetime inference, and does not have
129 // an operational effect.
130AscribeUserType(..) => {}
131132// Currently, Miri discards Coverage statements. Coverage statements are only injected
133 // via an optional compile time MIR pass and have no side effects. Since Coverage
134 // statements don't exist at the source level, it is safe for Miri to ignore them, even
135 // for undefined behavior (UB) checks.
136 //
137 // A coverage counter inside a const expression (for example, a counter injected in a
138 // const function) is discarded when the const is evaluated at compile time. Whether
139 // this should change, and/or how to implement a const eval counter, is a subject of the
140 // following issue:
141 //
142 // FIXME(#73156): Handle source code coverage in const eval
143Coverage(..) => {}
144145ConstEvalCounter => {
146 M::increment_const_eval_counter(self)?;
147 }
148149// Defined to do nothing. These are added by optimization passes, to avoid changing the
150 // size of MIR constantly.
151Nop => {}
152153// Only used for temporary lifetime lints
154BackwardIncompatibleDropHint { .. } => {}
155 }
156157interp_ok(())
158 }
159160/// Evaluate an assignment statement.
161 ///
162 /// There is no separate `eval_rvalue` function. Instead, the code for handling each rvalue
163 /// type writes its results directly into the memory specified by the place.
164pub fn eval_rvalue_into_place(
165&mut self,
166 rvalue: &mir::Rvalue<'tcx>,
167 place: mir::Place<'tcx>,
168 ) -> InterpResult<'tcx> {
169let dest = self.eval_place(place)?;
170// FIXME: ensure some kind of non-aliasing between LHS and RHS?
171 // Also see https://github.com/rust-lang/rust/issues/68364.
172173use rustc_middle::mir::Rvalue::*;
174match *rvalue {
175ThreadLocalRef(did) => {
176let ptr = M::thread_local_static_pointer(self, did)?;
177self.write_pointer(ptr, &dest)?;
178 }
179180Use(ref operand) => {
181// Avoid recomputing the layout
182let op = self.eval_operand(operand, Some(dest.layout))?;
183self.copy_op(&op, &dest)?;
184 }
185186CopyForDeref(_) => ::rustc_middle::util::bug::bug_fmt(format_args!("`CopyForDeref` in runtime MIR"))bug!("`CopyForDeref` in runtime MIR"),
187188BinaryOp(bin_op, box (ref left, ref right)) => {
189let layout = util::binop_left_homogeneous(bin_op).then_some(dest.layout);
190let left = self.read_immediate(&self.eval_operand(left, layout)?)?;
191let layout = util::binop_right_homogeneous(bin_op).then_some(left.layout);
192let right = self.read_immediate(&self.eval_operand(right, layout)?)?;
193let result = self.binary_op(bin_op, &left, &right)?;
194match (&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:?}");
195self.write_immediate(*result, &dest)?;
196 }
197198UnaryOp(un_op, ref operand) => {
199// The operand always has the same type as the result.
200let val = self.read_immediate(&self.eval_operand(operand, Some(dest.layout))?)?;
201let result = self.unary_op(un_op, &val)?;
202match (&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:?}");
203self.write_immediate(*result, &dest)?;
204 }
205206Aggregate(box ref kind, ref operands) => {
207self.write_aggregate(kind, operands, &dest)?;
208 }
209210Repeat(ref operand, _) => {
211self.write_repeat(operand, &dest)?;
212 }
213214Ref(_, borrow_kind, place) => {
215let src = self.eval_place(place)?;
216let place = self.force_allocation(&src)?;
217let val = ImmTy::from_immediate(place.to_ref(self), dest.layout);
218// A fresh reference was created, make sure it gets retagged.
219let val = M::retag_ptr_value(
220self,
221if borrow_kind.is_two_phase_borrow() {
222 mir::RetagKind::TwoPhase223 } else {
224 mir::RetagKind::Default225 },
226&val,
227 )?;
228self.write_immediate(*val, &dest)?;
229 }
230231RawPtr(kind, place) => {
232// Figure out whether this is an addr_of of an already raw place.
233let place_base_raw = if place.is_indirect_first_projection() {
234let ty = self.frame().body.local_decls[place.local].ty;
235ty.is_raw_ptr()
236 } else {
237// Not a deref, and thus not raw.
238false
239};
240241let src = self.eval_place(place)?;
242let place = self.force_allocation(&src)?;
243let mut val = ImmTy::from_immediate(place.to_ref(self), dest.layout);
244if !place_base_raw && !kind.is_fake() {
245// If this was not already raw, it needs retagging -- except for "fake"
246 // raw borrows whose defining property is that they do not get retagged.
247val = M::retag_ptr_value(self, mir::RetagKind::Raw, &val)?;
248 }
249self.write_immediate(*val, &dest)?;
250 }
251252Cast(cast_kind, ref operand, cast_ty) => {
253let src = self.eval_operand(operand, None)?;
254let cast_ty =
255self.instantiate_from_current_frame_and_normalize_erasing_regions(cast_ty)?;
256self.cast(&src, cast_kind, cast_ty, &dest)?;
257 }
258259Discriminant(place) => {
260let op = self.eval_place_to_op(place, None)?;
261let variant = self.read_discriminant(&op)?;
262let discr = self.discriminant_for_variant(op.layout.ty, variant)?;
263self.write_immediate(*discr, &dest)?;
264 }
265266WrapUnsafeBinder(ref op, _ty) => {
267// Constructing an unsafe binder acts like a transmute
268 // since the operand's layout does not change.
269let op = self.eval_operand(op, None)?;
270self.copy_op_allow_transmute(&op, &dest)?;
271 }
272 }
273274{
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:274",
"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(274u32),
::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};
let mut iter = __CALLSITE.metadata().fields().iter();
__CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&format_args!("{0:?}",
self.dump_place(&dest)) as &dyn Value))])
});
} else { ; }
};trace!("{:?}", self.dump_place(&dest));
275276interp_ok(())
277 }
278279/// Writes the aggregate to the destination.
280#[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(280u32),
::tracing_core::__macro_support::Option::Some("rustc_const_eval::interpret::step"),
::tracing_core::field::FieldSet::new(&["kind", "operands",
"dest"], ::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};
let mut iter = meta.fields().iter();
meta.fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&::tracing::field::debug(&kind)
as &dyn Value)),
(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&::tracing::field::debug(&operands)
as &dyn Value)),
(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&::tracing::field::debug(&dest)
as &dyn 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_operand(dest,
M::enforce_validity_recursively(self, dest.layout()),
true)?;
}
interp_ok(())
}
}
}#[instrument(skip(self), level = "trace")]281fn write_aggregate(
282&mut self,
283 kind: &mir::AggregateKind<'tcx>,
284 operands: &IndexSlice<FieldIdx, mir::Operand<'tcx>>,
285 dest: &PlaceTy<'tcx, M::Provenance>,
286 ) -> InterpResult<'tcx> {
287let (variant_index, variant_dest, active_field_index) = match *kind {
288 mir::AggregateKind::Adt(_, variant_index, _, _, active_field_index) => {
289let variant_dest = self.project_downcast(dest, variant_index)?;
290 (variant_index, variant_dest, active_field_index)
291 }
292 mir::AggregateKind::RawPtr(..) => {
293// Pointers don't have "fields" in the normal sense, so the
294 // projection-based code below would either fail in projection
295 // or in type mismatches. Instead, build an `Immediate` from
296 // the parts and write that to the destination.
297let [data, meta] = &operands.raw else {
298bug!("{kind:?} should have 2 operands, had {operands:?}");
299 };
300let data = self.eval_operand(data, None)?;
301let data = self.read_pointer(&data)?;
302let meta = self.eval_operand(meta, None)?;
303let meta = if meta.layout.is_zst() {
304 MemPlaceMeta::None
305 } else {
306 MemPlaceMeta::Meta(self.read_scalar(&meta)?)
307 };
308let ptr_imm = Immediate::new_pointer_with_meta(data, meta, self);
309let ptr = ImmTy::from_immediate(ptr_imm, dest.layout);
310self.copy_op(&ptr, dest)?;
311return interp_ok(());
312 }
313_ => (FIRST_VARIANT, dest.clone(), None),
314 };
315if active_field_index.is_some() {
316assert_eq!(operands.len(), 1);
317 }
318for (field_index, operand) in operands.iter_enumerated() {
319let field_index = active_field_index.unwrap_or(field_index);
320let field_dest = self.project_field(&variant_dest, field_index)?;
321let op = self.eval_operand(operand, Some(field_dest.layout))?;
322// We validate manually below so we don't have to do it here.
323self.copy_op_no_validate(&op, &field_dest, /*allow_transmute*/ false)?;
324 }
325self.write_discriminant(variant_index, dest)?;
326// Validate that the entire thing is valid, and reset padding that might be in between the
327 // fields.
328if M::enforce_validity(self, dest.layout()) {
329self.validate_operand(
330 dest,
331 M::enforce_validity_recursively(self, dest.layout()),
332/*reset_provenance_and_padding*/ true,
333 )?;
334 }
335 interp_ok(())
336 }
337338/// Repeats `operand` into the destination. `dest` must have array type, and that type
339 /// determines how often `operand` is repeated.
340fn write_repeat(
341&mut self,
342 operand: &mir::Operand<'tcx>,
343 dest: &PlaceTy<'tcx, M::Provenance>,
344 ) -> InterpResult<'tcx> {
345let src = self.eval_operand(operand, None)?;
346if !src.layout.is_sized() {
::core::panicking::panic("assertion failed: src.layout.is_sized()")
};assert!(src.layout.is_sized());
347let dest = self.force_allocation(&dest)?;
348let length = dest.len(self)?;
349350if length == 0 {
351// Nothing to copy... but let's still make sure that `dest` as a place is valid.
352self.get_place_alloc_mut(&dest)?;
353 } else {
354// Write the src to the first element.
355let first = self.project_index(&dest, 0)?;
356self.copy_op(&src, &first)?;
357358// This is performance-sensitive code for big static/const arrays! So we
359 // avoid writing each operand individually and instead just make many copies
360 // of the first element.
361let elem_size = first.layout.size;
362let first_ptr = first.ptr();
363let rest_ptr = first_ptr.wrapping_offset(elem_size, self);
364// No alignment requirement since `copy_op` above already checked it.
365self.mem_copy_repeatedly(
366first_ptr,
367rest_ptr,
368elem_size,
369length - 1,
370/*nonoverlapping:*/ true,
371 )?;
372 }
373374interp_ok(())
375 }
376377/// Evaluate the arguments of a function call
378fn eval_fn_call_argument(
379&mut self,
380 op: &mir::Operand<'tcx>,
381 move_definitely_disjoint: bool,
382 ) -> InterpResult<'tcx, FnArg<'tcx, M::Provenance>> {
383interp_ok(match op {
384 mir::Operand::Copy(_) | mir::Operand::Constant(_) | mir::Operand::RuntimeChecks(_) => {
385// Make a regular copy.
386let op = self.eval_operand(op, None)?;
387 FnArg::Copy(op)
388 }
389 mir::Operand::Move(place) => {
390let place = self.eval_place(*place)?;
391if move_definitely_disjoint {
392// We still have to ensure that no *other* pointers are used to access this place,
393 // so *if* it is in memory then we have to treat it as `InPlace`.
394 // Use `place_to_op` to guarantee that we notice it being in memory.
395let op = self.place_to_op(&place)?;
396match op.as_mplace_or_imm() {
397 Either::Left(mplace) => FnArg::InPlace(mplace),
398 Either::Right(_imm) => FnArg::Copy(op),
399 }
400 } else {
401// We have to force this into memory to detect aliasing among `Move` arguments.
402FnArg::InPlace(self.force_allocation(&place)?)
403 }
404 }
405 })
406 }
407408/// Shared part of `Call` and `TailCall` implementation — finding and evaluating all the
409 /// necessary information about callee and arguments to make a call.
410fn eval_callee_and_args(
411&mut self,
412 terminator: &mir::Terminator<'tcx>,
413 func: &mir::Operand<'tcx>,
414 args: &[Spanned<mir::Operand<'tcx>>],
415 dest: &mir::Place<'tcx>,
416 ) -> InterpResult<'tcx, EvaluatedCalleeAndArgs<'tcx, M>> {
417let func = self.eval_operand(func, None)?;
418419// Evaluating function call arguments. The tricky part here is dealing with `Move`
420 // arguments: we have to ensure no two such arguments alias. This would be most easily done
421 // by just forcing them all into memory and then doing the usual in-place argument
422 // protection, but then we'd force *a lot* of arguments into memory. So we do some syntactic
423 // pre-processing here where if all `move` arguments are syntactically distinct local
424 // variables (and none is indirect), we can skip the in-memory forcing.
425 // We have to include `dest` in that list so that we can detect aliasing of an in-place
426 // argument with the return place.
427let move_definitely_disjoint = 'move_definitely_disjoint: {
428let mut previous_locals = FxHashSet::<mir::Local>::default();
429for place in args
430 .iter()
431 .filter_map(|a| {
432// We only have to care about `Move` arguments.
433if let mir::Operand::Move(place) = &a.node { Some(place) } else { None }
434 })
435 .chain(iter::once(dest))
436 {
437if place.is_indirect_first_projection() {
438// An indirect in-place argument could alias with anything else...
439break 'move_definitely_disjoint false;
440 }
441if !previous_locals.insert(place.local) {
442// This local is the base for two arguments! They might overlap.
443break 'move_definitely_disjoint false;
444 }
445 }
446// We found no violation so they are all definitely disjoint.
447true
448};
449let args = args450 .iter()
451 .map(|arg| self.eval_fn_call_argument(&arg.node, move_definitely_disjoint))
452 .collect::<InterpResult<'tcx, Vec<_>>>()?;
453454let fn_sig_binder = {
455let _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(455u32),
::tracing_core::__macro_support::Option::Some("rustc_const_eval::interpret::step"),
::tracing_core::field::FieldSet::new(&["ty"],
::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};
let mut iter = meta.fields().iter();
meta.fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&debug(&func.layout.ty.kind())
as &dyn Value))])
})
} else {
let span =
::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
{};
span
}
})enter_trace_span!(M, "fn_sig", ty = ?func.layout.ty.kind());
456func.layout.ty.fn_sig(*self.tcx)
457 };
458let fn_sig = self.tcx.normalize_erasing_late_bound_regions(self.typing_env, fn_sig_binder);
459let extra_args = &args[fn_sig.inputs().len()..];
460let extra_args =
461self.tcx.mk_type_list_from_iter(extra_args.iter().map(|arg| arg.layout().ty));
462463let (callee, fn_abi, with_caller_location) = match *func.layout.ty.kind() {
464 ty::FnPtr(..) => {
465let fn_ptr = self.read_pointer(&func)?;
466let fn_val = self.get_ptr_fn(fn_ptr)?;
467 (fn_val, self.fn_abi_of_fn_ptr(fn_sig_binder, extra_args)?, false)
468 }
469 ty::FnDef(def_id, args) => {
470let instance = self.resolve(def_id, args)?;
471 (
472 FnVal::Instance(instance),
473self.fn_abi_of_instance_no_deduced_attrs(instance, extra_args)?,
474instance.def.requires_caller_location(*self.tcx),
475 )
476 }
477_ => {
478::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)479 }
480 };
481482interp_ok(EvaluatedCalleeAndArgs { callee, args, fn_sig, fn_abi, with_caller_location })
483 }
484485fn eval_terminator(&mut self, terminator: &mir::Terminator<'tcx>) -> InterpResult<'tcx> {
486let _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(486u32),
::tracing_core::__macro_support::Option::Some("rustc_const_eval::interpret::step"),
::tracing_core::field::FieldSet::new(&["step", "terminator",
"span", "tracing_separate_thread"],
::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};
let mut iter = meta.fields().iter();
meta.fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&display(&"eval_terminator")
as &dyn Value)),
(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&debug(&terminator.kind)
as &dyn Value)),
(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&debug(&terminator.source_info.span)
as &dyn Value)),
(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&Empty as
&dyn Value))])
})
} else {
let span =
::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
{};
span
}
})enter_trace_span!(
487 M,
488 step::eval_terminator,
489 terminator = ?terminator.kind,
490 span = ?terminator.source_info.span,
491 tracing_separate_thread = Empty,
492 )493 .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:493",
"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(493u32),
::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};
let mut iter = __CALLSITE.metadata().fields().iter();
__CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&format_args!("{0:?}",
terminator.kind) as &dyn Value))])
});
} else { ; }
}info!("{:?}", terminator.kind));
494495use rustc_middle::mir::TerminatorKind::*;
496match terminator.kind {
497Return => {
498self.return_from_current_stack_frame(/* unwinding */ false)?
499}
500501Goto { target } => self.go_to_block(target),
502503SwitchInt { ref discr, ref targets } => {
504let discr = self.read_immediate(&self.eval_operand(discr, None)?)?;
505{
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:505",
"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(505u32),
::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};
let mut iter = __CALLSITE.metadata().fields().iter();
__CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&format_args!("SwitchInt({0:?})",
*discr) as &dyn Value))])
});
} else { ; }
};trace!("SwitchInt({:?})", *discr);
506507// Branch to the `otherwise` case by default, if no match is found.
508let mut target_block = targets.otherwise();
509510for (const_int, target) in targets.iter() {
511// Compare using MIR BinOp::Eq, to also support pointer values.
512 // (Avoiding `self.binary_op` as that does some redundant layout computation.)
513let res = self.binary_op(
514 mir::BinOp::Eq,
515&discr,
516&ImmTy::from_uint(const_int, discr.layout),
517 )?;
518if res.to_scalar().to_bool()? {
519 target_block = target;
520break;
521 }
522 }
523524self.go_to_block(target_block);
525 }
526527Call {
528ref func,
529ref args,
530 destination,
531 target,
532 unwind,
533 call_source: _,
534 fn_span: _,
535 } => {
536let old_stack = self.frame_idx();
537let old_loc = self.frame().loc;
538539let EvaluatedCalleeAndArgs { callee, args, fn_sig, fn_abi, with_caller_location } =
540self.eval_callee_and_args(terminator, func, args, &destination)?;
541542let destination = self.eval_place(destination)?;
543self.init_fn_call(
544callee,
545 (fn_sig.abi, fn_abi),
546&args,
547with_caller_location,
548&destination,
549target,
550if fn_abi.can_unwind { unwind } else { mir::UnwindAction::Unreachable },
551 )?;
552// Sanity-check that `eval_fn_call` either pushed a new frame or
553 // did a jump to another block. We disable the sanity check for functions that
554 // can't return, since Miri sometimes does have to keep the location the same
555 // for those (which is fine since execution will continue on a different thread).
556if target.is_some() && self.frame_idx() == old_stack && self.frame().loc == old_loc557 {
558::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");
559 }
560 }
561562TailCall { ref func, ref args, fn_span: _ } => {
563let old_frame_idx = self.frame_idx();
564565let EvaluatedCalleeAndArgs { callee, args, fn_sig, fn_abi, with_caller_location } =
566self.eval_callee_and_args(terminator, func, args, &mir::Place::return_place())?;
567568self.init_fn_tail_call(callee, (fn_sig.abi, fn_abi), &args, with_caller_location)?;
569570if self.frame_idx() != old_frame_idx {
571::rustc_middle::util::bug::span_bug_fmt(terminator.source_info.span,
format_args!("evaluating this tail call pushed a new stack frame"));span_bug!(
572terminator.source_info.span,
573"evaluating this tail call pushed a new stack frame"
574);
575 }
576 }
577578Drop { place, target, unwind, replace: _, drop, async_fut } => {
579if !(async_fut.is_none() && drop.is_none()) {
{
::core::panicking::panic_fmt(format_args!("Async Drop must be expanded or reset to sync in runtime MIR"));
}
};assert!(
580 async_fut.is_none() && drop.is_none(),
581"Async Drop must be expanded or reset to sync in runtime MIR"
582);
583let place = self.eval_place(place)?;
584let instance = {
585let _trace =
586<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(586u32),
::tracing_core::__macro_support::Option::Some("rustc_const_eval::interpret::step"),
::tracing_core::field::FieldSet::new(&["resolve", "ty"],
::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};
let mut iter = meta.fields().iter();
meta.fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&display(&"resolve_drop_in_place")
as &dyn Value)),
(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&debug(&place.layout.ty)
as &dyn Value))])
})
} else {
let span =
::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
{};
span
}
})enter_trace_span!(M, resolve::resolve_drop_in_place, ty = ?place.layout.ty);
587Instance::resolve_drop_in_place(*self.tcx, place.layout.ty)
588 };
589if let ty::InstanceKind::DropGlue(_, None) = instance.def {
590// This is the branch we enter if and only if the dropped type has no drop glue
591 // whatsoever. This can happen as a result of monomorphizing a drop of a
592 // generic. In order to make sure that generic and non-generic code behaves
593 // roughly the same (and in keeping with Mir semantics) we do nothing here.
594self.go_to_block(target);
595return interp_ok(());
596 }
597{
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:597",
"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(597u32),
::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};
let mut iter = __CALLSITE.metadata().fields().iter();
__CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&format_args!("TerminatorKind::drop: {0:?}, type {1}",
place, place.layout.ty) as &dyn Value))])
});
} else { ; }
};trace!("TerminatorKind::drop: {:?}, type {}", place, place.layout.ty);
598self.init_drop_in_place_call(&place, instance, target, unwind)?;
599 }
600601Assert { ref cond, expected, ref msg, target, unwind } => {
602let ignored =
603 M::ignore_optional_overflow_checks(self) && msg.is_optional_overflow_check();
604let cond_val = self.read_scalar(&self.eval_operand(cond, None)?)?.to_bool()?;
605if ignored || expected == cond_val {
606self.go_to_block(target);
607 } else {
608 M::assert_panic(self, msg, unwind)?;
609 }
610 }
611612UnwindTerminate(reason) => {
613 M::unwind_terminate(self, reason)?;
614 }
615616// When we encounter Resume, we've finished unwinding
617 // cleanup for the current stack frame. We pop it in order
618 // to continue unwinding the next frame
619UnwindResume => {
620{
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:620",
"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(620u32),
::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};
let mut iter = __CALLSITE.metadata().fields().iter();
__CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&format_args!("unwinding: resuming from cleanup")
as &dyn Value))])
});
} else { ; }
};trace!("unwinding: resuming from cleanup");
621// By definition, a Resume terminator means
622 // that we're unwinding
623self.return_from_current_stack_frame(/* unwinding */ true)?;
624return interp_ok(());
625 }
626627// It is UB to ever encounter this.
628Unreachable => do yeet ::rustc_middle::mir::interpret::InterpErrorKind::UndefinedBehavior(::rustc_middle::mir::interpret::UndefinedBehaviorInfo::Unreachable)throw_ub!(Unreachable),
629630// These should never occur for MIR we actually run.
631FalseEdge { .. } | 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!(
632terminator.source_info.span,
633"{:#?} should have been eliminated by MIR pass",
634 terminator.kind
635 ),
636637InlineAsm { .. } => {
638do 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");
639 }
640 }
641642interp_ok(())
643 }
644}