Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 17de919

Browse files
committed
Auto merge of rust-lang#138083 - nnethercote:rm-NtItem-NtStmt, r=<try>
Remove `NtItem` and `NtStmt` Another piece of rust-lang#124141. r? `@petrochenkov`
2 parents 91a0e16 + 3378ee1 commit 17de919

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
}

compiler/rustc_ast/src/tokenstream.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use rustc_macros::{Decodable, Encodable, HashStable_Generic};
2323
use rustc_serialize::{Decodable, Encodable};
2424
use rustc_span::{DUMMY_SP, Span, SpanDecoder, SpanEncoder, Symbol, sym};
2525

26-
use crate::ast::{AttrStyle, StmtKind};
26+
use crate::ast::AttrStyle;
2727
use crate::ast_traits::{HasAttrs, HasTokens};
2828
use crate::token::{self, Delimiter, InvisibleOrigin, Nonterminal, Token, TokenKind};
2929
use crate::{AttrVec, Attribute};
@@ -461,13 +461,7 @@ impl TokenStream {
461461

462462
pub fn from_nonterminal_ast(nt: &Nonterminal) -> TokenStream {
463463
match nt {
464-
Nonterminal::NtItem(item) => TokenStream::from_ast(item),
465464
Nonterminal::NtBlock(block) => TokenStream::from_ast(block),
466-
Nonterminal::NtStmt(stmt) if let StmtKind::Empty = stmt.kind => {
467-
// FIXME: Properly collect tokens for empty statements.
468-
TokenStream::token_alone(token::Semi, stmt.span)
469-
}
470-
Nonterminal::NtStmt(stmt) => TokenStream::from_ast(stmt),
471465
Nonterminal::NtExpr(expr) | Nonterminal::NtLiteral(expr) => TokenStream::from_ast(expr),
472466
}
473467
}

compiler/rustc_ast_lowering/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
3333
// tidy-alphabetical-start
3434
#![allow(internal_features)]
35+
#![cfg_attr(doc, recursion_limit = "256")] // FIXME(nnethercote): will be removed by #124141
3536
#![doc(rust_logo)]
3637
#![feature(assert_matches)]
3738
#![feature(box_patterns)]

compiler/rustc_attr_parsing/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@
7777
7878
// tidy-alphabetical-start
7979
#![allow(internal_features)]
80+
#![cfg_attr(doc, recursion_limit = "256")] // FIXME(nnethercote): will be removed by #124141
8081
#![doc(rust_logo)]
8182
#![feature(let_chains)]
8283
#![feature(rustdoc_internals)]

compiler/rustc_borrowck/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
33
// tidy-alphabetical-start
44
#![allow(internal_features)]
5+
#![cfg_attr(doc, recursion_limit = "256")] // FIXME(nnethercote): will be removed by #124141
56
#![doc(rust_logo)]
67
#![feature(assert_matches)]
78
#![feature(box_patterns)]

compiler/rustc_builtin_macros/src/cfg_eval.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,9 @@ impl CfgEval<'_> {
140140
Annotatable::ForeignItem(self.flat_map_foreign_item(item).pop().unwrap())
141141
}
142142
Annotatable::Stmt(_) => {
143-
let stmt =
144-
parser.parse_stmt_without_recovery(false, ForceCollect::Yes)?.unwrap();
143+
let stmt = parser
144+
.parse_stmt_without_recovery(false, ForceCollect::Yes, false)?
145+
.unwrap();
145146
Annotatable::Stmt(P(self.flat_map_stmt(stmt).pop().unwrap()))
146147
}
147148
Annotatable::Expr(_) => {

compiler/rustc_builtin_macros/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#![allow(internal_features)]
66
#![allow(rustc::diagnostic_outside_of_impl)]
77
#![allow(rustc::untranslatable_diagnostic)]
8+
#![cfg_attr(doc, recursion_limit = "256")] // FIXME(nnethercote): will be removed by #124141
89
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
910
#![doc(rust_logo)]
1011
#![feature(assert_matches)]

0 commit comments

Comments
 (0)