Skip to content

Commit 8090799

Browse files
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]>
2 parents d447a9a + e6fbb94 commit 8090799

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

crates/ide/src/hover.rs

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ pub(crate) fn hover(
108108
let definition = match_ast! {
109109
match node {
110110
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)),
112112
_ => None,
113113
}
114114
};
@@ -3232,4 +3232,27 @@ fn main() { let foo_test = name_with_dashes::wrapper::Thing::new<|>(); }
32323232
"#]],
32333233
)
32343234
}
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+
}
32353258
}

0 commit comments

Comments
 (0)