@@ -555,7 +555,8 @@ impl<'tcx> Inliner<'tcx> {
555
555
new_scopes : SourceScope :: new ( caller_body. source_scopes . len ( ) ) ..,
556
556
new_blocks : BasicBlock :: new ( caller_body. basic_blocks ( ) . len ( ) ) ..,
557
557
destination : dest,
558
- return_block : callsite. target ,
558
+ callsite_scope : caller_body. source_scopes [ callsite. source_info . scope ] . clone ( ) ,
559
+ callsite,
559
560
cleanup_block : cleanup,
560
561
in_cleanup_block : false ,
561
562
tcx : self . tcx ,
@@ -567,31 +568,6 @@ impl<'tcx> Inliner<'tcx> {
567
568
// (or existing ones, in a few special cases) in the caller.
568
569
integrator. visit_body ( & mut callee_body) ;
569
570
570
- for scope in & mut callee_body. source_scopes {
571
- // FIXME(eddyb) move this into a `fn visit_scope_data` in `Integrator`.
572
- if scope. parent_scope . is_none ( ) {
573
- let callsite_scope = & caller_body. source_scopes [ callsite. source_info . scope ] ;
574
-
575
- // Attach the outermost callee scope as a child of the callsite
576
- // scope, via the `parent_scope` and `inlined_parent_scope` chains.
577
- scope. parent_scope = Some ( callsite. source_info . scope ) ;
578
- assert_eq ! ( scope. inlined_parent_scope, None ) ;
579
- scope. inlined_parent_scope = if callsite_scope. inlined . is_some ( ) {
580
- Some ( callsite. source_info . scope )
581
- } else {
582
- callsite_scope. inlined_parent_scope
583
- } ;
584
-
585
- // Mark the outermost callee scope as an inlined one.
586
- assert_eq ! ( scope. inlined, None ) ;
587
- scope. inlined = Some ( ( callsite. callee , callsite. source_info . span ) ) ;
588
- } else if scope. inlined_parent_scope . is_none ( ) {
589
- // Make it easy to find the scope with `inlined` set above.
590
- scope. inlined_parent_scope =
591
- Some ( integrator. map_scope ( OUTERMOST_SOURCE_SCOPE ) ) ;
592
- }
593
- }
594
-
595
571
// If there are any locals without storage markers, give them storage only for the
596
572
// duration of the call.
597
573
for local in callee_body. vars_and_temps_iter ( ) {
@@ -787,7 +763,8 @@ struct Integrator<'a, 'tcx> {
787
763
new_scopes : RangeFrom < SourceScope > ,
788
764
new_blocks : RangeFrom < BasicBlock > ,
789
765
destination : Place < ' tcx > ,
790
- return_block : Option < BasicBlock > ,
766
+ callsite_scope : SourceScopeData < ' tcx > ,
767
+ callsite : & ' a CallSite < ' tcx > ,
791
768
cleanup_block : Option < BasicBlock > ,
792
769
in_cleanup_block : bool ,
793
770
tcx : TyCtxt < ' tcx > ,
@@ -833,6 +810,28 @@ impl<'tcx> MutVisitor<'tcx> for Integrator<'_, 'tcx> {
833
810
* local = self . map_local ( * local) ;
834
811
}
835
812
813
+ fn visit_source_scope_data ( & mut self , scope_data : & mut SourceScopeData < ' tcx > ) {
814
+ self . super_source_scope_data ( scope_data) ;
815
+ if scope_data. parent_scope . is_none ( ) {
816
+ // Attach the outermost callee scope as a child of the callsite
817
+ // scope, via the `parent_scope` and `inlined_parent_scope` chains.
818
+ scope_data. parent_scope = Some ( self . callsite . source_info . scope ) ;
819
+ assert_eq ! ( scope_data. inlined_parent_scope, None ) ;
820
+ scope_data. inlined_parent_scope = if self . callsite_scope . inlined . is_some ( ) {
821
+ Some ( self . callsite . source_info . scope )
822
+ } else {
823
+ self . callsite_scope . inlined_parent_scope
824
+ } ;
825
+
826
+ // Mark the outermost callee scope as an inlined one.
827
+ assert_eq ! ( scope_data. inlined, None ) ;
828
+ scope_data. inlined = Some ( ( self . callsite . callee , self . callsite . source_info . span ) ) ;
829
+ } else if scope_data. inlined_parent_scope . is_none ( ) {
830
+ // Make it easy to find the scope with `inlined` set above.
831
+ scope_data. inlined_parent_scope = Some ( self . map_scope ( OUTERMOST_SOURCE_SCOPE ) ) ;
832
+ }
833
+ }
834
+
836
835
fn visit_source_scope ( & mut self , scope : & mut SourceScope ) {
837
836
* scope = self . map_scope ( * scope) ;
838
837
}
@@ -939,7 +938,7 @@ impl<'tcx> MutVisitor<'tcx> for Integrator<'_, 'tcx> {
939
938
}
940
939
}
941
940
TerminatorKind :: Return => {
942
- terminator. kind = if let Some ( tgt) = self . return_block {
941
+ terminator. kind = if let Some ( tgt) = self . callsite . target {
943
942
TerminatorKind :: Goto { target : tgt }
944
943
} else {
945
944
TerminatorKind :: Unreachable
0 commit comments