6234: Fix hover over field pattern shorthand r=matklad a=Vlad-Shcherbina

Instead of the information about the field, it now shows the information
about the local.

Fixes #6146

Co-authored-by: Vlad Shcherbina <vlad.shcherbina@gmail.com>
This commit is contained in:
bors[bot] 2020-10-15 13:09:27 +00:00 committed by GitHub
commit 8090799aa2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -108,7 +108,7 @@ pub(crate) fn hover(
let definition = match_ast! {
match node {
ast::NameRef(name_ref) => classify_name_ref(&sema, &name_ref).map(|d| d.definition(sema.db)),
ast::Name(name) => classify_name(&sema, &name).map(|d| d.definition(sema.db)),
ast::Name(name) => classify_name(&sema, &name).and_then(|d| d.into_definition(sema.db)),
_ => None,
}
};
@ -3232,4 +3232,27 @@ pub fn new() -> Thing
"#]],
)
}
#[test]
fn hover_field_pat_shorthand_ref_match_ergonomics() {
check(
r#"
struct S {
f: i32,
}
fn main() {
let s = S { f: 0 };
let S { f<|> } = &s;
}
"#,
expect![[r#"
*f*
```rust
&i32
```
"#]],
);
}
}