1
Fork 0

Skip reporting item name when checking RPITIT GAT's associated type bounds hold

This commit is contained in:
Michael Goulet 2023-07-27 22:04:19 +00:00
parent 9339f446a5
commit 0ae0643a53
3 changed files with 67 additions and 6 deletions

View file

@ -243,12 +243,18 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
}
infer::CheckAssociatedTypeBounds { impl_item_def_id, trait_item_def_id, parent } => {
let mut err = self.report_concrete_failure(*parent, sub, sup);
let trait_item_span = self.tcx.def_span(trait_item_def_id);
let item_name = self.tcx.item_name(impl_item_def_id.to_def_id());
err.span_label(
trait_item_span,
format!("definition of `{}` from trait", item_name),
);
// Don't mention the item name if it's an RPITIT, since that'll just confuse
// folks.
if !self.tcx.is_impl_trait_in_trait(impl_item_def_id.to_def_id()) {
let trait_item_span = self.tcx.def_span(trait_item_def_id);
let item_name = self.tcx.item_name(impl_item_def_id.to_def_id());
err.span_label(
trait_item_span,
format!("definition of `{}` from trait", item_name),
);
}
self.suggest_copy_trait_method_bounds(
trait_item_def_id,
impl_item_def_id,