Skip to content

Eat open paren when parsing list in libsyntax/parse/attr.rs #43904

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

Merged
merged 1 commit into from
Aug 18, 2017

Conversation

topecongiro
Copy link
Contributor

This PR adds a small refactoring:

      pub fn parse_meta_item_kind(&mut self) -> PResult<'a, ast::MetaItemKind> {
         Ok(if self.eat(&token::Eq) {
             ast::MetaItemKind::NameValue(self.parse_unsuffixed_lit()?)
-        } else if self.token == token::OpenDelim(token::Paren) {
+        } else if self.eat(&token::OpenDelim(token::Paren)) {
             ast::MetaItemKind::List(self.parse_meta_seq()?)
         } else {
-            self.eat(&token::OpenDelim(token::Paren));
             ast::MetaItemKind::Word
         })
     } 

in parse_meta_item_kind(), the parser calls self.eat(&token::OpenDelim(token::Paren)); before returning ast::MetaItemKind::Word just to add ( to expected token. It seems more natural to eat the paren when parsing ast::MetaItemKind::List.

@rust-highfive
Copy link
Contributor

r? @pnkfelix

(rust_highfive has picked a reviewer for you, use r? to override)

@petrochenkov
Copy link
Contributor

Thanks!
@bors r+

@bors
Copy link
Collaborator

bors commented Aug 16, 2017

📌 Commit 0bfe417 has been approved by petrochenkov

@aidanhs aidanhs added the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Aug 16, 2017
@bors
Copy link
Collaborator

bors commented Aug 18, 2017

⌛ Testing commit 0bfe417 with merge e6ab511...

bors added a commit that referenced this pull request Aug 18, 2017
Eat open paren when parsing list in libsyntax/parse/attr.rs

This PR adds a small refactoring:
```diff
      pub fn parse_meta_item_kind(&mut self) -> PResult<'a, ast::MetaItemKind> {
         Ok(if self.eat(&token::Eq) {
             ast::MetaItemKind::NameValue(self.parse_unsuffixed_lit()?)
-        } else if self.token == token::OpenDelim(token::Paren) {
+        } else if self.eat(&token::OpenDelim(token::Paren)) {
             ast::MetaItemKind::List(self.parse_meta_seq()?)
         } else {
-            self.eat(&token::OpenDelim(token::Paren));
             ast::MetaItemKind::Word
         })
     }
```
in `parse_meta_item_kind()`, the parser calls `self.eat(&token::OpenDelim(token::Paren));` before returning `ast::MetaItemKind::Word` just to add `(` to expected token. It seems more natural to eat the paren when parsing `ast::MetaItemKind::List`.
@bors
Copy link
Collaborator

bors commented Aug 18, 2017

☀️ Test successful - status-appveyor, status-travis
Approved by: petrochenkov
Pushing e6ab511 to master...

@bors bors merged commit 0bfe417 into rust-lang:master Aug 18, 2017
@topecongiro topecongiro deleted the libsyntax/parse-attr branch August 23, 2017 12:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants