mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-27 13:33:31 +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> {
|
fn macro_arg_text(db: &dyn AstDatabase, id: MacroCallId) -> Option<GreenNode> {
|
||||||
let loc = db.lookup_intern_macro(id);
|
let loc = db.lookup_intern_macro(id);
|
||||||
let arg = loc.kind.arg(db)?;
|
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 { .. }) {
|
if matches!(loc.kind, MacroCallKind::FnLike { .. }) {
|
||||||
let first = arg.first_child_or_token().map_or(T![.], |it| it.kind());
|
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());
|
let last = arg.last_child_or_token().map_or(T![.], |it| it.kind());
|
||||||
|
|
|
@ -6,19 +6,12 @@ use syntax::{
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
db::AstDatabase,
|
|
||||||
name::{name, AsName},
|
name::{name, AsName},
|
||||||
MacroCallId, MacroCallKind, MacroCallLoc,
|
MacroCallKind,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub(crate) fn process_macro_input(
|
pub(crate) fn process_macro_input(macro_call_kind: &MacroCallKind, node: SyntaxNode) -> SyntaxNode {
|
||||||
db: &dyn AstDatabase,
|
match macro_call_kind {
|
||||||
node: SyntaxNode,
|
|
||||||
id: MacroCallId,
|
|
||||||
) -> SyntaxNode {
|
|
||||||
let loc: MacroCallLoc = db.lookup_intern_macro(id);
|
|
||||||
|
|
||||||
match loc.kind {
|
|
||||||
MacroCallKind::FnLike { .. } => node,
|
MacroCallKind::FnLike { .. } => node,
|
||||||
MacroCallKind::Derive { derive_attr_index, .. } => {
|
MacroCallKind::Derive { derive_attr_index, .. } => {
|
||||||
let item = match ast::Item::cast(node.clone()) {
|
let item = match ast::Item::cast(node.clone()) {
|
||||||
|
@ -26,7 +19,7 @@ pub(crate) fn process_macro_input(
|
||||||
None => return node,
|
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, .. } => {
|
MacroCallKind::Attr { invoc_attr_index, .. } => {
|
||||||
let item = match ast::Item::cast(node.clone()) {
|
let item = match ast::Item::cast(node.clone()) {
|
||||||
|
@ -34,7 +27,7 @@ pub(crate) fn process_macro_input(
|
||||||
None => return node,
|
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