@@ -7,7 +7,6 @@ use either::Either;
77use rustc_middle:: mir;
88use rustc_middle:: mir:: interpret:: { InterpResult , Scalar } ;
99use rustc_middle:: ty:: layout:: LayoutOf ;
10- use rustc_target:: abi:: VariantIdx ;
1110
1211use super :: { ImmTy , InterpCx , Machine } ;
1312
@@ -200,24 +199,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
200199 }
201200
202201 Aggregate ( box ref kind, ref operands) => {
203- self . write_uninit ( & dest) ?;
204- let ( variant_index, variant_dest, active_field_index) = match * kind {
205- mir:: AggregateKind :: Adt ( _, variant_index, _, _, active_field_index) => {
206- let variant_dest = self . place_downcast ( & dest, variant_index) ?;
207- ( variant_index, variant_dest, active_field_index)
208- }
209- _ => ( VariantIdx :: from_u32 ( 0 ) , dest. clone ( ) , None ) ,
210- } ;
211- if active_field_index. is_some ( ) {
212- assert_eq ! ( operands. len( ) , 1 ) ;
213- }
214- for ( field_index, operand) in operands. iter ( ) . enumerate ( ) {
215- let field_index = active_field_index. unwrap_or ( field_index) ;
216- let field_dest = self . place_field ( & variant_dest, field_index) ?;
217- let op = self . eval_operand ( operand, Some ( field_dest. layout ) ) ?;
218- self . copy_op ( & op, & field_dest, /*allow_transmute*/ false ) ?;
219- }
220- self . write_discriminant ( variant_index, & dest) ?;
202+ self . write_aggregate ( kind, operands, & dest) ?;
221203 }
222204
223205 Repeat ( ref operand, _) => {
0 commit comments