@@ -1738,25 +1738,16 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
17381738 /// static variable, as we do not track those in the MoveData.
17391739 fn move_path_closest_to (
17401740 & mut self ,
1741- place : PlaceRef < ' cx , ' tcx > ,
1741+ place : PlaceRef < ' _ , ' tcx > ,
17421742 ) -> Result < ( PlaceRef < ' cx , ' tcx > , MovePathIndex ) , NoMovePathFound > {
1743- let mut last_prefix = place. base ;
1744-
1745- for prefix in self . prefixes ( place, PrefixSet :: All ) {
1746- if let Some ( mpi) = self . move_path_for_place ( prefix) {
1747- return Ok ( ( prefix, mpi) ) ;
1748- }
1749-
1750- last_prefix = prefix. base ;
1751- }
1752-
1753- match last_prefix {
1754- PlaceBase :: Local ( _) => panic ! ( "should have move path for every Local" ) ,
1755- PlaceBase :: Static ( _) => Err ( NoMovePathFound :: ReachedStatic ) ,
1743+ match self . move_data . rev_lookup . find ( place) {
1744+ LookupResult :: Parent ( Some ( mpi) )
1745+ | LookupResult :: Exact ( mpi) => Ok ( ( self . move_data . move_paths [ mpi] . place . as_ref ( ) , mpi) ) ,
1746+ LookupResult :: Parent ( None ) => Err ( NoMovePathFound :: ReachedStatic ) ,
17561747 }
17571748 }
17581749
1759- fn move_path_for_place ( & mut self , place : PlaceRef < ' cx , ' tcx > ) -> Option < MovePathIndex > {
1750+ fn move_path_for_place ( & mut self , place : PlaceRef < ' _ , ' tcx > ) -> Option < MovePathIndex > {
17601751 // If returns None, then there is no move path corresponding
17611752 // to a direct owner of `place` (which means there is nothing
17621753 // that borrowck tracks for its analysis).
0 commit comments