@@ -647,38 +647,45 @@ impl<'a, 'tcx> Integrator<'a, 'tcx> {
647
647
debug ! ( "updating target `{:?}`, new: `{:?}`" , tgt, new) ;
648
648
new
649
649
}
650
- }
651
650
652
- impl < ' a , ' tcx > MutVisitor < ' tcx > for Integrator < ' a , ' tcx > {
653
- fn visit_local ( & mut self ,
654
- local : & mut Local ,
655
- _ctxt : PlaceContext ,
656
- _location : Location ) {
651
+ fn make_integrate_local ( & self , local : & Local ) -> Local {
657
652
if * local == RETURN_PLACE {
658
653
match self . destination {
659
654
Place {
660
655
base : PlaceBase :: Local ( l) ,
661
656
projection : box [ ] ,
662
657
} => {
663
- * local = l;
664
- return ;
658
+ return l;
665
659
} ,
666
660
ref place => bug ! ( "Return place is {:?}, not local" , place)
667
661
}
668
662
}
663
+
669
664
let idx = local. index ( ) - 1 ;
670
665
if idx < self . args . len ( ) {
671
- * local = self . args [ idx] ;
672
- return ;
666
+ return self . args [ idx] ;
673
667
}
674
- * local = self . local_map [ Local :: new ( idx - self . args . len ( ) ) ] ;
668
+
669
+ self . local_map [ Local :: new ( idx - self . args . len ( ) ) ]
675
670
}
671
+ }
676
672
677
- fn visit_place ( & mut self ,
678
- place : & mut Place < ' tcx > ,
679
- _ctxt : PlaceContext ,
680
- _location : Location ) {
673
+ impl < ' a , ' tcx > MutVisitor < ' tcx > for Integrator < ' a , ' tcx > {
674
+ fn visit_local (
675
+ & mut self ,
676
+ local : & mut Local ,
677
+ _ctxt : PlaceContext ,
678
+ _location : Location ,
679
+ ) {
680
+ * local = self . make_integrate_local ( local) ;
681
+ }
681
682
683
+ fn visit_place (
684
+ & mut self ,
685
+ place : & mut Place < ' tcx > ,
686
+ context : PlaceContext ,
687
+ location : Location ,
688
+ ) {
682
689
match place {
683
690
Place {
684
691
base : PlaceBase :: Local ( RETURN_PLACE ) ,
@@ -687,7 +694,19 @@ impl<'a, 'tcx> MutVisitor<'tcx> for Integrator<'a, 'tcx> {
687
694
// Return pointer; update the place itself
688
695
* place = self . destination . clone ( ) ;
689
696
} ,
690
- _ => self . super_place ( place, _ctxt, _location)
697
+ _ => {
698
+ self . visit_place_base ( & mut place. base , context, location) ;
699
+
700
+ let new_projection: Vec < _ > = place. projection . iter ( ) . map ( |elem|
701
+ if let PlaceElem :: Index ( local) = elem {
702
+ PlaceElem :: Index ( self . make_integrate_local ( local) )
703
+ } else {
704
+ elem. clone ( )
705
+ }
706
+ ) . collect ( ) ;
707
+
708
+ place. projection = new_projection. into_boxed_slice ( ) ;
709
+ }
691
710
}
692
711
}
693
712
0 commit comments