diff options
Diffstat (limited to 'crates')
-rw-r--r-- | crates/ra_ide_api/src/goto_type_definition.rs | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/crates/ra_ide_api/src/goto_type_definition.rs b/crates/ra_ide_api/src/goto_type_definition.rs index de2b9d3c3..e456ec5d6 100644 --- a/crates/ra_ide_api/src/goto_type_definition.rs +++ b/crates/ra_ide_api/src/goto_type_definition.rs | |||
@@ -30,9 +30,9 @@ pub(crate) fn goto_type_definition( | |||
30 | return None; | 30 | return None; |
31 | }; | 31 | }; |
32 | 32 | ||
33 | let (adt_def, _) = ty.as_adt()?; | 33 | let adt_def = ty.autoderef(db).find_map(|ty| ty.as_adt().map(|adt| adt.0))?; |
34 | let nav = NavigationTarget::from_adt_def(db, adt_def); | ||
35 | 34 | ||
35 | let nav = NavigationTarget::from_adt_def(db, adt_def); | ||
36 | Some(RangeInfo::new(node.range(), vec![nav])) | 36 | Some(RangeInfo::new(node.range(), vec![nav])) |
37 | } | 37 | } |
38 | 38 | ||
@@ -63,4 +63,19 @@ mod tests { | |||
63 | "Foo STRUCT_DEF FileId(1) [0; 11) [7; 10)", | 63 | "Foo STRUCT_DEF FileId(1) [0; 11) [7; 10)", |
64 | ); | 64 | ); |
65 | } | 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 | } | ||
66 | } | 81 | } |