Skip to content

Commit 4e49dc2

Browse files
bors[bot]kjeremy
andcommitted
Merge #1203
1203: Go to Type Definition: See through references r=kjeremy a=kjeremy Co-authored-by: kjeremy <[email protected]>
2 parents b4bf2c8 + 558bdf7 commit 4e49dc2

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

crates/ra_ide_api/src/goto_type_definition.rs

+17-2
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ pub(crate) fn goto_type_definition(
3030
return None;
3131
};
3232

33-
let (adt_def, _) = ty.as_adt()?;
34-
let nav = NavigationTarget::from_adt_def(db, adt_def);
33+
let adt_def = ty.autoderef(db).find_map(|ty| ty.as_adt().map(|adt| adt.0))?;
3534

35+
let nav = NavigationTarget::from_adt_def(db, adt_def);
3636
Some(RangeInfo::new(node.range(), vec![nav]))
3737
}
3838

@@ -63,4 +63,19 @@ mod tests {
6363
"Foo STRUCT_DEF FileId(1) [0; 11) [7; 10)",
6464
);
6565
}
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+
}
6681
}

0 commit comments

Comments
 (0)