-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Check for uninhabited types in sub-patterns (#12609) #36476
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Conversation
r? @arielb1 (rust_highfive has picked a reviewer for you, use r? to override) |
d68b74d
to
0e51853
Compare
☔ The latest upstream changes (presumably #36551) made this pull request unmergeable. Please resolve the merge conflicts. |
0e51853
to
de169e7
Compare
☔ The latest upstream changes (presumably #36857) made this pull request unmergeable. Please resolve the merge conflicts. |
I would prefer that people on the lang team to look on this. |
This alters the exhaustiveness-checking algorithm for pattern matches to avoid raising spurious errors about cases not being covered for uninhabited types. Specifically, the construct_witness function now returns an Option. If it sees that DUMMY_WILD_PAT is being used to match on an uninhabited type it returns None to indicate that there is no witness. We look for DUMMY_WILD_PAT specifically and not any wildcard pattern so that wildcard patterns explicitly written by the programmer continue to work without raising errors about unreachability.
de169e7
to
a0026e6
Compare
☔ The latest upstream changes (presumably #36695) made this pull request unmergeable. Please resolve the merge conflicts. |
Looks like the code that this touched went through a major refactor and this PR will have to be rewritten. |
/cc @rust-lang/lang @rust-lang/compiler |
@canndrew shall we close the PR then and you can re-open when ready? |
@nikomatsakis Sure |
There's another, more complete and correct attempt at fixing this here: #38069 |
This alters the exhaustiveness-checking algorithm for pattern matches to
avoid raising spurious errors about cases not being covered for
uninhabited types.
Specifically, the construct_witness function now returns an Option. If
it sees that DUMMY_WILD_PAT is being used to match on an uninhabited
type it returns None to indicate that there is no witness. We look for
DUMMY_WILD_PAT specifically and not any wildcard pattern so that
wildcard patterns explicitly written by the programmer continue to work
without raising errors about unreachability.