Complete reference &T -> &&T

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() []
```
This commit is contained in:
A4-Tacks
2025-12-17 16:30:01 +08:00
parent 2a402415ec
commit f8f69b2a61

View File

@@ -630,7 +630,8 @@ 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.could_unify_with(ctx.db, expected_without_ref))
&& completion_ty.autoderef(ctx.db).any(|ty| ty == *expected_without_ref)
{
cov_mark::hit!(suggest_ref);
@@ -2232,6 +2233,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]