Skip to content

Commit d7be2fa

Browse files
committed
Auto merge of rust-lang#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 rust-lang/rust-analyzer#13712
2 parents 398a71a + 30736b5 commit d7be2fa

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

crates/ide/src/call_hierarchy.rs

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ pub(crate) fn incoming_calls(
5757
.flat_map(|func| func.usages(sema).all());
5858

5959
for (_, references) in references {
60-
let references = references.into_iter().map(|FileReference { name, .. }| name);
60+
let references =
61+
references.iter().filter_map(|FileReference { name, .. }| name.as_name_ref());
6162
for name in references {
6263
// This target is the containing function
6364
let nav = sema.ancestors_with_macros(name.syntax().clone()).find_map(|node| {
@@ -457,4 +458,28 @@ fn caller$0() {
457458
expect![[]],
458459
);
459460
}
461+
462+
#[test]
463+
fn test_trait_method_call_hierarchy() {
464+
check_hierarchy(
465+
r#"
466+
trait T1 {
467+
fn call$0ee();
468+
}
469+
470+
struct S1;
471+
472+
impl T1 for S1 {
473+
fn callee() {}
474+
}
475+
476+
fn caller() {
477+
S1::callee();
478+
}
479+
"#,
480+
expect![["callee Function FileId(0) 15..27 18..24"]],
481+
expect![["caller Function FileId(0) 82..115 85..91 : [104..110]"]],
482+
expect![[]],
483+
);
484+
}
460485
}

0 commit comments

Comments
 (0)