Skip to content

Commit 438d1da

Browse files
committed
minor: simplify
1 parent d29c523 commit 438d1da

File tree

2 files changed

+6
-13
lines changed

2 files changed

+6
-13
lines changed

crates/hir_expand/src/db.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ fn macro_arg(db: &dyn AstDatabase, id: MacroCallId) -> Option<Arc<(tt::Subtree,
272272
fn macro_arg_text(db: &dyn AstDatabase, id: MacroCallId) -> Option<GreenNode> {
273273
let loc = db.lookup_intern_macro(id);
274274
let arg = loc.kind.arg(db)?;
275-
let arg = process_macro_input(db, arg, id);
275+
let arg = process_macro_input(&loc.kind, arg);
276276
if matches!(loc.kind, MacroCallKind::FnLike { .. }) {
277277
let first = arg.first_child_or_token().map_or(T![.], |it| it.kind());
278278
let last = arg.last_child_or_token().map_or(T![.], |it| it.kind());

crates/hir_expand/src/input.rs

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,35 +6,28 @@ use syntax::{
66
};
77

88
use crate::{
9-
db::AstDatabase,
109
name::{name, AsName},
11-
MacroCallId, MacroCallKind, MacroCallLoc,
10+
MacroCallKind,
1211
};
1312

14-
pub(crate) fn process_macro_input(
15-
db: &dyn AstDatabase,
16-
node: SyntaxNode,
17-
id: MacroCallId,
18-
) -> SyntaxNode {
19-
let loc: MacroCallLoc = db.lookup_intern_macro(id);
20-
21-
match loc.kind {
13+
pub(crate) fn process_macro_input(macro_call_kind: &MacroCallKind, node: SyntaxNode) -> SyntaxNode {
14+
match macro_call_kind {
2215
MacroCallKind::FnLike { .. } => node,
2316
MacroCallKind::Derive { derive_attr_index, .. } => {
2417
let item = match ast::Item::cast(node.clone()) {
2518
Some(item) => item,
2619
None => return node,
2720
};
2821

29-
remove_derives_up_to(item, derive_attr_index as usize).syntax().clone()
22+
remove_derives_up_to(item, *derive_attr_index as usize).syntax().clone()
3023
}
3124
MacroCallKind::Attr { invoc_attr_index, .. } => {
3225
let item = match ast::Item::cast(node.clone()) {
3326
Some(item) => item,
3427
None => return node,
3528
};
3629

37-
remove_attr_invoc(item, invoc_attr_index as usize).syntax().clone()
30+
remove_attr_invoc(item, *invoc_attr_index as usize).syntax().clone()
3831
}
3932
}
4033
}

0 commit comments

Comments
 (0)