1
Fork 0

rustc_parse: Move AST -> TokenStream conversion logic to rustc_ast

This commit is contained in:
Vadim Petrochenkov 2022-05-21 15:50:39 +03:00
parent acfd327fd4
commit 8e8fb4f49e
14 changed files with 124 additions and 284 deletions

View file

@ -108,7 +108,7 @@ macro_rules! impl_has_span {
};
}
impl_has_span!(AssocItem, Expr, ForeignItem, Item, Stmt);
impl_has_span!(AssocItem, Block, Expr, ForeignItem, Item, Pat, Path, Stmt, Ty, Visibility);
impl<T: AstDeref<Target: HasSpan>> HasSpan for T {
fn span(&self) -> Span {
@ -116,6 +116,12 @@ impl<T: AstDeref<Target: HasSpan>> HasSpan for T {
}
}
impl HasSpan for AttrItem {
fn span(&self) -> Span {
self.span()
}
}
/// A trait for AST nodes having (or not having) collected tokens.
pub trait HasTokens {
fn tokens(&self) -> Option<&LazyTokenStream>;