@@ -647,38 +647,45 @@ impl<'a, 'tcx> Integrator<'a, 'tcx> {
647647 debug ! ( "updating target `{:?}`, new: `{:?}`" , tgt, new) ;
648648 new
649649 }
650- }
651650
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 {
657652 if * local == RETURN_PLACE {
658653 match self . destination {
659654 Place {
660655 base : PlaceBase :: Local ( l) ,
661656 projection : box [ ] ,
662657 } => {
663- * local = l;
664- return ;
658+ return l;
665659 } ,
666660 ref place => bug ! ( "Return place is {:?}, not local" , place)
667661 }
668662 }
663+
669664 let idx = local. index ( ) - 1 ;
670665 if idx < self . args . len ( ) {
671- * local = self . args [ idx] ;
672- return ;
666+ return self . args [ idx] ;
673667 }
674- * local = self . local_map [ Local :: new ( idx - self . args . len ( ) ) ] ;
668+
669+ self . local_map [ Local :: new ( idx - self . args . len ( ) ) ]
675670 }
671+ }
676672
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+ }
681682
683+ fn visit_place (
684+ & mut self ,
685+ place : & mut Place < ' tcx > ,
686+ context : PlaceContext ,
687+ location : Location ,
688+ ) {
682689 match place {
683690 Place {
684691 base : PlaceBase :: Local ( RETURN_PLACE ) ,
@@ -687,7 +694,19 @@ impl<'a, 'tcx> MutVisitor<'tcx> for Integrator<'a, 'tcx> {
687694 // Return pointer; update the place itself
688695 * place = self . destination . clone ( ) ;
689696 } ,
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+ }
691710 }
692711 }
693712
0 commit comments