Skip to content

Commit a500b28

Browse files
committed
Improve test_remaining_match_pairs_after_or
1 parent 55bde67 commit a500b28

File tree

1 file changed

+9
-0
lines changed
  • compiler/rustc_mir_build/src/build/matches

1 file changed

+9
-0
lines changed

compiler/rustc_mir_build/src/build/matches/mod.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1808,9 +1808,18 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
18081808
candidate.visit_leaves(|leaf_candidate| {
18091809
last_otherwise = leaf_candidate.otherwise_block;
18101810
});
1811+
18111812
let remaining_match_pairs = mem::take(&mut candidate.match_pairs);
1813+
debug_assert!(
1814+
remaining_match_pairs
1815+
.iter()
1816+
.all(|match_pair| matches!(match_pair.test_case, TestCase::Or { .. }))
1817+
);
1818+
18121819
candidate.visit_leaves(|leaf_candidate| {
18131820
assert!(leaf_candidate.match_pairs.is_empty());
1821+
// The remaining match pairs are all `Or`, so we can append them
1822+
// without having to re-sort or-patterns to the end.
18141823
leaf_candidate.match_pairs.extend(remaining_match_pairs.iter().cloned());
18151824
let or_start = leaf_candidate.pre_binding_block.unwrap();
18161825
let otherwise =

0 commit comments

Comments
 (0)