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
No known key found for this signature in database
GPG key ID: B4087E510E98B164
22 changed files with 120 additions and 50 deletions

View file

@ -279,6 +279,7 @@ pub fn nt_to_tokenstream(nt: &Nonterminal, sess: &ParseSess, span: Span) -> Toke
}
Nonterminal::NtMeta(ref attr) => attr.tokens.clone(),
Nonterminal::NtPath(ref path) => path.tokens.clone(),
Nonterminal::NtVis(ref vis) => vis.tokens.clone(),
Nonterminal::NtTT(ref tt) => Some(tt.clone().into()),
Nonterminal::NtExpr(ref expr) | Nonterminal::NtLiteral(ref expr) => {
if expr.tokens.is_none() {
@ -286,7 +287,6 @@ pub fn nt_to_tokenstream(nt: &Nonterminal, sess: &ParseSess, span: Span) -> Toke
}
prepend_attrs(sess, &expr.attrs, expr.tokens.as_ref(), span)
}
_ => None,
};
// FIXME(#43081): Avoid this pretty-print + reparse hack