-
Notifications
You must be signed in to change notification settings - Fork 531
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
Fixes for the match grammar #262
Conversation
brauliobz
commented
Mar 10, 2018
- added MatchArms to make things clearer
- added attributes to both the match block and match arms
- removed pipes before the patterns, since they're experimental
- added MatchArms to make things clearer - added attributes to both the match block and match arms - removes pipes before the patterns, since they're experimental
Pipes before the patterns are being stabilized in 1.25. |
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.
With the comment fixed, lgtm.
Are they really? Where can I follow that? Here: https://github.com/rust-lang/rust/milestone/44 ? I would prefer to only consider things stable when the stable build is published. |
rust-lang/rust#47947 I added the pipes as a prerequisite for the stabilization, so please keep them. |
Ok, that makes all sense 👍 . |
> _MatchArm_ `=>` ( [_BlockExpression_] | [_Expression_] ) `,`<sup>?</sup> | ||
> | ||
> _MatchArm_ : | ||
> [_OuterAttribute_]<sup>\*</sup> _MatchArmPatterns_ _MatchArmGuard_ |
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.
Can you give an example of the OuterAttribute here?
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 can't think of a useful example...
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 tried something like this, but the attribute doesn't apply to the use of deprecated USBType::A
and rustc warns about both things instead (unused attribute and use of deprecated item):
enum USBType {
#[deprecated] A,
B,
C,
}
fn describe(ty: USBType) -> &'static str {
use USBType::*;
match ty {
#[allow(deprecated)] A => "",
B => "",
C => ""
}
}
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.
So it's allowed by the grammar, but doesn't seem to have a use case? Weird, but as long as it's legal...
💟 Thanks! |