@@ -8,6 +8,7 @@ use rustc_middle::mir::visit::*;
88use rustc_middle:: mir:: * ;
99use rustc_middle:: ty:: subst:: Subst ;
1010use rustc_middle:: ty:: { self , ConstKind , Instance , InstanceDef , ParamEnv , Ty , TyCtxt } ;
11+ use rustc_span:: { hygiene:: ExpnKind , ExpnData , Span } ;
1112use rustc_target:: spec:: abi:: Abi ;
1213
1314use super :: simplify:: { remove_dead_blocks, CfgSimplifier } ;
@@ -488,6 +489,8 @@ impl Inliner<'tcx> {
488489 cleanup_block : cleanup,
489490 in_cleanup_block : false ,
490491 tcx : self . tcx ,
492+ callsite_span : callsite. source_info . span ,
493+ body_span : callee_body. span ,
491494 } ;
492495
493496 // Map all `Local`s, `SourceScope`s and `BasicBlock`s to new ones
@@ -699,6 +702,8 @@ struct Integrator<'a, 'tcx> {
699702 cleanup_block : Option < BasicBlock > ,
700703 in_cleanup_block : bool ,
701704 tcx : TyCtxt < ' tcx > ,
705+ callsite_span : Span ,
706+ body_span : Span ,
702707}
703708
704709impl < ' a , ' tcx > Integrator < ' a , ' tcx > {
@@ -743,6 +748,14 @@ impl<'a, 'tcx> MutVisitor<'tcx> for Integrator<'a, 'tcx> {
743748 * scope = self . map_scope ( * scope) ;
744749 }
745750
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+
746759 fn visit_place ( & mut self , place : & mut Place < ' tcx > , context : PlaceContext , location : Location ) {
747760 // If this is the `RETURN_PLACE`, we need to rebase any projections onto it.
748761 let dest_proj_len = self . destination . projection . len ( ) ;
0 commit comments