Rollup merge of #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 https://github.com/rust-lang/rust/issues/117378
This commit is contained in:
commit
342483ccc6
@ -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)
|
||||
}
|
||||
|
@ -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.., _) => {}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user