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

@@ -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()),
)
}