interpret: call caller_location logic the same way codegen does, and … · rust-lang/rust@bad4be6 (original) (raw)

Original file line number Diff line number Diff line change
@@ -433,16 +433,7 @@ impl<'tcx> FunctionCx<'_, '_, 'tcx> {
433 433 // Note: must be kept in sync with get_caller_location from cg_ssa
434 434 pub(crate) fn get_caller_location(&mut self, mut source_info: mir::SourceInfo) -> CValue<'tcx> {
435 435 let span_to_caller_location = |fx: &mut FunctionCx<'_, '_, 'tcx>, span: Span
436 -use rustc_session::RemapFileNameExt;
437 -let topmost = span.ctxt().outer_expn().expansion_cause().unwrap_or(span);
438 -let caller = fx.tcx.sess.source_map().lookup_char_pos(topmost.lo());
439 -let const_loc = fx.tcx.const_caller_location((
440 - rustc_span::symbol::Symbol::intern(
441 -&caller.file.name.for_codegen(&fx.tcx.sess).to_string_lossy(),
442 -),
443 - caller.line as u32,
444 - caller.col_display as u32 + 1,
445 -));
436 +let const_loc = fx.tcx.span_as_caller_location(span);
446 437 crate::constant::codegen_const_value(fx, const_loc, fx.tcx.caller_location_ty())
447 438 };
448 439