@@ -1758,7 +1758,10 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
17581758 debug!("check_if_assigned_path_is_moved place: {:?}", place);
17591759
17601760 // 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+
17621765 match elem {
17631766 ProjectionElem::Index(_/*operand*/) |
17641767 ProjectionElem::ConstantIndex { .. } |
@@ -1771,8 +1774,6 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
17711774
17721775 // assigning to (*P) requires P to be initialized
17731776 ProjectionElem::Deref => {
1774- let proj_base = &place.projection[..i];
1775-
17761777 self.check_if_full_path_is_moved(
17771778 location, InitializationRequiringAction::Use,
17781779 (PlaceRef {
@@ -1790,7 +1791,6 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
17901791 }
17911792
17921793 ProjectionElem::Field(..) => {
1793- let proj_base = &place.projection[..i];
17941794 // if type of `P` has a dtor, then
17951795 // assigning to `P.f` requires `P` itself
17961796 // be already initialized
0 commit comments