Skip to content

Commit bad4be6

Browse files
committed
interpret: call caller_location logic the same way codegen does, and share some code
1 parent a302610 commit bad4be6

File tree

1 file changed

+1
-10
lines changed

1 file changed

+1
-10
lines changed

src/common.rs

+1-10
Original file line numberDiff line numberDiff line change
@@ -433,16 +433,7 @@ impl<'tcx> FunctionCx<'_, '_, 'tcx> {
433433
// Note: must be kept in sync with get_caller_location from cg_ssa
434434
pub(crate) fn get_caller_location(&mut self, mut source_info: mir::SourceInfo) -> CValue<'tcx> {
435435
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);
446437
crate::constant::codegen_const_value(fx, const_loc, fx.tcx.caller_location_ty())
447438
};
448439

0 commit comments

Comments
 (0)