Do not require associated types with Self: Sized to uphold bounds when confirming object candidate

This commit is contained in:
Michael Goulet 2023-09-02 05:06:21 +00:00
parent 7a6b52bf0d
commit 07fc644132
7 changed files with 54 additions and 28 deletions

View file

@ -354,9 +354,9 @@ pub(in crate::solve) fn predicates_for_object_candidate<'tcx>(
// FIXME(associated_const_equality): Also add associated consts to
// the requirements here.
if item.kind == ty::AssocKind::Type {
// RPITITs are not checked here, since they are not (currently) object-safe
// and cannot be named from a non-`Self: Sized` method.
if item.is_impl_trait_in_trait() {
// associated types that require `Self: Sized` do not show up in the built-in
// implementation of `Trait for dyn Trait`, and can be dropped here.
if tcx.generics_require_sized_self(item.def_id) {
continue;
}