Move everything into the loop

This commit is contained in:
Nadrieril 2024-02-16 04:22:32 +01:00
parent 0896a4963f
commit e561dbb0b6

View File

@ -1272,11 +1272,16 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
start_block: BasicBlock,
fake_borrows: &mut Option<FxIndexSet<Place<'tcx>>>,
) -> BasicBlock {
let mut next_prebinding = start_block;
for candidate in matched_candidates.iter_mut() {
assert!(candidate.otherwise_block.is_none());
assert!(candidate.pre_binding_block.is_none());
debug_assert!(
matched_candidates.iter().all(|c| c.subcandidates.is_empty()),
candidate.subcandidates.is_empty(),
"subcandidates should be empty in select_matched_candidates",
);
if let Some(fake_borrows) = fake_borrows {
// Insert a borrows of prefixes of places that are bound and are
// behind a dereference projection.
//
@ -1293,10 +1298,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
// y if { y == 1 && (x = &2) == () } => y,
// _ => 3,
// }
if let Some(fake_borrows) = fake_borrows {
for Binding { source, .. } in
matched_candidates.iter().flat_map(|candidate| &candidate.bindings)
{
for Binding { source, .. } in &candidate.bindings {
if let Some(i) =
source.projection.iter().rposition(|elem| elem == ProjectionElem::Deref)
{
@ -1310,10 +1312,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
}
}
let mut next_prebinding = start_block;
for candidate in matched_candidates.iter_mut() {
assert!(candidate.otherwise_block.is_none());
assert!(candidate.pre_binding_block.is_none());
candidate.pre_binding_block = Some(next_prebinding);
next_prebinding = self.cfg.start_new_block();
if candidate.has_guard {