We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents b4bf2c8 + 558bdf7 commit 4e49dc2Copy full SHA for 4e49dc2
crates/ra_ide_api/src/goto_type_definition.rs
@@ -30,9 +30,9 @@ pub(crate) fn goto_type_definition(
30
return None;
31
};
32
33
- let (adt_def, _) = ty.as_adt()?;
34
- let nav = NavigationTarget::from_adt_def(db, adt_def);
+ let adt_def = ty.autoderef(db).find_map(|ty| ty.as_adt().map(|adt| adt.0))?;
35
+ let nav = NavigationTarget::from_adt_def(db, adt_def);
36
Some(RangeInfo::new(node.range(), vec![nav]))
37
}
38
@@ -63,4 +63,19 @@ mod tests {
63
"Foo STRUCT_DEF FileId(1) [0; 11) [7; 10)",
64
);
65
66
+
67
+ #[test]
68
+ fn goto_type_definition_works_simple_ref() {
69
+ check_goto(
70
+ "
71
+ //- /lib.rs
72
+ struct Foo;
73
+ fn foo() {
74
+ let f: &Foo;
75
+ f<|>
76
+ }
77
+ ",
78
+ "Foo STRUCT_DEF FileId(1) [0; 11) [7; 10)",
79
+ );
80
81
0 commit comments