Auto merge of #13713 - allanbrondum:bug/trait-method-callers, r=Veykril
check reference is a NameRef (and not Name) Fixes that implementing methods are shown in call hierarchy https://github.com/rust-lang/rust-analyzer/issues/13712
This commit is contained in:
commit
d7be2fa1a6
1 changed files with 26 additions and 1 deletions
|
|
@ -57,7 +57,8 @@ pub(crate) fn incoming_calls(
|
|||
.flat_map(|func| func.usages(sema).all());
|
||||
|
||||
for (_, references) in references {
|
||||
let references = references.into_iter().map(|FileReference { name, .. }| name);
|
||||
let references =
|
||||
references.iter().filter_map(|FileReference { name, .. }| name.as_name_ref());
|
||||
for name in references {
|
||||
// This target is the containing function
|
||||
let nav = sema.ancestors_with_macros(name.syntax().clone()).find_map(|node| {
|
||||
|
|
@ -457,4 +458,28 @@ fn caller$0() {
|
|||
expect![[]],
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_trait_method_call_hierarchy() {
|
||||
check_hierarchy(
|
||||
r#"
|
||||
trait T1 {
|
||||
fn call$0ee();
|
||||
}
|
||||
|
||||
struct S1;
|
||||
|
||||
impl T1 for S1 {
|
||||
fn callee() {}
|
||||
}
|
||||
|
||||
fn caller() {
|
||||
S1::callee();
|
||||
}
|
||||
"#,
|
||||
expect![["callee Function FileId(0) 15..27 18..24"]],
|
||||
expect![["caller Function FileId(0) 82..115 85..91 : [104..110]"]],
|
||||
expect![[]],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue