Auto merge of #80441 - petrochenkov:kwtok, r=Aaron1011
ast: Remove some indirection layers from values in key-value attributes Trying to address some perf regressions from https://github.com/rust-lang/rust/pull/78837#issuecomment-745380762.
This commit is contained in:
commit
f30733adb9
12 changed files with 72 additions and 50 deletions
|
@ -983,8 +983,8 @@ impl<'a> Parser<'a> {
|
|||
_ => self.sess.gated_spans.gate(sym::extended_key_value_attributes, span),
|
||||
}
|
||||
|
||||
let token = token::Interpolated(Lrc::new(token::NtExpr(expr)));
|
||||
MacArgs::Eq(eq_span, TokenTree::token(token, span).into())
|
||||
let token_kind = token::Interpolated(Lrc::new(token::NtExpr(expr)));
|
||||
MacArgs::Eq(eq_span, Token::new(token_kind, span))
|
||||
} else {
|
||||
MacArgs::Empty
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
use crate::parse_in;
|
||||
|
||||
use rustc_ast::tokenstream::DelimSpan;
|
||||
use rustc_ast::tokenstream::{DelimSpan, TokenTree};
|
||||
use rustc_ast::{self as ast, Attribute, MacArgs, MacDelimiter, MetaItem, MetaItemKind};
|
||||
use rustc_errors::{Applicability, PResult};
|
||||
use rustc_feature::{AttributeTemplate, BUILTIN_ATTRIBUTE_MAP};
|
||||
|
@ -45,7 +45,8 @@ pub fn parse_meta<'a>(sess: &'a ParseSess, attr: &Attribute) -> PResult<'a, Meta
|
|||
kind: match &item.args {
|
||||
MacArgs::Empty => MetaItemKind::Word,
|
||||
MacArgs::Eq(_, t) => {
|
||||
let v = parse_in(sess, t.clone(), "name value", |p| p.parse_unsuffixed_lit())?;
|
||||
let t = TokenTree::Token(t.clone()).into();
|
||||
let v = parse_in(sess, t, "name value", |p| p.parse_unsuffixed_lit())?;
|
||||
MetaItemKind::NameValue(v)
|
||||
}
|
||||
MacArgs::Delimited(dspan, delim, t) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue