Skip to content

Commit

Permalink
Properly differentiate between methods and assoc fns
Browse files Browse the repository at this point in the history
  • Loading branch information
estebank committed Aug 12, 2024
1 parent 6105893 commit 110b19b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion compiler/rustc_hir_typeck/src/method/suggest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4109,8 +4109,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
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(
Expand Down
2 changes: 1 addition & 1 deletion tests/run-make/crate-loading/rmake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ note: there are multiple different versions of crate `dependency` in the depende
| ^^^^^^^^^^^^^^^ 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
|
Expand Down

0 comments on commit 110b19b

Please sign in to comment.