Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/ide-assists/src/handlers/remove_unused_param.rs')
| -rw-r--r-- | crates/ide-assists/src/handlers/remove_unused_param.rs | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/crates/ide-assists/src/handlers/remove_unused_param.rs b/crates/ide-assists/src/handlers/remove_unused_param.rs index 0772b168d4..aa1002ee39 100644 --- a/crates/ide-assists/src/handlers/remove_unused_param.rs +++ b/crates/ide-assists/src/handlers/remove_unused_param.rs @@ -42,13 +42,7 @@ pub(crate) fn remove_unused_param(acc: &mut Assists, ctx: &AssistContext<'_>) -> param.syntax().parent()?.children().find_map(ast::SelfParam::cast).is_some(); // check if fn is in impl Trait for .. - if func - .syntax() - .parent() // AssocItemList - .and_then(|x| x.parent()) - .and_then(ast::Impl::cast) - .map_or(false, |imp| imp.trait_().is_some()) - { + if is_trait_impl(&func) { cov_mark::hit!(trait_impl); return None; } @@ -87,6 +81,14 @@ pub(crate) fn remove_unused_param(acc: &mut Assists, ctx: &AssistContext<'_>) -> ) } +pub(crate) fn is_trait_impl(func: &ast::Fn) -> bool { + func.syntax() + .parent() // AssocItemList + .and_then(|x| x.parent()) + .and_then(ast::Impl::cast) + .map_or(false, |imp| imp.trait_().is_some()) +} + fn process_usages( ctx: &AssistContext<'_>, builder: &mut SourceChangeBuilder, |