Skip to content

Commit d122369

Browse files
Merge pull request rust-lang#21289 from A4-Tacks/add-ref-matched-type
Complete reference `&T` -> `&&T`
2 parents 0b1740b + 33585ad commit d122369

File tree

1 file changed

+20
-1
lines changed
  • src/tools/rust-analyzer/crates/ide-completion/src

1 file changed

+20
-1
lines changed

src/tools/rust-analyzer/crates/ide-completion/src/render.rs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -630,7 +630,8 @@ fn compute_ref_match(
630630
return None;
631631
}
632632
if let Some(expected_without_ref) = &expected_without_ref
633-
&& completion_without_ref.is_none()
633+
&& (completion_without_ref.is_none()
634+
|| completion_ty.could_unify_with(ctx.db, expected_without_ref))
634635
&& completion_ty.autoderef(ctx.db).any(|ty| ty == *expected_without_ref)
635636
{
636637
cov_mark::hit!(suggest_ref);
@@ -2232,6 +2233,24 @@ fn main() {
22322233
fn main() fn() []
22332234
"#]],
22342235
);
2236+
check_relevance(
2237+
r#"
2238+
struct S;
2239+
fn foo(s: &&S) {}
2240+
fn main() {
2241+
let mut ssss = &S;
2242+
foo($0);
2243+
}
2244+
"#,
2245+
expect![[r#"
2246+
st S S []
2247+
lc ssss &S [local]
2248+
lc &ssss [type+local]
2249+
st S S []
2250+
fn foo(…) fn(&&S) []
2251+
fn main() fn() []
2252+
"#]],
2253+
);
22352254
}
22362255

22372256
#[test]

0 commit comments

Comments
 (0)