@@ -8,6 +8,7 @@ use rustc_middle::mir::visit::*;
8
8
use rustc_middle:: mir:: * ;
9
9
use rustc_middle:: ty:: subst:: Subst ;
10
10
use rustc_middle:: ty:: { self , ConstKind , Instance , InstanceDef , ParamEnv , Ty , TyCtxt } ;
11
+ use rustc_span:: { hygiene:: ExpnKind , ExpnData , Span } ;
11
12
use rustc_target:: spec:: abi:: Abi ;
12
13
13
14
use super :: simplify:: { remove_dead_blocks, CfgSimplifier } ;
@@ -488,6 +489,8 @@ impl Inliner<'tcx> {
488
489
cleanup_block : cleanup,
489
490
in_cleanup_block : false ,
490
491
tcx : self . tcx ,
492
+ callsite_span : callsite. source_info . span ,
493
+ body_span : callee_body. span ,
491
494
} ;
492
495
493
496
// Map all `Local`s, `SourceScope`s and `BasicBlock`s to new ones
@@ -699,6 +702,8 @@ struct Integrator<'a, 'tcx> {
699
702
cleanup_block : Option < BasicBlock > ,
700
703
in_cleanup_block : bool ,
701
704
tcx : TyCtxt < ' tcx > ,
705
+ callsite_span : Span ,
706
+ body_span : Span ,
702
707
}
703
708
704
709
impl < ' a , ' tcx > Integrator < ' a , ' tcx > {
@@ -743,6 +748,14 @@ impl<'a, 'tcx> MutVisitor<'tcx> for Integrator<'a, 'tcx> {
743
748
* scope = self . map_scope ( * scope) ;
744
749
}
745
750
751
+ fn visit_span ( & mut self , span : & mut Span ) {
752
+ // Make sure that all spans track the fact that they were inlined.
753
+ * span = self . callsite_span . fresh_expansion ( ExpnData {
754
+ def_site : self . body_span ,
755
+ ..ExpnData :: default ( ExpnKind :: Inlined , * span, self . tcx . sess . edition ( ) , None )
756
+ } ) ;
757
+ }
758
+
746
759
fn visit_place ( & mut self , place : & mut Place < ' tcx > , context : PlaceContext , location : Location ) {
747
760
// If this is the `RETURN_PLACE`, we need to rebase any projections onto it.
748
761
let dest_proj_len = self . destination . projection . len ( ) ;
0 commit comments