@@ -39,15 +39,15 @@ impl<'a, 'tcx> MoveDataBuilder<'a, 'tcx> {
3939 . iter_enumerated ( )
4040 . map ( |( i, l) | {
4141 if l. is_deref_temp ( ) {
42- MovePathIndex :: MAX
42+ None
4343 } else {
44- Self :: new_move_path (
44+ Some ( Self :: new_move_path (
4545 & mut move_paths,
4646 & mut path_map,
4747 & mut init_path_map,
4848 None ,
4949 Place :: from ( i) ,
50- )
50+ ) )
5151 }
5252 } )
5353 . collect ( ) ,
@@ -100,7 +100,9 @@ impl<'b, 'a, 'tcx> Gatherer<'b, 'a, 'tcx> {
100100 let data = & mut self . builder . data ;
101101
102102 debug ! ( "lookup({:?})" , place) ;
103- let mut base = data. rev_lookup . find_local ( place. local ) ;
103+ let Some ( mut base) = data. rev_lookup . find_local ( place. local ) else {
104+ return Err ( MoveError :: UntrackedLocal ) ;
105+ } ;
104106
105107 // The move path index of the first union that we find. Once this is
106108 // some we stop creating child move paths, since moves from unions
@@ -328,17 +330,17 @@ pub(super) fn gather_moves<'tcx>(
328330impl < ' a , ' tcx > MoveDataBuilder < ' a , ' tcx > {
329331 fn gather_args ( & mut self ) {
330332 for arg in self . body . args_iter ( ) {
331- let path = self . data . rev_lookup . find_local ( arg) ;
333+ if let Some ( path) = self . data . rev_lookup . find_local ( arg) {
334+ let init = self . data . inits . push ( Init {
335+ path,
336+ kind : InitKind :: Deep ,
337+ location : InitLocation :: Argument ( arg) ,
338+ } ) ;
332339
333- let init = self . data . inits . push ( Init {
334- path,
335- kind : InitKind :: Deep ,
336- location : InitLocation :: Argument ( arg) ,
337- } ) ;
338-
339- debug ! ( "gather_args: adding init {:?} of {:?} for argument {:?}" , init, path, arg) ;
340+ debug ! ( "gather_args: adding init {:?} of {:?} for argument {:?}" , init, path, arg) ;
340341
341- self . data . init_path_map [ path] . push ( init) ;
342+ self . data . init_path_map [ path] . push ( init) ;
343+ }
342344 }
343345 }
344346
@@ -546,9 +548,7 @@ impl<'b, 'a, 'tcx> Gatherer<'b, 'a, 'tcx> {
546548 self . record_move ( place, path) ;
547549 return ;
548550 }
549- Err ( MoveError :: IllegalMove { .. } ) => {
550- return ;
551- }
551+ Err ( MoveError :: IllegalMove { .. } | MoveError :: UntrackedLocal ) => return ,
552552 } ;
553553 let base_ty = base_place. ty ( self . builder . body , self . builder . tcx ) . ty ;
554554 let len: u64 = match base_ty. kind ( ) {
@@ -567,7 +567,7 @@ impl<'b, 'a, 'tcx> Gatherer<'b, 'a, 'tcx> {
567567 } else {
568568 match self . move_path_for ( place) {
569569 Ok ( path) | Err ( MoveError :: UnionMove { path } ) => self . record_move ( place, path) ,
570- Err ( MoveError :: IllegalMove { .. } ) => { }
570+ Err ( MoveError :: IllegalMove { .. } | MoveError :: UntrackedLocal ) => { }
571571 } ;
572572 }
573573 }
0 commit comments