Skip to content

Fixes for the match grammar#262

Merged
Havvy merged 2 commits into
rust-lang:masterfrom
brauliobz:match_grammar
Mar 11, 2018
Merged

Fixes for the match grammar#262
Havvy merged 2 commits into
rust-lang:masterfrom
brauliobz:match_grammar

Conversation

@brauliobz

Copy link
Copy Markdown
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
Copy Markdown
Contributor

Pipes before the patterns are being stabilized in 1.25.

@goodmanjonathan goodmanjonathan left a comment

Copy link
Copy Markdown
Contributor

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

@brauliobz brauliobz Mar 11, 2018

Copy link
Copy Markdown
Contributor Author

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
Copy Markdown
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

Havvy commented Mar 11, 2018

Copy link
Copy Markdown
Contributor

💟 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