diff options
| author | bors <bors@rust-lang.org> | 2024-02-12 14:51:15 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-02-12 14:51:15 +0000 |
| commit | bdc15928c8119a86d15e2946cb54851264607842 (patch) | |
| tree | d5b51d8a541e073ba30e0d8c5803760cfdb73608 /compiler/rustc_trait_selection | |
| parent | ed195328689e052b5270b25d0e410b491914fc71 (diff) | |
| parent | 0dbd6e9572c7c2bac7922116d6cd9357177ccbc9 (diff) | |
| download | rust-bdc15928c8119a86d15e2946cb54851264607842.tar.gz rust-bdc15928c8119a86d15e2946cb54851264607842.zip | |
Auto merge of #115367 - frank-king:feature/unnamed-fields-hir, r=davidtwco
Lowering unnamed fields and anonymous adt This implements #49804. Goals: - [x] lowering anonymous ADTs from AST to HIR - [x] generating definitions of anonymous ADTs - [x] uniqueness check of the unnamed fields - [x] field projection of anonymous ADTs - [x] `#[repr(C)]` check of the anonymous ADTs Non-Goals (will be in the next PRs) - capturing generic params for the anonymous ADTs from the parent ADT - pattern matching of anonymous ADTs - structural expressions of anonymous ADTs - rustdoc support of anonymous ADTs
Diffstat (limited to 'compiler/rustc_trait_selection')
| -rw-r--r-- | compiler/rustc_trait_selection/src/traits/select/mod.rs | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/compiler/rustc_trait_selection/src/traits/select/mod.rs b/compiler/rustc_trait_selection/src/traits/select/mod.rs index ac6cfcdeb59..60453f5ab9c 100644 --- a/compiler/rustc_trait_selection/src/traits/select/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/select/mod.rs @@ -2212,6 +2212,14 @@ impl<'tcx> SelectionContext<'_, 'tcx> { // FIXME(async_closures): These are never clone, for now. ty::CoroutineClosure(_, _) => None, + // `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.non_enum_variant().fields.iter().map(|f| f.ty(self.tcx(), args)).collect(), + )) + } ty::Adt(..) | ty::Alias(..) | ty::Param(..) | ty::Placeholder(..) => { // Fallback to whatever user-defined impls exist in this case. |
