Skip to content

Commit

Permalink
interpret: call caller_location logic the same way codegen does, and …
Browse files Browse the repository at this point in the history
…share some code
  • Loading branch information
RalfJung committed Oct 28, 2023
1 parent a302610 commit bad4be6
Showing 1 changed file with 1 addition and 10 deletions.
11 changes: 1 addition & 10 deletions src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -433,16 +433,7 @@ impl<'tcx> FunctionCx<'_, '_, 'tcx> {
// Note: must be kept in sync with get_caller_location from cg_ssa
pub(crate) fn get_caller_location(&mut self, mut source_info: mir::SourceInfo) -> CValue<'tcx> {
let span_to_caller_location = |fx: &mut FunctionCx<'_, '_, 'tcx>, span: Span| {
use rustc_session::RemapFileNameExt;
let topmost = span.ctxt().outer_expn().expansion_cause().unwrap_or(span);
let caller = fx.tcx.sess.source_map().lookup_char_pos(topmost.lo());
let const_loc = fx.tcx.const_caller_location((
rustc_span::symbol::Symbol::intern(
&caller.file.name.for_codegen(&fx.tcx.sess).to_string_lossy(),
),
caller.line as u32,
caller.col_display as u32 + 1,
));
let const_loc = fx.tcx.span_as_caller_location(span);
crate::constant::codegen_const_value(fx, const_loc, fx.tcx.caller_location_ty())
};

Expand Down

0 comments on commit bad4be6

Please sign in to comment.