better span for functions whose frame we push 'manually'

This commit is contained in:
Ralf Jung
2019-11-29 11:52:53 +01:00
parent 4cf83433b1
commit b2cddd27bd
3 changed files with 8 additions and 9 deletions
+1 -6
View File
@@ -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());
+5 -1
View File
@@ -132,9 +132,13 @@ fn call_function(
// 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,
+2 -2
View File
@@ -166,7 +166,7 @@ fn assert_panic(
// 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 @@ fn assert_panic(
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();