1
Fork 0

Rollup merge of #114146 - compiler-errors:dont-report-rpitit-name, r=spastorino

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

Doesn't really make sense to label an item that has a name that users can't really mention. Fixes #114145. Also fixes #113794.

r? `@spastorino`
This commit is contained in:
Matthias Krüger 2023-07-28 19:51:15 +02:00 committed by GitHub
commit 06eebbe6e7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 121 additions and 8 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,