@@ -320,8 +320,6 @@ fn base_local_and_movability<'tcx>(
320
320
mir : & mir:: Body < ' tcx > ,
321
321
place : mir:: Place < ' tcx > ,
322
322
) -> ( mir:: Local , CannotMoveOut ) {
323
- use rustc_middle:: mir:: PlaceRef ;
324
-
325
323
// Dereference. You cannot move things out from a borrowed value.
326
324
let mut deref = false ;
327
325
// Accessing a field of an ADT that has `Drop`. Moving the field out will cause E0509.
@@ -330,17 +328,14 @@ fn base_local_and_movability<'tcx>(
330
328
// underlying type implements Copy
331
329
let mut slice = false ;
332
330
333
- let PlaceRef { local, mut projection } = place. as_ref ( ) ;
334
- while let [ base @ .., elem] = projection {
335
- projection = base;
331
+ for ( base, elem) in place. as_ref ( ) . iter_projections ( ) {
332
+ let base_ty = base. ty ( & mir. local_decls , cx. tcx ) . ty ;
336
333
deref |= matches ! ( elem, mir:: ProjectionElem :: Deref ) ;
337
- field |= matches ! ( elem, mir:: ProjectionElem :: Field ( ..) )
338
- && has_drop ( cx, mir:: Place :: ty_from ( local, projection, & mir. local_decls , cx. tcx ) . ty ) ;
339
- slice |= matches ! ( elem, mir:: ProjectionElem :: Index ( ..) )
340
- && !is_copy ( cx, mir:: Place :: ty_from ( local, projection, & mir. local_decls , cx. tcx ) . ty ) ;
334
+ field |= matches ! ( elem, mir:: ProjectionElem :: Field ( ..) ) && has_drop ( cx, base_ty) ;
335
+ slice |= matches ! ( elem, mir:: ProjectionElem :: Index ( ..) ) && !is_copy ( cx, base_ty) ;
341
336
}
342
337
343
- ( local, deref || field || slice)
338
+ ( place . local , deref || field || slice)
344
339
}
345
340
346
341
#[ derive( Default ) ]
0 commit comments