From 110b19b2b6a9896d4d73b8bd8b735fa9c2503d1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Mon, 12 Aug 2024 19:45:20 +0000 Subject: [PATCH] Properly differentiate between methods and assoc fns --- compiler/rustc_hir_typeck/src/method/suggest.rs | 3 ++- tests/run-make/crate-loading/rmake.rs | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_hir_typeck/src/method/suggest.rs b/compiler/rustc_hir_typeck/src/method/suggest.rs index 31366a30760..ab13b31439c 100644 --- a/compiler/rustc_hir_typeck/src/method/suggest.rs +++ b/compiler/rustc_hir_typeck/src/method/suggest.rs @@ -4109,8 +4109,9 @@ fn detect_and_explain_multiple_crate_versions( let trait_span = self.tcx.def_span(trait_def_id); let mut multi_span: MultiSpan = trait_span.into(); multi_span.push_span_label(trait_span, format!("this is the trait that is needed")); + let descr = self.tcx.associated_item(item_def_id).descr(); multi_span - .push_span_label(item_span, format!("the method is available for `{rcvr_ty}` here")); + .push_span_label(item_span, format!("the {descr} is available for `{rcvr_ty}` here")); for (def_id, import_def_id) in candidates { if let Some(import_def_id) = import_def_id { multi_span.push_span_label( diff --git a/tests/run-make/crate-loading/rmake.rs b/tests/run-make/crate-loading/rmake.rs index 65cbc8b0b1b..13585edf6cc 100644 --- a/tests/run-make/crate-loading/rmake.rs +++ b/tests/run-make/crate-loading/rmake.rs @@ -90,7 +90,7 @@ fn main() { | ^^^^^^^^^^^^^^^ this is the trait that is needed 5 | fn foo(&self); 6 | fn bar(); - | --------- the method is available for `dep_2_reexport::Type` here + | --------- the associated function is available for `dep_2_reexport::Type` here | ::: multiple-dep-versions.rs:4:32 |