diff options
-rw-r--r-- | crates/ra_ide_api/src/goto_type_definition.rs | 22 |
1 files changed, 20 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..08ef4a86d 100644 --- a/crates/ra_ide_api/src/goto_type_definition.rs +++ b/crates/ra_ide_api/src/goto_type_definition.rs | |||
@@ -30,9 +30,12 @@ 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| match ty.as_adt() { |
34 | let nav = NavigationTarget::from_adt_def(db, adt_def); | 34 | Some((adt_def, _)) => Some(adt_def), |
35 | None => None, | ||
36 | })?; | ||
35 | 37 | ||
38 | let nav = NavigationTarget::from_adt_def(db, adt_def); | ||
36 | Some(RangeInfo::new(node.range(), vec![nav])) | 39 | Some(RangeInfo::new(node.range(), vec![nav])) |
37 | } | 40 | } |
38 | 41 | ||
@@ -63,4 +66,19 @@ mod tests { | |||
63 | "Foo STRUCT_DEF FileId(1) [0; 11) [7; 10)", | 66 | "Foo STRUCT_DEF FileId(1) [0; 11) [7; 10)", |
64 | ); | 67 | ); |
65 | } | 68 | } |
69 | |||
70 | #[test] | ||
71 | fn goto_type_definition_works_simple_ref() { | ||
72 | check_goto( | ||
73 | " | ||
74 | //- /lib.rs | ||
75 | struct Foo; | ||
76 | fn foo() { | ||
77 | let f: &Foo; | ||
78 | f<|> | ||
79 | } | ||
80 | ", | ||
81 | "Foo STRUCT_DEF FileId(1) [0; 11) [7; 10)", | ||
82 | ); | ||
83 | } | ||
66 | } | 84 | } |