Skip to content

Commit

Permalink
Unrolled build for rust-lang#117398
Browse files Browse the repository at this point in the history
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
  • Loading branch information
rust-timer authored Oct 30, 2023
2 parents 236ac91 + d5e836c commit 093bc99
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion compiler/rustc_mir_build/src/thir/pattern/usefulness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -931,7 +931,7 @@ impl<'p, 'tcx> PatternColumn<'p, 'tcx> {
let specialized = pat.specialize(pcx, &ctor);
for (subpat, column) in specialized.iter().zip(&mut specialized_columns) {
if subpat.is_or_pat() {
column.patterns.extend(subpat.iter_fields())
column.patterns.extend(subpat.flatten_or_pat())
} else {
column.patterns.push(subpat)
}
Expand Down
6 changes: 6 additions & 0 deletions tests/ui/or-patterns/exhaustiveness-pass.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,10 @@ fn main() {
((0, 0) | (1, 0),) => {}
_ => {}
}

// This one caused ICE https://github.com/rust-lang/rust/issues/117378
match (0u8, 0) {
(x @ 0 | x @ (1 | 2), _) => {}
(3.., _) => {}
}
}

0 comments on commit 093bc99

Please sign in to comment.