@@ -1738,25 +1738,16 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
1738
1738
/// static variable, as we do not track those in the MoveData.
1739
1739
fn move_path_closest_to (
1740
1740
& mut self ,
1741
- place : PlaceRef < ' cx , ' tcx > ,
1741
+ place : PlaceRef < ' _ , ' tcx > ,
1742
1742
) -> 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 ) ,
1756
1747
}
1757
1748
}
1758
1749
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 > {
1760
1751
// If returns None, then there is no move path corresponding
1761
1752
// to a direct owner of `place` (which means there is nothing
1762
1753
// that borrowck tracks for its analysis).
0 commit comments