Rollup merge of #128910 - estebank:assoc-fn, r=compiler-errors
Differentiate between methods and associated functions in diagnostics Accurately refer to assoc fn without receiver as assoc fn instead of methods. Add `AssocItem::descr` method to centralize where we call methods and associated functions.
This commit is contained in:
commit
50e9fd1a1d
27 changed files with 79 additions and 72 deletions
|
@ -1117,7 +1117,7 @@ fn check_region_bounds_on_impl_item<'tcx>(
|
|||
.dcx()
|
||||
.create_err(LifetimesOrBoundsMismatchOnTrait {
|
||||
span,
|
||||
item_kind: assoc_item_kind_str(&impl_m),
|
||||
item_kind: impl_m.descr(),
|
||||
ident: impl_m.ident(tcx),
|
||||
generics_span,
|
||||
bounds_span,
|
||||
|
@ -1294,7 +1294,7 @@ fn compare_number_of_generics<'tcx>(
|
|||
("const", trait_own_counts.consts, impl_own_counts.consts),
|
||||
];
|
||||
|
||||
let item_kind = assoc_item_kind_str(&impl_);
|
||||
let item_kind = impl_.descr();
|
||||
|
||||
let mut err_occurred = None;
|
||||
for (kind, trait_count, impl_count) in matchings {
|
||||
|
@ -1676,7 +1676,7 @@ fn compare_generic_param_kinds<'tcx>(
|
|||
param_impl_span,
|
||||
E0053,
|
||||
"{} `{}` has an incompatible generic parameter for trait `{}`",
|
||||
assoc_item_kind_str(&impl_item),
|
||||
impl_item.descr(),
|
||||
trait_item.name,
|
||||
&tcx.def_path_str(tcx.parent(trait_item.def_id))
|
||||
);
|
||||
|
@ -2249,14 +2249,6 @@ fn param_env_with_gat_bounds<'tcx>(
|
|||
ty::ParamEnv::new(tcx.mk_clauses(&predicates), Reveal::UserFacing)
|
||||
}
|
||||
|
||||
fn assoc_item_kind_str(impl_item: &ty::AssocItem) -> &'static str {
|
||||
match impl_item.kind {
|
||||
ty::AssocKind::Const => "const",
|
||||
ty::AssocKind::Fn => "method",
|
||||
ty::AssocKind::Type => "type",
|
||||
}
|
||||
}
|
||||
|
||||
/// Manually check here that `async fn foo()` wasn't matched against `fn foo()`,
|
||||
/// and extract a better error if so.
|
||||
fn try_report_async_mismatch<'tcx>(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue