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

Fixes for the match grammar #262

Merged
merged 2 commits into from
Mar 11, 2018
Merged

Conversation

brauliobz
Copy link
Contributor

  • 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
@goodmanjonathan
Copy link
Contributor

Pipes before the patterns are being stabilized in 1.25.

Copy link
Contributor

@goodmanjonathan goodmanjonathan left a 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.

@brauliobz
Copy link
Contributor Author

Pipes before the patterns are being stabilized in 1.25.

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.

@goodmanjonathan
Copy link
Contributor

rust-lang/rust#47947
rust-lang/rust#48374

I added the pipes as a prerequisite for the stabilization, so please keep them.

@brauliobz
Copy link
Contributor Author

I added the pipes as a prerequisite for the stabilization, so please keep them.

Ok, that makes all sense 👍 .

> &nbsp;&nbsp; _MatchArm_ `=>` ( [_BlockExpression_] | [_Expression_] ) `,`<sup>?</sup>
>
> _MatchArm_ :
> &nbsp;&nbsp; [_OuterAttribute_]<sup>\*</sup> _MatchArmPatterns_ _MatchArmGuard_
Copy link
Contributor

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?

Copy link
Contributor Author

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...

Copy link
Contributor Author

@brauliobz brauliobz Mar 11, 2018

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 => ""
    }
}

Copy link
Contributor

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...

@Havvy Havvy merged commit 45649d8 into rust-lang:master Mar 11, 2018
@Havvy
Copy link
Contributor

Havvy commented Mar 11, 2018

💟 Thanks!

@brauliobz brauliobz deleted the match_grammar branch March 11, 2018 18:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants