Skip to content
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

Check for uninhabited types in sub-patterns (#12609) #36476

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
Collaborator

r? @arielb1

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

@bors
Copy link
Contributor

bors commented Sep 22, 2016

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

@bors
Copy link
Contributor

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
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in 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