mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 16:24:46 +00:00
Use P
for NtMeta
.
This commit reduces the size of `Nonterminal` from a 72 bytes to 40 bytes (on x86-64).
This commit is contained in:
parent
0d69fe8308
commit
7d2173ed27
@ -81,6 +81,7 @@ use rustc_parse::Directory;
|
||||
use rustc_span::symbol::{kw, sym, Symbol};
|
||||
use syntax::ast::{Ident, Name};
|
||||
use syntax::print::pprust;
|
||||
use syntax::ptr::P;
|
||||
use syntax::sess::ParseSess;
|
||||
use syntax::token::{self, DocComment, Nonterminal, Token};
|
||||
use syntax::tokenstream::TokenStream;
|
||||
@ -914,7 +915,7 @@ fn parse_nt_inner<'a>(p: &mut Parser<'a>, sp: Span, name: Symbol) -> PResult<'a,
|
||||
}
|
||||
}
|
||||
sym::path => token::NtPath(p.parse_path(PathStyle::Type)?),
|
||||
sym::meta => token::NtMeta(p.parse_attr_item()?),
|
||||
sym::meta => token::NtMeta(P(p.parse_attr_item()?)),
|
||||
sym::vis => token::NtVis(p.parse_visibility(FollowedByType::Yes)?),
|
||||
sym::lifetime => {
|
||||
if p.check_lifetime() {
|
||||
|
@ -177,7 +177,7 @@ impl<'a> Parser<'a> {
|
||||
pub fn parse_attr_item(&mut self) -> PResult<'a, ast::AttrItem> {
|
||||
let item = match self.token.kind {
|
||||
token::Interpolated(ref nt) => match **nt {
|
||||
Nonterminal::NtMeta(ref item) => Some(item.clone()),
|
||||
Nonterminal::NtMeta(ref item) => Some(item.clone().into_inner()),
|
||||
_ => None,
|
||||
},
|
||||
_ => None,
|
||||
|
@ -704,7 +704,8 @@ pub fn noop_visit_interpolated<T: MutVisitor>(nt: &mut token::Nonterminal, vis:
|
||||
token::NtIdent(ident, _is_raw) => vis.visit_ident(ident),
|
||||
token::NtLifetime(ident) => vis.visit_ident(ident),
|
||||
token::NtLiteral(expr) => vis.visit_expr(expr),
|
||||
token::NtMeta(AttrItem { path, args }) => {
|
||||
token::NtMeta(item) => {
|
||||
let AttrItem { path, args } = item.deref_mut();
|
||||
vis.visit_path(path);
|
||||
visit_mac_args(args, vis);
|
||||
}
|
||||
|
@ -673,7 +673,7 @@ pub enum Nonterminal {
|
||||
NtLifetime(ast::Ident),
|
||||
NtLiteral(P<ast::Expr>),
|
||||
/// Stuff inside brackets for attributes
|
||||
NtMeta(ast::AttrItem),
|
||||
NtMeta(P<ast::AttrItem>),
|
||||
NtPath(ast::Path),
|
||||
NtVis(ast::Visibility),
|
||||
NtTT(TokenTree),
|
||||
@ -687,7 +687,7 @@ pub enum Nonterminal {
|
||||
|
||||
// `Nonterminal` is used a lot. Make sure it doesn't unintentionally get bigger.
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
rustc_data_structures::static_assert_size!(Nonterminal, 72);
|
||||
rustc_data_structures::static_assert_size!(Nonterminal, 40);
|
||||
|
||||
impl PartialEq for Nonterminal {
|
||||
fn eq(&self, rhs: &Self) -> bool {
|
||||
|
Loading…
Reference in New Issue
Block a user