1203: Go to Type Definition: See through references r=kjeremy a=kjeremy



Co-authored-by: kjeremy <kjeremy@gmail.com>
This commit is contained in:
bors[bot] 2019-04-24 18:58:54 +00:00
commit 4e49dc2914

View file

@ -30,9 +30,9 @@ pub(crate) fn goto_type_definition(
return None;
};
let (adt_def, _) = ty.as_adt()?;
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))?;
let nav = NavigationTarget::from_adt_def(db, adt_def);
Some(RangeInfo::new(node.range(), vec![nav]))
}
@ -63,4 +63,19 @@ mod tests {
"Foo STRUCT_DEF FileId(1) [0; 11) [7; 10)",
);
}
#[test]
fn goto_type_definition_works_simple_ref() {
check_goto(
"
//- /lib.rs
struct Foo;
fn foo() {
let f: &Foo;
f<|>
}
",
"Foo STRUCT_DEF FileId(1) [0; 11) [7; 10)",
);
}
}