-
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
Add support for while let
#17733
Add support for while let
#17733
Conversation
I suspect that this isn’t supposed to be so heavily based on |
Hah, oi. headdesk |
Subject line needs fixing. |
} | ||
} else { | ||
span_err!(cx.tcx.sess, pat.span, E0001, "unreachable pattern"); | ||
span_err!(cx.tcx.sess, span, E0163, "irrefutable while-let pattern"); |
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.
Is there a specific reason this is an error? What if I want to do an infinite loop with destructuring?
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.
That's discussed in the RFC: https://github.com/rust-lang/rfcs/blob/master/active/0068-while-let.md#detailed-design
Rebased onto current master |
span_err!(cx.tcx.sess, span, E0165, "irrefutable while-let pattern"); | ||
}, | ||
|
||
_ => span_err!(cx.tcx.sess, pat.span, E0001, "unreachable pattern") |
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.
nit: Could you please make this a specific pattern, i.e.:
MatchNormal => span_err!(cx.tcx.sess, pat.span, E0001, "unreachable pattern")
The set of variants of this particular enum probably won't grow in the near future but it's still good for clarity, I think.
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.
Thanks, fixed in 16ccdba.
This is heavily based on
if let
(#17634) by @jakub- and @kballardThis should close #17687