diff options
| author | Michael Howell <michael@notriddle.com> | 2023-02-21 14:05:32 -0700 |
|---|---|---|
| committer | Michael Howell <michael@notriddle.com> | 2023-02-22 08:40:33 -0700 |
| commit | 3d056c31257cc26760b7e65c5dfdae069f7ddc74 (patch) | |
| tree | 05fe48fc1b2f91afbf0adbea57ca5fe9a674b923 /compiler/rustc_trait_selection/src/traits | |
| parent | 3b4d6e080404560f63599deeb328dfa27fe081a6 (diff) | |
| download | rust-3d056c31257cc26760b7e65c5dfdae069f7ddc74.tar.gz rust-3d056c31257cc26760b7e65c5dfdae069f7ddc74.zip | |
diagnostics: if AssocFn has self argument, describe as method
Discussed in https://rust-lang.zulipchat.com/#narrow/stream/147480-t-compiler.2Fwg-diagnostics/topic/.22associated.20function.22.20vs.20.22method.22/near/329265515 This commit also changes the tooltips on rustdoc intra-doc links targeting methods.
Diffstat (limited to 'compiler/rustc_trait_selection/src/traits')
| -rw-r--r-- | compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs index 824264c21d0..eb2fde09514 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs @@ -927,7 +927,10 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> { DefKind::Ctor(CtorOf::Variant, _) => { "use parentheses to construct this tuple variant".to_string() } - kind => format!("use parentheses to call this {}", kind.descr(def_id)), + kind => format!( + "use parentheses to call this {}", + self.tcx.def_kind_descr(kind, def_id) + ), }, DefIdOrName::Name(name) => format!("use parentheses to call this {name}"), }; @@ -2139,7 +2142,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> { err.note(&format!( "{}s cannot be accessed directly on a `trait`, they can only be \ accessed through a specific `impl`", - assoc_item.kind.as_def_kind().descr(item_def_id) + self.tcx.def_kind_descr(assoc_item.kind.as_def_kind(), item_def_id) )); err.span_suggestion( span, |
