-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Conversation
There was a problem hiding this 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.
src/librustc_const_eval/_match.rs
Outdated
/// 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`. |
There was a problem hiding this comment.
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
."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also not my fault.
src/librustc_const_eval/_match.rs
Outdated
@@ -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). |
There was a problem hiding this comment.
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?
@nikomatsakis what do you want to do with this PR of ariel's? |
@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.
7c8d541
to
c1281b4
Compare
I fixed the comments. |
@bors r+ |
📌 Commit 98fbcce has been approved by |
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
☀️ Test successful - status-appveyor, status-travis |
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 ofTyErr
to handle that.Revert to using
TyErr
to fix that problem.Fixes #46964.
r? @nikomatsakis