-
Notifications
You must be signed in to change notification settings - Fork 13k
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
RFC2229 Add missing edge case #87996
Conversation
r? @wesleywiser (rust-highfive has picked a reviewer for you, use r? to override) |
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.
Possible edge case
@@ -265,6 +265,9 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> { | |||
if def.variants.len() > 1 { | |||
needs_to_be_read = true; | |||
} | |||
} else { | |||
// If it is not ty::Adt, then it should be read | |||
needs_to_be_read = true; |
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 am wondering what cases might be missing here -- one silly example might be matching on a constant of type ()
or something like that, which is kind of a no-op.
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 am not too sure either. I am going to import all the match test cases that are here https://github.com/rust-lang/rust/tree/master/src/test/ui/match and then convert them into closure test cases and see if I found anything new
@bors r+ We might as well land this PR in the meantime. |
📌 Commit 2e61659 has been approved by |
RFC2229 Add missing edge case Closes rust-lang#87988 This PR fixes an ICE where a match discriminant is not being read when expected. This ICE was the result of a missing edge case which assumed that if a pattern is of type `PatKind::TupleStruct(..) | PatKind::Path(..) | PatKind::Struct(..) | PatKind::Tuple(..)` then a place could only be a multi variant if the place is of type kind Adt.
☀️ Test successful - checks-actions |
Closes #87988
This PR fixes an ICE where a match discriminant is not being read when expected. This ICE was the result of a missing edge case which assumed that if a pattern is of type
PatKind::TupleStruct(..) | PatKind::Path(..) | PatKind::Struct(..) | PatKind::Tuple(..)
then a place could only be a multi variant if the place is of type kind Adt.