@@ -241,21 +241,22 @@ impl MovePathLookup {
241241 // unknown place, but will rather return the nearest available
242242 // parent.
243243 pub fn find ( & self , place : & Place < ' tcx > ) -> LookupResult {
244- match * place {
245- Place :: Base ( PlaceBase :: Local ( local) ) => LookupResult :: Exact ( self . locals [ local] ) ,
246- Place :: Base ( PlaceBase :: Static ( ..) ) => LookupResult :: Parent ( None ) ,
247- Place :: Projection ( ref proj) => {
248- match self . find ( & proj. base ) {
249- LookupResult :: Exact ( base_path) => {
250- match self . projections . get ( & ( base_path, proj. elem . lift ( ) ) ) {
251- Some ( & subpath) => LookupResult :: Exact ( subpath) ,
252- None => LookupResult :: Parent ( Some ( base_path) )
253- }
254- }
255- inexact => inexact
244+ place. iterate ( |place_base, place_projection| {
245+ let mut result = match place_base {
246+ PlaceBase :: Local ( local) => self . locals [ * local] ,
247+ PlaceBase :: Static ( ..) => return LookupResult :: Parent ( None ) ,
248+ } ;
249+
250+ for proj in place_projection {
251+ if let Some ( & subpath) = self . projections . get ( & ( result, proj. elem . lift ( ) ) ) {
252+ result = subpath;
253+ } else {
254+ return LookupResult :: Parent ( Some ( result) ) ;
256255 }
257256 }
258- }
257+
258+ LookupResult :: Exact ( result)
259+ } )
259260 }
260261
261262 pub fn find_local ( & self , local : Local ) -> MovePathIndex {
0 commit comments