Rollup merge of #122123 - compiler-errors:object-trait-alias-bounds, r=oli-obk

Don't require specifying unrelated assoc types when trait alias is in `dyn` type

Object types must specify the associated types for all of the principal trait ref's supertraits. However, we weren't doing elaboration properly, so we incorrectly errored with erroneous suggestions to specify associated types that were unrelated to that principal trait ref. To fix this, use proper supertrait elaboration when expanding trait aliases in `conv_object_ty_poly_trait_ref`.

**NOTE**: Please use the ignore-whitespace option when reviewing. This only touches a handful of lines.

r? oli-obk or please feel free to reassign.

Fixes #122118
This commit is contained in:
Guillaume Gomez 2024-03-07 15:07:09 +01:00 committed by GitHub
commit bb582c6d0f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 55 additions and 50 deletions

View file

@ -127,7 +127,7 @@ impl<'tcx> TraitAliasExpander<'tcx> {
}
// Get components of trait alias.
let predicates = tcx.implied_predicates_of(trait_ref.def_id());
let predicates = tcx.super_predicates_of(trait_ref.def_id());
debug!(?predicates);
let items = predicates.predicates.iter().rev().filter_map(|(pred, span)| {