diff --git a/crates/ide_completion/src/completions/fn_param.rs b/crates/ide_completion/src/completions/fn_param.rs index bb4ce0a24d..a55bab67e1 100644 --- a/crates/ide_completion/src/completions/fn_param.rs +++ b/crates/ide_completion/src/completions/fn_param.rs @@ -83,9 +83,15 @@ fn remove_duplicated( let whole_param = param.syntax().text().to_string(); file_params.remove(&whole_param); - if let Some(pattern) = param.pat() { - let binding = pattern.syntax().text().to_string(); - file_params.retain(|_, v| v != &binding); + match param.pat() { + // remove suggestions for patterns that already exist + // if the type is missing we are checking the current param to be completed + // in which case this would find itself removing the suggestions due to itself + Some(pattern) if param.ty().is_some() => { + let binding = pattern.syntax().text().to_string(); + file_params.retain(|_, v| v != &binding); + } + _ => (), } }) } diff --git a/crates/ide_completion/src/tests/pattern.rs b/crates/ide_completion/src/tests/pattern.rs index c9a31eea84..7f437e1a07 100644 --- a/crates/ide_completion/src/tests/pattern.rs +++ b/crates/ide_completion/src/tests/pattern.rs @@ -368,3 +368,17 @@ fn foo() { "#]], ) } + +#[test] +fn completes_fully_equal() { + check_empty( + r#" +fn foo(bar: u32) {} +fn bar(bar$0) {} +"#, + expect![[r#" + bn bar: u32 + kw mut + "#]], + ) +}