Shrink a loop to its looping part and move out the part that runs after the loop
This commit is contained in:
parent
626fd4b258
commit
f014e91a38
@ -144,13 +144,16 @@ impl<'tcx> MirPass<'tcx> for ByMoveBody {
|
||||
.skip(num_args)
|
||||
.enumerate()
|
||||
{
|
||||
let (mut parent_field_idx, mut parent_capture);
|
||||
loop {
|
||||
let &(parent_field_idx, parent_capture) =
|
||||
parent_captures.peek().expect("we ran out of parent captures!");
|
||||
(parent_field_idx, parent_capture) =
|
||||
*parent_captures.peek().expect("we ran out of parent captures!");
|
||||
// A parent matches a child they share the same prefix of projections.
|
||||
// The child may have more, if it is capturing sub-fields out of
|
||||
// something that is captured by-move in the parent closure.
|
||||
if !child_prefix_matches_parent_projections(parent_capture, child_capture) {
|
||||
if child_prefix_matches_parent_projections(parent_capture, child_capture) {
|
||||
break;
|
||||
}
|
||||
// Make sure the field was used at least once.
|
||||
assert!(
|
||||
field_used_at_least_once,
|
||||
@ -159,7 +162,6 @@ impl<'tcx> MirPass<'tcx> for ByMoveBody {
|
||||
field_used_at_least_once = false;
|
||||
// Skip this field.
|
||||
let _ = parent_captures.next().unwrap();
|
||||
continue;
|
||||
}
|
||||
|
||||
// Store this set of additional projections (fields and derefs).
|
||||
@ -203,8 +205,6 @@ impl<'tcx> MirPass<'tcx> for ByMoveBody {
|
||||
);
|
||||
|
||||
field_used_at_least_once = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Pop the last parent capture
|
||||
|
Loading…
x
Reference in New Issue
Block a user