Skip to content

Commit 110b19b

Browse files
committed
Properly differentiate between methods and assoc fns
1 parent 6105893 commit 110b19b

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

Diff for: compiler/rustc_hir_typeck/src/method/suggest.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -4109,8 +4109,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
41094109
let trait_span = self.tcx.def_span(trait_def_id);
41104110
let mut multi_span: MultiSpan = trait_span.into();
41114111
multi_span.push_span_label(trait_span, format!("this is the trait that is needed"));
4112+
let descr = self.tcx.associated_item(item_def_id).descr();
41124113
multi_span
4113-
.push_span_label(item_span, format!("the method is available for `{rcvr_ty}` here"));
4114+
.push_span_label(item_span, format!("the {descr} is available for `{rcvr_ty}` here"));
41144115
for (def_id, import_def_id) in candidates {
41154116
if let Some(import_def_id) = import_def_id {
41164117
multi_span.push_span_label(

Diff for: tests/run-make/crate-loading/rmake.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ note: there are multiple different versions of crate `dependency` in the depende
9090
| ^^^^^^^^^^^^^^^ this is the trait that is needed
9191
5 | fn foo(&self);
9292
6 | fn bar();
93-
| --------- the method is available for `dep_2_reexport::Type` here
93+
| --------- the associated function is available for `dep_2_reexport::Type` here
9494
|
9595
::: multiple-dep-versions.rs:4:32
9696
|

0 commit comments

Comments
 (0)