@@ -107,35 +107,31 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
107
107
}
108
108
109
109
mir:: Rvalue :: Aggregate ( ref kind, ref operands) => {
110
- let ( dest, active_field_index) = match * * kind {
111
- mir:: AggregateKind :: Adt ( adt_did, variant_index, _, _, active_field_index) => {
112
- dest. codegen_set_discr ( bx, variant_index) ;
113
- if bx. tcx ( ) . adt_def ( adt_did) . is_enum ( ) {
114
- ( dest. project_downcast ( bx, variant_index) , active_field_index)
115
- } else {
116
- ( dest, active_field_index)
117
- }
110
+ let ( variant_index, variant_dest, active_field_index) = match * * kind {
111
+ mir:: AggregateKind :: Adt ( _, variant_index, _, _, active_field_index) => {
112
+ let variant_dest = dest. project_downcast ( bx, variant_index) ;
113
+ ( variant_index, variant_dest, active_field_index)
118
114
}
119
- mir:: AggregateKind :: Generator ( ..) => {
120
- dest. codegen_set_discr ( bx, VariantIdx :: from_u32 ( 0 ) ) ;
121
- ( dest, None )
122
- }
123
- _ => ( dest, None ) ,
115
+ _ => ( VariantIdx :: from_u32 ( 0 ) , dest, None ) ,
124
116
} ;
117
+ if active_field_index. is_some ( ) {
118
+ assert_eq ! ( operands. len( ) , 1 ) ;
119
+ }
125
120
for ( i, operand) in operands. iter ( ) . enumerate ( ) {
126
121
let op = self . codegen_operand ( bx, operand) ;
127
122
// Do not generate stores and GEPis for zero-sized fields.
128
123
if !op. layout . is_zst ( ) {
129
124
let field_index = active_field_index. unwrap_or ( i) ;
130
125
let field = if let mir:: AggregateKind :: Array ( _) = * * kind {
131
126
let llindex = bx. cx ( ) . const_usize ( field_index as u64 ) ;
132
- dest . project_index ( bx, llindex)
127
+ variant_dest . project_index ( bx, llindex)
133
128
} else {
134
- dest . project_field ( bx, field_index)
129
+ variant_dest . project_field ( bx, field_index)
135
130
} ;
136
131
op. val . store ( bx, field) ;
137
132
}
138
133
}
134
+ dest. codegen_set_discr ( bx, variant_index) ;
139
135
}
140
136
141
137
_ => {
0 commit comments