@@ -197,12 +197,17 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
197
197
}
198
198
199
199
Aggregate ( ref kind, ref operands) => {
200
+ // active_field_index is for union initialization.
200
201
let ( dest, active_field_index) = match * * kind {
201
202
mir:: AggregateKind :: Adt ( adt_def, variant_index, _, _, active_field_index) => {
202
203
self . write_discriminant ( variant_index, & dest) ?;
203
204
if adt_def. is_enum ( ) {
204
- ( self . place_downcast ( & dest, variant_index) ?, active_field_index)
205
+ assert ! ( active_field_index. is_none( ) ) ;
206
+ ( self . place_downcast ( & dest, variant_index) ?, None )
205
207
} else {
208
+ if active_field_index. is_some ( ) {
209
+ assert_eq ! ( operands. len( ) , 1 ) ;
210
+ }
206
211
( dest, active_field_index)
207
212
}
208
213
}
@@ -211,12 +216,9 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
211
216
212
217
for ( i, operand) in operands. iter ( ) . enumerate ( ) {
213
218
let op = self . eval_operand ( operand, None ) ?;
214
- // Ignore zero-sized fields.
215
- if !op. layout . is_zst ( ) {
216
- let field_index = active_field_index. unwrap_or ( i) ;
217
- let field_dest = self . place_field ( & dest, field_index) ?;
218
- self . copy_op ( & op, & field_dest) ?;
219
- }
219
+ let field_index = active_field_index. unwrap_or ( i) ;
220
+ let field_dest = self . place_field ( & dest, field_index) ?;
221
+ self . copy_op ( & op, & field_dest) ?;
220
222
}
221
223
}
222
224
0 commit comments