Attach tokens to ast::Stmt
We currently only attach tokens when parsing a `:stmt` matcher for a `macro_rules!` macro. Proc-macro attributes on statements are still unstable, and need additional work.
This commit is contained in:
parent
c1011165e6
commit
156ef2bee8
11 changed files with 56 additions and 15 deletions
|
@ -918,6 +918,7 @@ pub struct Stmt {
|
|||
pub id: NodeId,
|
||||
pub kind: StmtKind,
|
||||
pub span: Span,
|
||||
pub tokens: Option<TokenStream>,
|
||||
}
|
||||
|
||||
impl Stmt {
|
||||
|
|
|
@ -1286,12 +1286,15 @@ pub fn noop_filter_map_expr<T: MutVisitor>(mut e: P<Expr>, vis: &mut T) -> Optio
|
|||
}
|
||||
|
||||
pub fn noop_flat_map_stmt<T: MutVisitor>(
|
||||
Stmt { kind, mut span, mut id }: Stmt,
|
||||
Stmt { kind, mut span, mut id, tokens }: Stmt,
|
||||
vis: &mut T,
|
||||
) -> SmallVec<[Stmt; 1]> {
|
||||
vis.visit_id(&mut id);
|
||||
vis.visit_span(&mut span);
|
||||
noop_flat_map_stmt_kind(kind, vis).into_iter().map(|kind| Stmt { id, kind, span }).collect()
|
||||
noop_flat_map_stmt_kind(kind, vis)
|
||||
.into_iter()
|
||||
.map(|kind| Stmt { id, kind, span, tokens: tokens.clone() })
|
||||
.collect()
|
||||
}
|
||||
|
||||
pub fn noop_flat_map_stmt_kind<T: MutVisitor>(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue