Skip to content

Commit

Permalink
fix rust-lang#13105: Ignore auto-import assist on parameter names
Browse files Browse the repository at this point in the history
  • Loading branch information
volsa committed Oct 15, 2022
1 parent 5174d3d commit dd4d3f0
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions crates/ide-assists/src/handlers/auto_import.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit dd4d3f0

Please sign in to comment.