diff options
| author | bors <bors@rust-lang.org> | 2022-10-16 08:42:24 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-10-16 08:42:24 +0000 |
| commit | 8267966180d0ea7fbdf1c49e0054c6abc64e2efc (patch) | |
| tree | 46a6da16ce8eaf3127939445c653196500c45109 | |
| parent | 5174d3d030c3f38e7f3fea857cc8a0f59f24b219 (diff) | |
| parent | dd4d3f0a098359bd6f632caa6d7817fffec1179f (diff) | |
| download | rust-8267966180d0ea7fbdf1c49e0054c6abc64e2efc.tar.gz rust-8267966180d0ea7fbdf1c49e0054c6abc64e2efc.zip | |
Auto merge of #13420 - volsa:master, r=Veykril
fix: Ignore auto-import assist on parameter names Fixes #13105; before & after https://user-images.githubusercontent.com/29666622/195999489-0474c93a-b2bf-41c4-b7da-a4242a8082d8.mov https://user-images.githubusercontent.com/29666622/195999571-605ee09c-bc6f-4ee5-bfe4-73e37254c647.mov
| -rw-r--r-- | crates/ide-assists/src/handlers/auto_import.rs | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/crates/ide-assists/src/handlers/auto_import.rs b/crates/ide-assists/src/handlers/auto_import.rs index e257218ba93..678dc877d13 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::<ast::Param>() { + None } else if let Some(pat) = ctx .find_node_at_offset_with_descend::<ast::IdentPat>() .filter(ast::IdentPat::is_simple_ident) @@ -269,6 +271,20 @@ mod tests { } #[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" //- /main.rs crate:main deps:foo,bar |
