-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ICE "Or-pattern should have been expanded earlier on" #69875
Comments
Another variation on this to include in a regression test: #![feature(or_patterns)]
fn main() {
if let x @ 0 | x @ (1 | 2) = 0 {}
} |
Ah yeah, I see the issue. There's an implicit invariant that there should be no or-patterns directly in the first column of the matrix, but this invariant is broken exactly when an or-pattern has a child that is itself an or-pattern. I should have documented that. rust/src/librustc_mir_build/hair/pattern/_match.rs Lines 480 to 487 in dd155df
I don't expect to have the bandwidth to work on rustc in the foreseeable future sadly. I anyone wants to try, I believe the fix could be as simple as replacing in the above function self.0.extend(rows) with a loop that calls self.push (and not self.0.push ). That will ensure that we recursively expand or-patterns as needed instead of just expanding the first one.
|
@Nadrieril Yep, that did it. Thanks for the pointer. This issue is fixed by #69891. |
Exhaustiveness checking, `Matrix::push`: recursively expand or-patterns > There's an implicit invariant that there should be no or-patterns directly in the first column of the matrix, but this invariant is broken exactly when an or-pattern has a child that is itself an or-pattern. Here we preserve this broken invariant by recursively expanding `PatKind::Or`s in `Matrix::push`. Fixes rust-lang#69875. r? @varkor cc @Nadrieril cc rust-lang#54883
Code
This code is reduced from issue-54538-unused-parens-lint.rs
Meta
rustc --version --verbose
:Error output
The text was updated successfully, but these errors were encountered: