diff --git a/crates/ide-completion/src/render.rs b/crates/ide-completion/src/render.rs index f2312c64945e..1f1b0fe4342a 100644 --- a/crates/ide-completion/src/render.rs +++ b/crates/ide-completion/src/render.rs @@ -630,7 +630,7 @@ fn compute_ref_match( return None; } if let Some(expected_without_ref) = &expected_without_ref - && completion_without_ref.is_none() + && (completion_without_ref.is_none() || completion_ty == expected_without_ref) && completion_ty.autoderef(ctx.db).any(|ty| ty == *expected_without_ref) { cov_mark::hit!(suggest_ref); @@ -2232,6 +2232,24 @@ fn main() { fn main() fn() [] "#]], ); + check_relevance( + r#" +struct S; +fn foo(s: &&S) {} +fn main() { + let mut ssss = &S; + foo($0); +} + "#, + expect![[r#" + st S S [] + lc ssss &S [local] + lc &ssss [type+local] + st S S [] + fn foo(…) fn(&&S) [] + fn main() fn() [] + "#]], + ); } #[test]