Skip to content

Commit aaa2d47

Browse files
committedMar 12, 2025·
Auto merge of #138083 - nnethercote:rm-NtItem-NtStmt, r=petrochenkov
Remove `NtItem` and `NtStmt` Another piece of #124141. r? `@petrochenkov`
·
1.90.01.87.0
2 parents 0998d40 + 3378ee1 commit aaa2d47

File tree

49 files changed

+269
-141
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+269
-141
lines changed
 

‎compiler/rustc_ast/src/ast_traits.rs‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -209,16 +209,12 @@ impl HasTokens for Attribute {
209209
impl HasTokens for Nonterminal {
210210
fn tokens(&self) -> Option<&LazyAttrTokenStream> {
211211
match self {
212-
Nonterminal::NtItem(item) => item.tokens(),
213-
Nonterminal::NtStmt(stmt) => stmt.tokens(),
214212
Nonterminal::NtExpr(expr) | Nonterminal::NtLiteral(expr) => expr.tokens(),
215213
Nonterminal::NtBlock(block) => block.tokens(),
216214
}
217215
}
218216
fn tokens_mut(&mut self) -> Option<&mut Option<LazyAttrTokenStream>> {
219217
match self {
220-
Nonterminal::NtItem(item) => item.tokens_mut(),
221-
Nonterminal::NtStmt(stmt) => stmt.tokens_mut(),
222218
Nonterminal::NtExpr(expr) | Nonterminal::NtLiteral(expr) => expr.tokens_mut(),
223219
Nonterminal::NtBlock(block) => block.tokens_mut(),
224220
}

‎compiler/rustc_ast/src/lib.rs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
77
// tidy-alphabetical-start
88
#![allow(internal_features)]
9+
#![cfg_attr(doc, recursion_limit = "256")] // FIXME(nnethercote): will be removed by #124141
910
#![doc(
1011
html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/",
1112
test(attr(deny(warnings)))

‎compiler/rustc_ast/src/mut_visit.rs‎

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -895,19 +895,7 @@ pub fn visit_token<T: MutVisitor>(vis: &mut T, t: &mut Token) {
895895
// multiple items there....
896896
fn visit_nonterminal<T: MutVisitor>(vis: &mut T, nt: &mut token::Nonterminal) {
897897
match nt {
898-
token::NtItem(item) => visit_clobber(item, |item| {
899-
// This is probably okay, because the only visitors likely to
900-
// peek inside interpolated nodes will be renamings/markings,
901-
// which map single items to single items.
902-
vis.flat_map_item(item).expect_one("expected visitor to produce exactly one item")
903-
}),
904898
token::NtBlock(block) => vis.visit_block(block),
905-
token::NtStmt(stmt) => visit_clobber(stmt, |stmt| {
906-
// See reasoning above.
907-
stmt.map(|stmt| {
908-
vis.flat_map_stmt(stmt).expect_one("expected visitor to produce exactly one item")
909-
})
910-
}),
911899
token::NtExpr(expr) => vis.visit_expr(expr),
912900
token::NtLiteral(expr) => vis.visit_expr(expr),
913901
}

‎compiler/rustc_ast/src/token.rs‎

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -870,6 +870,7 @@ impl Token {
870870
/// Is this a pre-parsed expression dropped into the token stream
871871
/// (which happens while parsing the result of macro expansion)?
872872
pub fn is_whole_expr(&self) -> bool {
873+
#[allow(irrefutable_let_patterns)] // FIXME: temporary
873874
if let Interpolated(nt) = &self.kind
874875
&& let NtExpr(_) | NtLiteral(_) | NtBlock(_) = &**nt
875876
{
@@ -1103,9 +1104,7 @@ pub enum NtExprKind {
11031104
#[derive(Clone, Encodable, Decodable)]
11041105
/// For interpolation during macro expansion.
11051106
pub enum Nonterminal {
1106-
NtItem(P<ast::Item>),
11071107
NtBlock(P<ast::Block>),
1108-
NtStmt(P<ast::Stmt>),
11091108
NtExpr(P<ast::Expr>),
11101109
NtLiteral(P<ast::Expr>),
11111110
}
@@ -1196,18 +1195,14 @@ impl fmt::Display for NonterminalKind {
11961195
impl Nonterminal {
11971196
pub fn use_span(&self) -> Span {
11981197
match self {
1199-
NtItem(item) => item.span,
12001198
NtBlock(block) => block.span,
1201-
NtStmt(stmt) => stmt.span,
12021199
NtExpr(expr) | NtLiteral(expr) => expr.span,
12031200
}
12041201
}
12051202

12061203
pub fn descr(&self) -> &'static str {
12071204
match self {
1208-
NtItem(..) => "item",
12091205
NtBlock(..) => "block",
1210-
NtStmt(..) => "statement",
12111206
NtExpr(..) => "expression",
12121207
NtLiteral(..) => "literal",
12131208
}
@@ -1227,9 +1222,7 @@ impl PartialEq for Nonterminal {
12271222
impl fmt::Debug for Nonterminal {
12281223
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
12291224
match *self {
1230-
NtItem(..) => f.pad("NtItem(..)"),
12311225
NtBlock(..) => f.pad("NtBlock(..)"),
1232-
NtStmt(..) => f.pad("NtStmt(..)"),
12331226
NtExpr(..) => f.pad("NtExpr(..)"),
12341227
NtLiteral(..) => f.pad("NtLiteral(..)"),
12351228
}

0 commit comments

Comments
 (0)
Please sign in to comment.