Don't require associated types with Self: Sized bounds in dyn Trait objects

This commit is contained in:
Oli Scherer 2023-06-05 15:57:21 +00:00
parent 9227ff28af
commit ca581f9161
5 changed files with 23 additions and 14 deletions

View file

@ -1131,6 +1131,16 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
}
}
for def_ids in associated_types.values_mut() {
for def_id in def_ids.clone() {
// If the associated type has a `where Self: Sized` bound, we do not need to constrain the associated
// type in the `dyn Trait`.
if tcx.generics_require_sized_self(def_id) {
def_ids.remove(&def_id);
}
}
}
self.complain_about_missing_associated_types(
associated_types,
potential_assoc_types,