ast: Introduce some traits to get AST node properties generically
And use them to avoid constructing some artificial `Nonterminal` tokens during expansion
This commit is contained in:
parent
8fcf113743
commit
f77fd90aff
@ -1,7 +1,7 @@
|
||||
//! Format attributes and meta items.
|
||||
|
||||
use rustc_ast::ast;
|
||||
use rustc_ast::AstLike;
|
||||
use rustc_ast::HasAttrs;
|
||||
use rustc_span::{symbol::sym, Span, Symbol};
|
||||
|
||||
use self::doc_comment::DocCommentFormatter;
|
||||
|
@ -5,7 +5,6 @@
|
||||
use std::time::{Duration, Instant};
|
||||
|
||||
use rustc_ast::ast;
|
||||
use rustc_ast::AstLike;
|
||||
use rustc_span::Span;
|
||||
|
||||
use self::newline_style::apply_newline_style;
|
||||
|
@ -4,7 +4,6 @@
|
||||
|
||||
use rustc_ast::ast;
|
||||
use rustc_ast::visit::Visitor;
|
||||
use rustc_ast::AstLike;
|
||||
use rustc_span::symbol::{self, sym, Symbol};
|
||||
use rustc_span::Span;
|
||||
use thiserror::Error;
|
||||
@ -50,19 +49,10 @@ pub(crate) fn new(
|
||||
ast_mod_kind,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> AstLike for Module<'a> {
|
||||
const SUPPORTS_CUSTOM_INNER_ATTRS: bool = true;
|
||||
fn attrs(&self) -> &[ast::Attribute] {
|
||||
pub(crate) fn attrs(&self) -> &[ast::Attribute] {
|
||||
&self.inner_attr
|
||||
}
|
||||
fn visit_attrs(&mut self, f: impl FnOnce(&mut Vec<ast::Attribute>)) {
|
||||
f(&mut self.inner_attr)
|
||||
}
|
||||
fn tokens_mut(&mut self) -> Option<&mut Option<rustc_ast::tokenstream::LazyTokenStream>> {
|
||||
unimplemented!()
|
||||
}
|
||||
}
|
||||
|
||||
/// Maps each module to the corresponding file.
|
||||
|
@ -1,7 +1,7 @@
|
||||
use std::cell::{Cell, RefCell};
|
||||
use std::rc::Rc;
|
||||
|
||||
use rustc_ast::{ast, token::Delimiter, visit, AstLike};
|
||||
use rustc_ast::{ast, token::Delimiter, visit};
|
||||
use rustc_data_structures::sync::Lrc;
|
||||
use rustc_span::{symbol, BytePos, Pos, Span};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user