better span for functions whose frame we push 'manually'
This commit is contained in:
parent
4cf83433b1
commit
b2cddd27bd
3 changed files with 8 additions and 9 deletions
|
|
@ -221,12 +221,7 @@ pub fn eval_main<'tcx>(tcx: TyCtxt<'tcx>, main_id: DefId, config: MiriConfig) ->
|
|||
};
|
||||
e.print_backtrace();
|
||||
if let Some(frame) = ecx.stack().last() {
|
||||
let block = &frame.body.basic_blocks()[frame.block.unwrap()];
|
||||
let span = if frame.stmt < block.statements.len() {
|
||||
block.statements[frame.stmt].source_info.span
|
||||
} else {
|
||||
block.terminator().source_info.span
|
||||
};
|
||||
let span = frame.current_source_info().unwrap().span;
|
||||
|
||||
let msg = format!("Miri evaluation error: {}", msg);
|
||||
let mut err = ecx.tcx.sess.struct_span_err(span, msg.as_str());
|
||||
|
|
|
|||
|
|
@ -132,9 +132,13 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
|
|||
|
||||
// Push frame.
|
||||
let mir = this.load_mir(f.def, None)?;
|
||||
let span = this.stack().last()
|
||||
.and_then(Frame::current_source_info)
|
||||
.map(|si| si.span)
|
||||
.unwrap_or(DUMMY_SP);
|
||||
this.push_stack_frame(
|
||||
f,
|
||||
DUMMY_SP, // There is no call site.
|
||||
span,
|
||||
mir,
|
||||
dest,
|
||||
stack_pop,
|
||||
|
|
|
|||
|
|
@ -166,7 +166,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
|
|||
// Forward to `panic_bounds_check` lang item.
|
||||
|
||||
// First arg: Caller location.
|
||||
let location = this.alloc_caller_location_for_span(span)?;
|
||||
let location = this.alloc_caller_location_for_span(span);
|
||||
// Second arg: index.
|
||||
let index = this.read_scalar(this.eval_operand(index, None)?)?;
|
||||
// Third arg: len.
|
||||
|
|
@ -190,7 +190,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
|
|||
let msg = this.allocate_str(msg, MiriMemoryKind::Static.into());
|
||||
|
||||
// Second arg: Caller location.
|
||||
let location = this.alloc_caller_location_for_span(span)?;
|
||||
let location = this.alloc_caller_location_for_span(span);
|
||||
|
||||
// Call the lang item.
|
||||
let panic = this.tcx.lang_items().panic_fn().unwrap();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue