diff options
author | Vlad Shcherbina <[email protected]> | 2020-10-14 19:22:00 +0100 |
---|---|---|
committer | Vlad Shcherbina <[email protected]> | 2020-10-14 19:22:00 +0100 |
commit | e6fbb94edde4e3f9bdc7a41df67177f1d0d16951 (patch) | |
tree | 4c07480192810e94982fa6e94c4afdb69fa77694 | |
parent | f7144dcd52c663cefc789445fe561771d935fbf0 (diff) |
Fix hover over field pattern shorthand
Instead of the information about the field, it now shows the information
about the local.
Fixes #6146
-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 | } |