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.

@goodmanjonathangoodmanjonathan 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
ContributorAuthor

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
ContributorAuthor

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
ContributorAuthor

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

@brauliobzbrauliobzMar 11, 2018

Copy link
Copy Markdown
ContributorAuthor

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):

enumUSBType{#[deprecated]A,B,C,}fndescribe(ty:USBType) -> &'staticstr{useUSBType::*;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:masterMar 11, 2018
@Havvy

Copy link
Copy Markdown
Contributor

💟 Thanks!

@brauliobz
brauliobz deleted the match_grammar branch March 11, 2018 18:15
Sign up for freeto 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

@brauliobz@goodmanjonathan@Havvy