aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorbors[bot] <bors[bot]@users.noreply.github.com>2019-04-24 19:58:54 +0100
committerbors[bot] <bors[bot]@users.noreply.github.com>2019-04-24 19:58:54 +0100
commit4e49dc2914492fe97eb7d65ae36c1452413af1eb (patch)
tree2e84d86869e8b0e32ad17046db5eb25af5c35418 /crates
parentb4bf2c8062af56fa5a4ed8f1ee2fcf81c7f85e3a (diff)
parent558bdf73c848eaccf3f274248981f56771c0d5ad (diff)
Merge #1203
1203: Go to Type Definition: See through references r=kjeremy a=kjeremy Co-authored-by: kjeremy <[email protected]>
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_ide_api/src/goto_type_definition.rs19
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}