Attach TokenStream to ast::Visibility

A `Visibility` does not have outer attributes, so we only capture tokens
when parsing a `macro_rules!` matcher
This commit is contained in:
Aaron Hill
2020-08-21 19:11:00 -04:00
parent 55082ce413
commit c1011165e6
22 changed files with 120 additions and 50 deletions

View File

@@ -186,7 +186,15 @@ impl<'a> Parser<'a> {
token::NtMeta(P(attr))
}
NonterminalKind::TT => token::NtTT(self.parse_token_tree()),
NonterminalKind::Vis => token::NtVis(self.parse_visibility(FollowedByType::Yes)?),
NonterminalKind::Vis => {
let (mut vis, tokens) =
self.collect_tokens(|this| this.parse_visibility(FollowedByType::Yes))?;
// We may have etan an `NtVis`, which could already have tokens
if vis.tokens.is_none() {
vis.tokens = Some(tokens);
}
token::NtVis(vis)
}
NonterminalKind::Lifetime => {
if self.check_lifetime() {
token::NtLifetime(self.expect_lifetime().ident)