Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 093bc99

Browse files
authoredOct 30, 2023
Unrolled build for rust-lang#117398
Rollup merge of rust-lang#117398 - Nadrieril:fix-117378, r=compiler-errors Correctly handle nested or-patterns in exhaustiveness I had assumed nested or-patterns were flattened, and they mostly are but not always. Fixes rust-lang#117378
2 parents 236ac91 + d5e836c commit 093bc99

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed
 

‎compiler/rustc_mir_build/src/thir/pattern/usefulness.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -931,7 +931,7 @@ impl<'p, 'tcx> PatternColumn<'p, 'tcx> {
931931
let specialized = pat.specialize(pcx, &ctor);
932932
for (subpat, column) in specialized.iter().zip(&mut specialized_columns) {
933933
if subpat.is_or_pat() {
934-
column.patterns.extend(subpat.iter_fields())
934+
column.patterns.extend(subpat.flatten_or_pat())
935935
} else {
936936
column.patterns.push(subpat)
937937
}

‎tests/ui/or-patterns/exhaustiveness-pass.rs

+6
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,10 @@ fn main() {
3535
((0, 0) | (1, 0),) => {}
3636
_ => {}
3737
}
38+
39+
// This one caused ICE https://github.com/rust-lang/rust/issues/117378
40+
match (0u8, 0) {
41+
(x @ 0 | x @ (1 | 2), _) => {}
42+
(3.., _) => {}
43+
}
3844
}

0 commit comments

Comments
 (0)
Please sign in to comment.