1
Fork 0

Attach TokenStream to ast::Ty

A `Ty` 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:18:04 -04:00
parent de4bd9f0f8
commit 1823dea7df
No known key found for this signature in database
GPG key ID: B4087E510E98B164
12 changed files with 42 additions and 15 deletions

View file

@ -607,6 +607,7 @@ impl DummyResult {
id: ast::DUMMY_NODE_ID,
kind: if is_error { ast::TyKind::Err } else { ast::TyKind::Tup(Vec::new()) },
span: sp,
tokens: None,
})
}
}

View file

@ -54,7 +54,7 @@ impl<'a> ExtCtxt<'a> {
}
pub fn ty(&self, span: Span, kind: ast::TyKind) -> P<ast::Ty> {
P(ast::Ty { id: ast::DUMMY_NODE_ID, span, kind })
P(ast::Ty { id: ast::DUMMY_NODE_ID, span, kind, tokens: None })
}
pub fn ty_path(&self, path: ast::Path) -> P<ast::Ty> {

View file

@ -37,7 +37,8 @@ pub fn placeholder(
tokens: None,
})
};
let ty = || P(ast::Ty { id, kind: ast::TyKind::MacCall(mac_placeholder()), span });
let ty =
|| P(ast::Ty { id, kind: ast::TyKind::MacCall(mac_placeholder()), span, tokens: None });
let pat =
|| P(ast::Pat { id, kind: ast::PatKind::MacCall(mac_placeholder()), span, tokens: None });
@ -88,9 +89,12 @@ pub fn placeholder(
kind: ast::PatKind::MacCall(mac_placeholder()),
tokens: None,
})),
AstFragmentKind::Ty => {
AstFragment::Ty(P(ast::Ty { id, span, kind: ast::TyKind::MacCall(mac_placeholder()) }))
}
AstFragmentKind::Ty => AstFragment::Ty(P(ast::Ty {
id,
span,
kind: ast::TyKind::MacCall(mac_placeholder()),
tokens: None,
})),
AstFragmentKind::Stmts => AstFragment::Stmts(smallvec![{
let mac = P(ast::MacCallStmt {
mac: mac_placeholder(),