From dc15b9b97bd34f0c2634e00a5c4df605ea01c27e Mon Sep 17 00:00:00 2001 From: A4-Tacks Date: Wed, 17 Dec 2025 16:30:01 +0800 Subject: [PATCH] Complete reference `&T` -> `&&T` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Example --- ```rust struct S; fn foo(s: &&S) {} fn main() { let mut ssss = &S; foo($0); } ``` **Before this PR** ```rust st S S [] lc ssss &S [local] st S S [] fn foo(…) fn(&&S) [] fn main() fn() [] ``` **After this PR** ```rust st S S [] lc ssss &S [local] lc &ssss [type+local] st S S [] fn foo(…) fn(&&S) [] fn main() fn() [] ``` --- crates/ide-completion/src/render.rs | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) 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]