-
-
Notifications
You must be signed in to change notification settings - Fork 14.7k
Missing "unreachable pattern" warning on char ranges #79307
Copy link
Copy link
Closed
Labels
A-UnicodeArea: UnicodeArea: UnicodeA-exhaustiveness-checkingRelating to exhaustiveness / usefulness checking of patternsRelating to exhaustiveness / usefulness checking of patternsC-bugCategory: This is a bug.Category: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Metadata
Metadata
Assignees
Labels
A-UnicodeArea: UnicodeArea: UnicodeA-exhaustiveness-checkingRelating to exhaustiveness / usefulness checking of patternsRelating to exhaustiveness / usefulness checking of patternsC-bugCategory: This is a bug.Category: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Type
Fields
Give feedbackNo fields configured for issues without a type.
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