Skip to content

Commit f77fd90

Browse files
committed
ast: Introduce some traits to get AST node properties generically
And use them to avoid constructing some artificial `Nonterminal` tokens during expansion
1 parent 8fcf113 commit f77fd90

File tree

4 files changed

+3
-14
lines changed

4 files changed

+3
-14
lines changed

src/attr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! Format attributes and meta items.
22
33
use rustc_ast::ast;
4-
use rustc_ast::AstLike;
4+
use rustc_ast::HasAttrs;
55
use rustc_span::{symbol::sym, Span, Symbol};
66

77
use self::doc_comment::DocCommentFormatter;

src/formatting.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ use std::io::{self, Write};
55
use std::time::{Duration, Instant};
66

77
use rustc_ast::ast;
8-
use rustc_ast::AstLike;
98
use rustc_span::Span;
109

1110
use self::newline_style::apply_newline_style;

src/modules.rs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ use std::path::{Path, PathBuf};
44

55
use rustc_ast::ast;
66
use rustc_ast::visit::Visitor;
7-
use rustc_ast::AstLike;
87
use rustc_span::symbol::{self, sym, Symbol};
98
use rustc_span::Span;
109
use thiserror::Error;
@@ -50,19 +49,10 @@ impl<'a> Module<'a> {
5049
ast_mod_kind,
5150
}
5251
}
53-
}
5452

55-
impl<'a> AstLike for Module<'a> {
56-
const SUPPORTS_CUSTOM_INNER_ATTRS: bool = true;
57-
fn attrs(&self) -> &[ast::Attribute] {
53+
pub(crate) fn attrs(&self) -> &[ast::Attribute] {
5854
&self.inner_attr
5955
}
60-
fn visit_attrs(&mut self, f: impl FnOnce(&mut Vec<ast::Attribute>)) {
61-
f(&mut self.inner_attr)
62-
}
63-
fn tokens_mut(&mut self) -> Option<&mut Option<rustc_ast::tokenstream::LazyTokenStream>> {
64-
unimplemented!()
65-
}
6656
}
6757

6858
/// Maps each module to the corresponding file.

src/visitor.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::cell::{Cell, RefCell};
22
use std::rc::Rc;
33

4-
use rustc_ast::{ast, token::Delimiter, visit, AstLike};
4+
use rustc_ast::{ast, token::Delimiter, visit};
55
use rustc_data_structures::sync::Lrc;
66
use rustc_span::{symbol, BytePos, Pos, Span};
77

0 commit comments

Comments
 (0)