diff --git a/crates/ide-assists/src/handlers/auto_import.rs b/crates/ide-assists/src/handlers/auto_import.rs index e257218ba9..678dc877d1 100644 --- a/crates/ide-assists/src/handlers/auto_import.rs +++ b/crates/ide-assists/src/handlers/auto_import.rs @@ -156,6 +156,8 @@ pub(super) fn find_importable_node( { ImportAssets::for_method_call(&method_under_caret, &ctx.sema) .zip(Some(method_under_caret.syntax().clone().into())) + } else if let Some(_) = ctx.find_node_at_offset_with_descend::() { + None } else if let Some(pat) = ctx .find_node_at_offset_with_descend::() .filter(ast::IdentPat::is_simple_ident) @@ -268,6 +270,20 @@ mod tests { assert_eq!(labels, order); } + #[test] + fn ignore_parameter_name() { + check_assist_not_applicable( + auto_import, + r" + mod foo { + pub mod bar {} + } + + fn foo(bar$0: &str) {} + ", + ); + } + #[test] fn prefer_shorter_paths() { let before = r"