mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2026-04-17 21:24:52 +00:00
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:
@@ -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]
|
||||
|
||||
Reference in New Issue
Block a user