diff options
| author | Mazdak Farrokhzad <twingoow@gmail.com> | 2019-12-05 14:19:00 +0100 |
|---|---|---|
| committer | Mazdak Farrokhzad <twingoow@gmail.com> | 2019-12-06 21:17:18 +0100 |
| commit | 99191c2e717883bfec51b49df0e412a34849fc4a (patch) | |
| tree | 7e62fb059b7c253c5a29b42df997fd38f4ce7d99 /src/librustc_parse/parser | |
| parent | cbc9f683125b4eb21eb3137bbd2c5295650eeaa5 (diff) | |
| download | rust-99191c2e717883bfec51b49df0e412a34849fc4a.tar.gz rust-99191c2e717883bfec51b49df0e412a34849fc4a.zip | |
parse_meta: ditch parse_in_attr
Diffstat (limited to 'src/librustc_parse/parser')
| -rw-r--r-- | src/librustc_parse/parser/attr.rs | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/src/librustc_parse/parser/attr.rs b/src/librustc_parse/parser/attr.rs index b2030a4570e..00fd6b8a25b 100644 --- a/src/librustc_parse/parser/attr.rs +++ b/src/librustc_parse/parser/attr.rs @@ -220,7 +220,7 @@ impl<'a> Parser<'a> { Ok(attrs) } - pub(super) fn parse_unsuffixed_lit(&mut self) -> PResult<'a, ast::Lit> { + crate fn parse_unsuffixed_lit(&mut self) -> PResult<'a, ast::Lit> { let lit = self.parse_lit()?; debug!("checking if {:?} is unusuffixed", lit); @@ -247,12 +247,27 @@ impl<'a> Parser<'a> { let lo = self.token.span; let item = self.parse_attr_item()?; expanded_attrs.push((item, lo.to(self.prev_span))); - self.eat(&token::Comma); + if !self.eat(&token::Comma) { + break; + } } Ok((cfg_predicate, expanded_attrs)) } + /// Matches `COMMASEP(meta_item_inner)`. + crate fn parse_meta_seq_top(&mut self) -> PResult<'a, Vec<ast::NestedMetaItem>> { + // Presumably, the majority of the time there will only be one attr. + let mut nmis = Vec::with_capacity(1); + while self.token.kind != token::Eof { + nmis.push(self.parse_meta_item_inner()?); + if !self.eat(&token::Comma) { + break; + } + } + Ok(nmis) + } + /// Matches the following grammar (per RFC 1559). /// /// meta_item : PATH ( '=' UNSUFFIXED_LIT | '(' meta_item_inner? ')' )? ; |
