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_match: fix handling of privately uninhabited types #47001

Merged
merged 2 commits into from
Jan 21, 2018

Conversation

arielb1
Copy link
Contributor

@arielb1 arielb1 commented Dec 25, 2017

the match-checking code used to use TyErr for signaling "unknown,
inhabited" types for a long time. It had been switched to using the
exact type in #38069, to handle uninhabited types.

However, in #39980, we discovered that we still needed the "unknown
inhabited" logic, but I used () instead of TyErr to handle that.
Revert to using TyErr to fix that problem.

Fixes #46964.

r? @nikomatsakis

@kennytm kennytm added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Dec 25, 2017
Copy link
Contributor

@nikomatsakis nikomatsakis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm sure the code is good, but I'm confused by the comments just a hair.

/// but not any of the sets in `m`.
/// This finds whether a (row) vector `v` of patterns is 'useful' in relation
/// to a set of such vectors `m` is defined as there being a set of inputs
/// that will match `v` but not any of the sets in `m`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This sentence is not 100% grammatical. Maybe:

"This finds whether a (row) vector v of patterns is 'useful' in relation to a set of such vectors m; useful is defined as there being a set of inputs that will match v but not any of the sets in m."

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also not my fault.

@@ -596,6 +602,9 @@ pub fn is_useful<'p, 'a: 'p, 'tcx: 'a>(cx: &mut MatchCheckCtxt<'a, 'tcx>,
assert!(rows.iter().all(|r| r.len() == v.len()));

let pcx = PatternContext {
// () is used to represent an unknown type in this context. If
// one of the fields has a known type, use it instead (other
// than that, all types should be equal modulo normalization).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really understand this comment. What is an unknown type here? And where is () being used?

@carols10cents
Copy link
Member

@nikomatsakis what do you want to do with this PR of ariel's?

@nikomatsakis
Copy link
Contributor

@carols10cents good question =) I'll probably re-read it and try to write some comments myself, then merge it.

the match-checking code used to use TyErr for signaling "unknown,
inhabited" types for a long time. It had been switched to using the
exact type in rust-lang#38069, to handle uninhabited types.

However, in rust-lang#39980, we discovered that we still needed the "unknown
inhabited" logic, but I used `()` instead of `TyErr` to handle that.
Revert to using `TyErr` to fix that problem.
@arielb1
Copy link
Contributor Author

arielb1 commented Jan 13, 2018

I fixed the comments.

@nikomatsakis
Copy link
Contributor

@bors r+

@bors
Copy link
Contributor

bors commented Jan 17, 2018

📌 Commit 98fbcce has been approved by nikomatsakis

@kennytm kennytm added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 17, 2018
@bors
Copy link
Contributor

bors commented Jan 21, 2018

⌛ Testing commit 98fbcce with merge 3001ab1...

bors added a commit that referenced this pull request Jan 21, 2018
check_match: fix handling of privately uninhabited types

the match-checking code used to use TyErr for signaling "unknown,
inhabited" types for a long time. It had been switched to using the
exact type in #38069, to handle uninhabited types.

However, in #39980, we discovered that we still needed the "unknown
inhabited" logic, but I used `()` instead of `TyErr` to handle that.
Revert to using `TyErr` to fix that problem.

Fixes #46964.

r? @nikomatsakis
@bors
Copy link
Contributor

bors commented Jan 21, 2018

☀️ Test successful - status-appveyor, status-travis
Approved by: nikomatsakis
Pushing 3001ab1 to master...

@bors bors merged commit 98fbcce into rust-lang:master Jan 21, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

compiler crash on innocent-looking match
5 participants