1
Fork 0

Attach tokens to NtMeta (ast::AttrItem)

An `AttrItem` 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 18:37:34 -04:00
parent d5a04a9927
commit 3815e91ccd
No known key found for this signature in database
GPG key ID: B4087E510E98B164
9 changed files with 17 additions and 6 deletions

View file

@ -2419,6 +2419,7 @@ impl<D: Decoder> rustc_serialize::Decodable<D> for AttrId {
pub struct AttrItem {
pub path: Path,
pub args: MacArgs,
pub tokens: Option<TokenStream>,
}
/// A list of attributes.

View file

@ -330,7 +330,7 @@ crate fn mk_attr_id() -> AttrId {
}
pub fn mk_attr(style: AttrStyle, path: Path, args: MacArgs, span: Span) -> Attribute {
mk_attr_from_item(style, AttrItem { path, args }, span)
mk_attr_from_item(style, AttrItem { path, args, tokens: None }, span)
}
pub fn mk_attr_from_item(style: AttrStyle, item: AttrItem, span: Span) -> Attribute {

View file

@ -579,7 +579,7 @@ pub fn noop_visit_local<T: MutVisitor>(local: &mut P<Local>, vis: &mut T) {
pub fn noop_visit_attribute<T: MutVisitor>(attr: &mut Attribute, vis: &mut T) {
let Attribute { kind, id: _, style: _, span } = attr;
match kind {
AttrKind::Normal(AttrItem { path, args }) => {
AttrKind::Normal(AttrItem { path, args, tokens: _ }) => {
vis.visit_path(path);
visit_mac_args(args, vis);
}
@ -709,7 +709,7 @@ pub fn noop_visit_interpolated<T: MutVisitor>(nt: &mut token::Nonterminal, vis:
token::NtLifetime(ident) => vis.visit_ident(ident),
token::NtLiteral(expr) => vis.visit_expr(expr),
token::NtMeta(item) => {
let AttrItem { path, args } = item.deref_mut();
let AttrItem { path, args, tokens: _ } = item.deref_mut();
vis.visit_path(path);
visit_mac_args(args, vis);
}