diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-10-15 14:09:27 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2020-10-15 14:09:27 +0100 |
commit | 8090799aa2f2a83746780ebdd7837e0e280c2d2c (patch) | |
tree | 34775b791df184e8a220fb5beaceaaf5e7bb0b74 /crates | |
parent | d447a9a381ecf16ea010b9953159ed533d9ba509 (diff) | |
parent | e6fbb94edde4e3f9bdc7a41df67177f1d0d16951 (diff) |
Merge #6234
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 <[email protected]>
Diffstat (limited to 'crates')
-rw-r--r-- | crates/ide/src/hover.rs | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/crates/ide/src/hover.rs b/crates/ide/src/hover.rs index 6290b35bd..632eaf0a0 100644 --- a/crates/ide/src/hover.rs +++ b/crates/ide/src/hover.rs | |||
@@ -108,7 +108,7 @@ pub(crate) fn hover( | |||
108 | let definition = match_ast! { | 108 | let definition = match_ast! { |
109 | match node { | 109 | match node { |
110 | ast::NameRef(name_ref) => classify_name_ref(&sema, &name_ref).map(|d| d.definition(sema.db)), | 110 | ast::NameRef(name_ref) => classify_name_ref(&sema, &name_ref).map(|d| d.definition(sema.db)), |
111 | ast::Name(name) => classify_name(&sema, &name).map(|d| d.definition(sema.db)), | 111 | ast::Name(name) => classify_name(&sema, &name).and_then(|d| d.into_definition(sema.db)), |
112 | _ => None, | 112 | _ => None, |
113 | } | 113 | } |
114 | }; | 114 | }; |
@@ -3232,4 +3232,27 @@ fn main() { let foo_test = name_with_dashes::wrapper::Thing::new<|>(); } | |||
3232 | "#]], | 3232 | "#]], |
3233 | ) | 3233 | ) |
3234 | } | 3234 | } |
3235 | |||
3236 | #[test] | ||
3237 | fn hover_field_pat_shorthand_ref_match_ergonomics() { | ||
3238 | check( | ||
3239 | r#" | ||
3240 | struct S { | ||
3241 | f: i32, | ||
3242 | } | ||
3243 | |||
3244 | fn main() { | ||
3245 | let s = S { f: 0 }; | ||
3246 | let S { f<|> } = &s; | ||
3247 | } | ||
3248 | "#, | ||
3249 | expect![[r#" | ||
3250 | *f* | ||
3251 | |||
3252 | ```rust | ||
3253 | &i32 | ||
3254 | ``` | ||
3255 | "#]], | ||
3256 | ); | ||
3257 | } | ||
3235 | } | 3258 | } |