@@ -430,38 +430,11 @@ impl<'tcx> FunctionCx<'_, '_, 'tcx> {
430
430
}
431
431
}
432
432
433
- // Note: must be kept in sync with get_caller_location from cg_ssa
434
- pub ( crate ) fn get_caller_location ( & mut self , mut source_info : mir:: SourceInfo ) -> CValue < ' tcx > {
435
- let span_to_caller_location = |fx : & mut FunctionCx < ' _ , ' _ , ' tcx > , span : Span | {
436
- let const_loc = fx. tcx . span_as_caller_location ( span) ;
437
- crate :: constant:: codegen_const_value ( fx, const_loc, fx. tcx . caller_location_ty ( ) )
438
- } ;
439
-
440
- // Walk up the `SourceScope`s, in case some of them are from MIR inlining.
441
- // If so, the starting `source_info.span` is in the innermost inlined
442
- // function, and will be replaced with outer callsite spans as long
443
- // as the inlined functions were `#[track_caller]`.
444
- loop {
445
- let scope_data = & self . mir . source_scopes [ source_info. scope ] ;
446
-
447
- if let Some ( ( callee, callsite_span) ) = scope_data. inlined {
448
- // Stop inside the most nested non-`#[track_caller]` function,
449
- // before ever reaching its caller (which is irrelevant).
450
- if !callee. def . requires_caller_location ( self . tcx ) {
451
- return span_to_caller_location ( self , source_info. span ) ;
452
- }
453
- source_info. span = callsite_span;
454
- }
455
-
456
- // Skip past all of the parents with `inlined: None`.
457
- match scope_data. inlined_parent_scope {
458
- Some ( parent) => source_info. scope = parent,
459
- None => break ,
460
- }
461
- }
462
-
463
- // No inlined `SourceScope`s, or all of them were `#[track_caller]`.
464
- self . caller_location . unwrap_or_else ( || span_to_caller_location ( self , source_info. span ) )
433
+ pub ( crate ) fn get_caller_location ( & mut self , source_info : mir:: SourceInfo ) -> CValue < ' tcx > {
434
+ self . mir . caller_location_span ( source_info, self . caller_location , self . tcx , |span| {
435
+ let const_loc = self . tcx . span_as_caller_location ( span) ;
436
+ crate :: constant:: codegen_const_value ( self , const_loc, self . tcx . caller_location_ty ( ) )
437
+ } )
465
438
}
466
439
467
440
pub ( crate ) fn anonymous_str ( & mut self , msg : & str ) -> Value {
0 commit comments