mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 06:11:35 +00:00
See through references
This commit is contained in:
parent
b4bf2c8062
commit
f69bf6a12b
1 changed files with 20 additions and 2 deletions
|
@ -30,9 +30,12 @@ pub(crate) fn goto_type_definition(
|
||||||
return None;
|
return None;
|
||||||
};
|
};
|
||||||
|
|
||||||
let (adt_def, _) = ty.as_adt()?;
|
let adt_def = ty.autoderef(db).find_map(|ty| match ty.as_adt() {
|
||||||
let nav = NavigationTarget::from_adt_def(db, adt_def);
|
Some((adt_def, _)) => Some(adt_def),
|
||||||
|
None => None,
|
||||||
|
})?;
|
||||||
|
|
||||||
|
let nav = NavigationTarget::from_adt_def(db, adt_def);
|
||||||
Some(RangeInfo::new(node.range(), vec![nav]))
|
Some(RangeInfo::new(node.range(), vec![nav]))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,4 +66,19 @@ mod tests {
|
||||||
"Foo STRUCT_DEF FileId(1) [0; 11) [7; 10)",
|
"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)",
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue