9918: minor: simplify r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
This commit is contained in:
bors[bot] 2021-08-16 11:46:21 +00:00 committed by GitHub
commit 785bc57a3d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 13 deletions

View file

@ -272,7 +272,7 @@ fn macro_arg(db: &dyn AstDatabase, id: MacroCallId) -> Option<Arc<(tt::Subtree,
fn macro_arg_text(db: &dyn AstDatabase, id: MacroCallId) -> Option<GreenNode> {
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());

View file

@ -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()
}
}
}