Unnamed repository; edit this file 'description' to name the repository.
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() []
```
| -rw-r--r-- | crates/ide-completion/src/render.rs | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/crates/ide-completion/src/render.rs b/crates/ide-completion/src/render.rs index f2312c6494..380e1e4f46 100644 --- a/crates/ide-completion/src/render.rs +++ b/crates/ide-completion/src/render.rs @@ -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] |