Remove Nonterminal::NtTT
.
It's only needed for macro expansion, not as a general element in the AST. This commit removes it, adds `NtOrTt` for the parser and macro expansion cases, and renames the variants in `NamedMatch` to better match the new type.
This commit is contained in:
parent
8a0c55046c
commit
364b908d57
10 changed files with 52 additions and 55 deletions
|
@ -51,7 +51,6 @@ impl AstLike for crate::token::Nonterminal {
|
|||
| Nonterminal::NtMeta(_)
|
||||
| Nonterminal::NtPath(_)
|
||||
| Nonterminal::NtVis(_)
|
||||
| Nonterminal::NtTT(_)
|
||||
| Nonterminal::NtBlock(_)
|
||||
| Nonterminal::NtIdent(..)
|
||||
| Nonterminal::NtLifetime(_) => &[],
|
||||
|
@ -67,7 +66,6 @@ impl AstLike for crate::token::Nonterminal {
|
|||
| Nonterminal::NtMeta(_)
|
||||
| Nonterminal::NtPath(_)
|
||||
| Nonterminal::NtVis(_)
|
||||
| Nonterminal::NtTT(_)
|
||||
| Nonterminal::NtBlock(_)
|
||||
| Nonterminal::NtIdent(..)
|
||||
| Nonterminal::NtLifetime(_) => {}
|
||||
|
@ -84,7 +82,7 @@ impl AstLike for crate::token::Nonterminal {
|
|||
Nonterminal::NtPath(path) => path.tokens_mut(),
|
||||
Nonterminal::NtVis(vis) => vis.tokens_mut(),
|
||||
Nonterminal::NtBlock(block) => block.tokens_mut(),
|
||||
Nonterminal::NtIdent(..) | Nonterminal::NtLifetime(..) | Nonterminal::NtTT(..) => None,
|
||||
Nonterminal::NtIdent(..) | Nonterminal::NtLifetime(..) => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -787,7 +787,6 @@ pub fn visit_interpolated<T: MutVisitor>(nt: &mut token::Nonterminal, vis: &mut
|
|||
visit_lazy_tts(tokens, vis);
|
||||
}
|
||||
token::NtPath(path) => vis.visit_path(path),
|
||||
token::NtTT(tt) => visit_tt(tt, vis),
|
||||
token::NtVis(visib) => vis.visit_vis(visib),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,6 @@ pub use TokenKind::*;
|
|||
|
||||
use crate::ast;
|
||||
use crate::ptr::P;
|
||||
use crate::tokenstream::TokenTree;
|
||||
|
||||
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
|
||||
use rustc_data_structures::sync::Lrc;
|
||||
|
@ -680,7 +679,6 @@ pub enum Nonterminal {
|
|||
NtMeta(P<ast::AttrItem>),
|
||||
NtPath(ast::Path),
|
||||
NtVis(ast::Visibility),
|
||||
NtTT(TokenTree),
|
||||
}
|
||||
|
||||
// `Nonterminal` is used a lot. Make sure it doesn't unintentionally get bigger.
|
||||
|
@ -778,7 +776,6 @@ impl Nonterminal {
|
|||
NtMeta(attr_item) => attr_item.span(),
|
||||
NtPath(path) => path.span,
|
||||
NtVis(vis) => vis.span,
|
||||
NtTT(tt) => tt.span(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -790,7 +787,6 @@ impl PartialEq for Nonterminal {
|
|||
ident_lhs == ident_rhs && is_raw_lhs == is_raw_rhs
|
||||
}
|
||||
(NtLifetime(ident_lhs), NtLifetime(ident_rhs)) => ident_lhs == ident_rhs,
|
||||
(NtTT(tt_lhs), NtTT(tt_rhs)) => tt_lhs == tt_rhs,
|
||||
// FIXME: Assume that all "complex" nonterminal are not equal, we can't compare them
|
||||
// correctly based on data from AST. This will prevent them from matching each other
|
||||
// in macros. The comparison will become possible only when each nonterminal has an
|
||||
|
@ -813,7 +809,6 @@ impl fmt::Debug for Nonterminal {
|
|||
NtLiteral(..) => f.pad("NtLiteral(..)"),
|
||||
NtMeta(..) => f.pad("NtMeta(..)"),
|
||||
NtPath(..) => f.pad("NtPath(..)"),
|
||||
NtTT(..) => f.pad("NtTT(..)"),
|
||||
NtVis(..) => f.pad("NtVis(..)"),
|
||||
NtLifetime(..) => f.pad("NtLifetime(..)"),
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue