mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-26 21:13:37 +00:00
Merge #9918
9918: minor: simplify r=matklad a=matklad
bors r+
🤖
Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
This commit is contained in:
commit
785bc57a3d
2 changed files with 6 additions and 13 deletions
|
@ -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());
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue