Skip to content

Commit

Permalink
Correctly handle nested or-patterns in column-wise analyses
Browse files Browse the repository at this point in the history
  • Loading branch information
Nadrieril committed Oct 30, 2023
1 parent 9d6d5d4 commit d5e836c
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 d5e836c

Please sign in to comment.