Skip to content

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

Closed
wants to merge 1 commit into from

Conversation

canndrew
Copy link
Contributor

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.

@rust-highfive
Copy link
Contributor

r? @arielb1

(rust_highfive has picked a reviewer for you, use r? to override)

@bors
Copy link
Collaborator

bors commented Sep 22, 2016

☔ The latest upstream changes (presumably #36551) made this pull request unmergeable. Please resolve the merge conflicts.

@bors
Copy link
Collaborator

bors commented Oct 1, 2016

☔ The latest upstream changes (presumably #36857) made this pull request unmergeable. Please resolve the merge conflicts.

@arielb1
Copy link
Contributor

arielb1 commented Oct 2, 2016

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.
@bors
Copy link
Collaborator

bors commented Oct 27, 2016

☔ The latest upstream changes (presumably #36695) made this pull request unmergeable. Please resolve the merge conflicts.

@canndrew
Copy link
Contributor Author

canndrew commented Nov 2, 2016

Looks like the code that this touched went through a major refactor and this PR will have to be rewritten.

@steveklabnik
Copy link
Member

/cc @rust-lang/lang @rust-lang/compiler

@aturon aturon added the T-lang Relevant to the language team, which will review and decide on the PR/issue. label Nov 7, 2016
@nikomatsakis
Copy link
Contributor

@canndrew shall we close the PR then and you can re-open when ready?

@canndrew
Copy link
Contributor Author

canndrew commented Nov 9, 2016

@nikomatsakis Sure

@canndrew canndrew closed this Nov 9, 2016
@canndrew
Copy link
Contributor Author

canndrew commented Dec 1, 2016

There's another, more complete and correct attempt at fixing this here: #38069

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
T-lang Relevant to the language team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants