1
Fork 0

Lowering field access for anonymous adts

This commit is contained in:
Frank King 2024-01-04 21:45:06 +08:00
parent 36d7e7fd3f
commit 0c0df4efe0
18 changed files with 391 additions and 71 deletions

View file

@ -183,7 +183,7 @@ pub(in crate::solve) fn instantiate_constituent_tys_for_copy_clone_trait<'tcx>(
// Check for anonymous adts.
ty::Adt(adt, generics) if adt.is_anonymous() => {
Ok(adt.all_fields().map(|f| f.ty(ecx.tcx(), generics)).collect())
Ok(adt.non_enum_variant().fields.iter().map(|f| f.ty(ecx.tcx(), generics)).collect())
}
ty::Dynamic(..)

View file

@ -2212,14 +2212,14 @@ impl<'tcx> SelectionContext<'_, 'tcx> {
// FIXME(async_closures): These are never clone, for now.
ty::CoroutineClosure(_, _) => None,
// `Copy` and `Clone` are automatically impelemented for an anonymous adt
// `Copy` and `Clone` are automatically implemented for an anonymous adt
// if all of its fields are `Copy` and `Clone`
ty::Adt(adt, args) if adt.is_anonymous() => {
// (*) binder moved here
Where(
obligation
.predicate
.rebind(adt.all_fields().map(|f| f.ty(self.tcx(), args)).collect()),
.rebind(adt.non_enum_variant().fields.iter().map(|f| f.ty(self.tcx(), args)).collect()),
)
}