diff options
| author | Nadrieril <nadrieril+git@gmail.com> | 2024-01-21 23:36:33 +0100 |
|---|---|---|
| committer | Nadrieril <nadrieril+git@gmail.com> | 2024-01-25 02:56:02 +0100 |
| commit | 09d4613f20a6052bb8af7119b90cf64e288deda0 (patch) | |
| tree | 7fe50bc278c43af16e09347db3cd8172d2e67019 /compiler | |
| parent | e9028789084b2d9ebb6fbadf54527daf78598510 (diff) | |
| download | rust-09d4613f20a6052bb8af7119b90cf64e288deda0.tar.gz rust-09d4613f20a6052bb8af7119b90cf64e288deda0.zip | |
Put new bindings first in refutable cases too
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/rustc_mir_build/src/build/matches/simplify.rs | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/compiler/rustc_mir_build/src/build/matches/simplify.rs b/compiler/rustc_mir_build/src/build/matches/simplify.rs index 8563c2d6dfb..9fab61803e8 100644 --- a/compiler/rustc_mir_build/src/build/matches/simplify.rs +++ b/compiler/rustc_mir_build/src/build/matches/simplify.rs @@ -87,7 +87,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { // let z = (x as Variant).copy_field; // // and raises an error // } - let mut original_bindings = mem::take(&mut candidate.bindings); + let original_bindings = mem::take(&mut candidate.bindings); let mut new_bindings = Vec::new(); // Repeatedly simplify match pairs until fixed point is reached loop { @@ -115,9 +115,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { } // Restore original bindings and append the new ones. - // This does: candidate.bindings = original_bindings ++ new_bindings - mem::swap(&mut candidate.bindings, &mut original_bindings); - candidate.bindings.extend_from_slice(&new_bindings); + // This does: candidate.bindings = new_bindings ++ original_bindings + mem::swap(&mut candidate.bindings, &mut new_bindings); + candidate.bindings.extend_from_slice(&original_bindings); let did_expand_or = if let [MatchPair { pattern: Pat { kind: PatKind::Or { pats }, .. }, place }] = |
