Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 885c723

Browse files
committedSep 25, 2024·
Auto merge of rust-lang#124141 - nnethercote:rm-Nonterminal-and-TokenKind-Interpolated, r=<try>
Remove `Nonterminal` and `TokenKind::Interpolated` A third attempt at this; the first attempt was rust-lang#96724 and the second was rust-lang#114647. r? `@ghost`
2 parents 1b5aa96 + 5494f08 commit 885c723

File tree

144 files changed

+1708
-1399
lines changed

Some content is hidden

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

144 files changed

+1708
-1399
lines changed
 

‎compiler/rustc_ast/src/ast_traits.rs

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ use std::fmt;
66
use std::marker::PhantomData;
77

88
use crate::ptr::P;
9-
use crate::token::Nonterminal;
109
use crate::tokenstream::LazyAttrTokenStream;
1110
use crate::{
1211
Arm, AssocItem, AttrItem, AttrKind, AttrVec, Attribute, Block, Crate, Expr, ExprField,
@@ -196,35 +195,6 @@ impl HasTokens for Attribute {
196195
}
197196
}
198197

199-
impl HasTokens for Nonterminal {
200-
fn tokens(&self) -> Option<&LazyAttrTokenStream> {
201-
match self {
202-
Nonterminal::NtItem(item) => item.tokens(),
203-
Nonterminal::NtStmt(stmt) => stmt.tokens(),
204-
Nonterminal::NtExpr(expr) | Nonterminal::NtLiteral(expr) => expr.tokens(),
205-
Nonterminal::NtPat(pat) => pat.tokens(),
206-
Nonterminal::NtTy(ty) => ty.tokens(),
207-
Nonterminal::NtMeta(attr_item) => attr_item.tokens(),
208-
Nonterminal::NtPath(path) => path.tokens(),
209-
Nonterminal::NtVis(vis) => vis.tokens(),
210-
Nonterminal::NtBlock(block) => block.tokens(),
211-
}
212-
}
213-
fn tokens_mut(&mut self) -> Option<&mut Option<LazyAttrTokenStream>> {
214-
match self {
215-
Nonterminal::NtItem(item) => item.tokens_mut(),
216-
Nonterminal::NtStmt(stmt) => stmt.tokens_mut(),
217-
Nonterminal::NtExpr(expr) | Nonterminal::NtLiteral(expr) => expr.tokens_mut(),
218-
Nonterminal::NtPat(pat) => pat.tokens_mut(),
219-
Nonterminal::NtTy(ty) => ty.tokens_mut(),
220-
Nonterminal::NtMeta(attr_item) => attr_item.tokens_mut(),
221-
Nonterminal::NtPath(path) => path.tokens_mut(),
222-
Nonterminal::NtVis(vis) => vis.tokens_mut(),
223-
Nonterminal::NtBlock(block) => block.tokens_mut(),
224-
}
225-
}
226-
}
227-
228198
/// A trait for AST nodes having (or not having) attributes.
229199
pub trait HasAttrs {
230200
/// This is `true` if this `HasAttrs` might support 'custom' (proc-macro) inner

‎compiler/rustc_ast/src/attr/mod.rs

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use crate::ast::{
1515
NormalAttr, Path, PathSegment, Safety,
1616
};
1717
use crate::ptr::P;
18-
use crate::token::{self, CommentKind, Delimiter, Token};
18+
use crate::token::{self, CommentKind, Delimiter, InvisibleOrigin, MetaVarKind, Token};
1919
use crate::tokenstream::{DelimSpan, LazyAttrTokenStream, Spacing, TokenStream, TokenTree};
2020
use crate::util::comments;
2121
use crate::util::literal::escape_string_symbol;
@@ -364,11 +364,17 @@ impl MetaItem {
364364
let span = span.with_hi(segments.last().unwrap().ident.span.hi());
365365
Path { span, segments, tokens: None }
366366
}
367-
Some(TokenTree::Token(Token { kind: token::Interpolated(nt), .. }, _)) => match &**nt {
368-
token::Nonterminal::NtMeta(item) => return item.meta(item.path.span),
369-
token::Nonterminal::NtPath(path) => (**path).clone(),
370-
_ => return None,
371-
},
367+
Some(TokenTree::Delimited(
368+
_span,
369+
_spacing,
370+
Delimiter::Invisible(InvisibleOrigin::MetaVar(
371+
MetaVarKind::Meta | MetaVarKind::Path,
372+
)),
373+
_stream,
374+
)) => {
375+
// This path is currently unreachable in the test suite.
376+
unreachable!()
377+
}
372378
Some(TokenTree::Token(
373379
Token { kind: token::OpenDelim(_) | token::CloseDelim(_), .. },
374380
_,
@@ -411,7 +417,7 @@ impl MetaItemKind {
411417
tokens: &mut impl Iterator<Item = &'a TokenTree>,
412418
) -> Option<MetaItemKind> {
413419
match tokens.next() {
414-
Some(TokenTree::Delimited(.., Delimiter::Invisible, inner_tokens)) => {
420+
Some(TokenTree::Delimited(.., Delimiter::Invisible(_), inner_tokens)) => {
415421
MetaItemKind::name_value_from_tokens(&mut inner_tokens.trees())
416422
}
417423
Some(TokenTree::Token(token, _)) => {
@@ -549,7 +555,7 @@ impl NestedMetaItem {
549555
tokens.next();
550556
return Some(NestedMetaItem::Lit(lit));
551557
}
552-
Some(TokenTree::Delimited(.., Delimiter::Invisible, inner_tokens)) => {
558+
Some(TokenTree::Delimited(.., Delimiter::Invisible(_), inner_tokens)) => {
553559
tokens.next();
554560
return NestedMetaItem::from_tokens(&mut inner_tokens.trees().peekable());
555561
}

0 commit comments

Comments
 (0)
This repository has been archived.