-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Missing "unreachable pattern" warning on char ranges #79307
Comments
Are such intervals ever going to change in the UNICODE world? |
Hm, good question, I have no idea. But they are already hardcoded in the compiler since the following is exhaustive: match 'a' {
'\u{0}'..='\u{D7FF}' | '\u{E000}'..='\u{10_FFFF}' => {}
} So this issue is more about making the two consistent. If unicode changes it would change the above too. |
Current error:
|
Closing this as the warning message now indicates that the 2nd arm is unreachable. |
That's an unrelated lint, it does not indicate that the 2nd arm is unreachable (only my comment in the code does). This still shows the issue. (thx so much for triaging tho!) |
Rewrite exhaustiveness in one pass This is at least my 4th attempt at this in as many years x) Previous attempts were all too complicated or too slow. But we're finally here! The previous version of the exhaustiveness algorithm computed reachability for each arm then exhaustiveness of the whole match. Since each of these steps does roughly the same things, this rewrites the algorithm to do them all in one go. I also think this makes things much simpler. I also rewrote the documentation of the algorithm in depth. Hopefully it's up-to-date and easier to follow now. Plz comment if anything's unclear. r? `@oli-obk` I think you're one of the rare other people to understand the exhaustiveness algorithm? cc `@varkor` I know you're not active anymore, but if you feel like having a look you might enjoy this :D Fixes rust-lang/rust#79307
I tried this code (playground):
The first pattern by itself is exhaustive, because it covers all the valid chars. The second pattern looks like it includes more chars than the first, but it doesn't, because those extra chars are all invalid. So the second pattern should be marked unreachable.
This fails on all rust versions on the playground, and I think it's been that way since we implemented
exhaustive_integer_patterns
. I discovered it while working on the exhaustiveness algorithm.@rustbot modify labels: +A-exhaustiveness-checking
The text was updated successfully, but these errors were encountered: