From 438d1da6c6becf28c07570e301d80989ffc0febe Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Mon, 16 Aug 2021 14:45:54 +0300 Subject: [PATCH] minor: simplify --- crates/hir_expand/src/db.rs | 2 +- crates/hir_expand/src/input.rs | 17 +++++------------ 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/crates/hir_expand/src/db.rs b/crates/hir_expand/src/db.rs index d619d6a462..795980660d 100644 --- a/crates/hir_expand/src/db.rs +++ b/crates/hir_expand/src/db.rs @@ -272,7 +272,7 @@ fn macro_arg(db: &dyn AstDatabase, id: MacroCallId) -> Option Option { let loc = db.lookup_intern_macro(id); let arg = loc.kind.arg(db)?; - let arg = process_macro_input(db, arg, id); + let arg = process_macro_input(&loc.kind, arg); if matches!(loc.kind, MacroCallKind::FnLike { .. }) { let first = arg.first_child_or_token().map_or(T![.], |it| it.kind()); let last = arg.last_child_or_token().map_or(T![.], |it| it.kind()); diff --git a/crates/hir_expand/src/input.rs b/crates/hir_expand/src/input.rs index bc3ecc5930..55935ed3dd 100644 --- a/crates/hir_expand/src/input.rs +++ b/crates/hir_expand/src/input.rs @@ -6,19 +6,12 @@ use syntax::{ }; use crate::{ - db::AstDatabase, name::{name, AsName}, - MacroCallId, MacroCallKind, MacroCallLoc, + MacroCallKind, }; -pub(crate) fn process_macro_input( - db: &dyn AstDatabase, - node: SyntaxNode, - id: MacroCallId, -) -> SyntaxNode { - let loc: MacroCallLoc = db.lookup_intern_macro(id); - - match loc.kind { +pub(crate) fn process_macro_input(macro_call_kind: &MacroCallKind, node: SyntaxNode) -> SyntaxNode { + match macro_call_kind { MacroCallKind::FnLike { .. } => node, MacroCallKind::Derive { derive_attr_index, .. } => { let item = match ast::Item::cast(node.clone()) { @@ -26,7 +19,7 @@ pub(crate) fn process_macro_input( None => return node, }; - remove_derives_up_to(item, derive_attr_index as usize).syntax().clone() + remove_derives_up_to(item, *derive_attr_index as usize).syntax().clone() } MacroCallKind::Attr { invoc_attr_index, .. } => { let item = match ast::Item::cast(node.clone()) { @@ -34,7 +27,7 @@ pub(crate) fn process_macro_input( None => return node, }; - remove_attr_invoc(item, invoc_attr_index as usize).syntax().clone() + remove_attr_invoc(item, *invoc_attr_index as usize).syntax().clone() } } }