9965: minor: Don't ask for the builtin attribute input twice r=Veykril a=Veykril

`tt` and `item` here were the same, I misunderstood what the main input for attributes was in #9943
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
This commit is contained in:
bors[bot] 2021-08-21 10:56:09 +00:00 committed by GitHub
commit 6f41053ede
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 9 deletions

View file

@ -18,12 +18,11 @@ macro_rules! register_builtin {
db: &dyn AstDatabase, db: &dyn AstDatabase,
id: MacroCallId, id: MacroCallId,
tt: &tt::Subtree, tt: &tt::Subtree,
item: &tt::Subtree,
) -> ExpandResult<tt::Subtree> { ) -> ExpandResult<tt::Subtree> {
let expander = match *self { let expander = match *self {
$( BuiltinAttrExpander::$variant => $expand, )* $( BuiltinAttrExpander::$variant => $expand, )*
}; };
expander(db, id, tt, item) expander(db, id, tt)
} }
fn find_by_name(name: &name::Name) -> Option<Self> { fn find_by_name(name: &name::Name) -> Option<Self> {
@ -63,8 +62,7 @@ pub fn find_builtin_attr(
fn dummy_attr_expand( fn dummy_attr_expand(
_db: &dyn AstDatabase, _db: &dyn AstDatabase,
_id: MacroCallId, _id: MacroCallId,
_tt: &tt::Subtree, tt: &tt::Subtree,
item: &tt::Subtree,
) -> ExpandResult<tt::Subtree> { ) -> ExpandResult<tt::Subtree> {
ExpandResult::ok(item.clone()) ExpandResult::ok(tt.clone())
} }

View file

@ -53,10 +53,7 @@ impl TokenExpander {
TokenExpander::MacroRules { mac, .. } => mac.expand(tt), TokenExpander::MacroRules { mac, .. } => mac.expand(tt),
TokenExpander::MacroDef { mac, .. } => mac.expand(tt), TokenExpander::MacroDef { mac, .. } => mac.expand(tt),
TokenExpander::Builtin(it) => it.expand(db, id, tt), TokenExpander::Builtin(it) => it.expand(db, id, tt),
TokenExpander::BuiltinAttr(it) => match db.macro_arg(id) { TokenExpander::BuiltinAttr(it) => it.expand(db, id, tt),
Some(macro_arg) => it.expand(db, id, tt, &macro_arg.0),
None => mbe::ExpandResult::str_err("No item argument for attribute".to_string()),
},
TokenExpander::BuiltinDerive(it) => it.expand(db, id, tt), TokenExpander::BuiltinDerive(it) => it.expand(db, id, tt),
TokenExpander::ProcMacro(_) => { TokenExpander::ProcMacro(_) => {
// We store the result in salsa db to prevent non-deterministic behavior in // We store the result in salsa db to prevent non-deterministic behavior in