use rustc_middle::ty::{
self, fold::BottomUpFolder, query::TyCtxtAt, subst::SubstsRef, Ty, TyCtxt, TypeFoldable,
};
-use rustc_span::source_map::DUMMY_SP;
+use rustc_span::{source_map::DUMMY_SP, Span};
use rustc_target::abi::{Align, HasDataLayout, LayoutOf, Size, TargetDataLayout};
use super::{
}
}
+ #[inline(always)]
+ pub(crate) fn set_span(&mut self, span: Span) {
+ self.tcx.span = span;
+ self.memory.tcx.span = span;
+ }
+
#[inline(always)]
pub fn force_ptr(
&self,
fn statement(&mut self, stmt: &mir::Statement<'tcx>) -> InterpResult<'tcx> {
info!("{:?}", stmt);
+ self.set_span(stmt.source_info.span);
use rustc_middle::mir::StatementKind::*;
// Some statements (e.g., box) push new stack frames.
// We have to record the stack frame number *before* executing the statement.
let frame_idx = self.cur_frame();
- self.tcx.span = stmt.source_info.span;
- self.memory.tcx.span = stmt.source_info.span;
match &stmt.kind {
Assign(box (place, rvalue)) => self.eval_rvalue_into_place(rvalue, *place)?,
fn terminator(&mut self, terminator: &mir::Terminator<'tcx>) -> InterpResult<'tcx> {
info!("{:?}", terminator.kind);
- self.tcx.span = terminator.source_info.span;
- self.memory.tcx.span = terminator.source_info.span;
+ self.set_span(terminator.source_info.span);
self.eval_terminator(terminator)?;
if !self.stack.is_empty() {
}
fn eval_constant(&mut self, c: &Constant<'tcx>, source_info: SourceInfo) -> Option<OpTy<'tcx>> {
- self.ecx.tcx.span = c.span;
-
// FIXME we need to revisit this for #67176
if c.needs_subst() {
return None;
match self.ecx.eval_const_to_op(c.literal, None) {
Ok(op) => Some(op),
Err(error) => {
+ // Make sure errors point at the constant.
+ self.ecx.set_span(c.span);
let err = error_to_const_error(&self.ecx, error);
if let Some(lint_root) = self.lint_root(source_info) {
let lint_only = match c.literal.val {
fn visit_statement(&mut self, statement: &mut Statement<'tcx>, location: Location) {
trace!("visit_statement: {:?}", statement);
let source_info = statement.source_info;
+ self.ecx.set_span(source_info.span);
self.source_info = Some(source_info);
if let StatementKind::Assign(box (place, ref mut rval)) = statement.kind {
let place_ty: Ty<'tcx> = place.ty(&self.local_decls, self.tcx).ty;
fn visit_terminator(&mut self, terminator: &mut Terminator<'tcx>, location: Location) {
let source_info = terminator.source_info;
+ self.ecx.set_span(source_info.span);
self.source_info = Some(source_info);
self.super_terminator(terminator, location);
match &mut terminator.kind {