@@ -1758,7 +1758,10 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
1758
1758
debug ! ( "check_if_assigned_path_is_moved place: {:?}" , place) ;
1759
1759
1760
1760
// None case => assigning to `x` does not require `x` be initialized.
1761
- for ( i, elem) in place. projection . iter ( ) . enumerate ( ) . rev ( ) {
1761
+ let mut cursor = & * place. projection ;
1762
+ while let [ proj_base @ .., elem] = cursor {
1763
+ cursor = proj_base;
1764
+
1762
1765
match elem {
1763
1766
ProjectionElem :: Index ( _/*operand*/ ) |
1764
1767
ProjectionElem :: ConstantIndex { .. } |
@@ -1771,8 +1774,6 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
1771
1774
1772
1775
// assigning to (*P) requires P to be initialized
1773
1776
ProjectionElem :: Deref => {
1774
- let proj_base = & place. projection [ ..i] ;
1775
-
1776
1777
self . check_if_full_path_is_moved (
1777
1778
location, InitializationRequiringAction :: Use ,
1778
1779
( PlaceRef {
@@ -1790,7 +1791,6 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
1790
1791
}
1791
1792
1792
1793
ProjectionElem :: Field ( ..) => {
1793
- let proj_base = & place. projection [ ..i] ;
1794
1794
// if type of `P` has a dtor, then
1795
1795
// assigning to `P.f` requires `P` itself
1796
1796
// be already initialized
0 commit comments