@@ -98,13 +98,19 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
9898
9999 mir:: Rvalue :: Aggregate ( ref kind, ref operands) => {
100100 match * kind {
101- // Unit struct or variant; both are translated very differently compared to any
102- // other aggregate
103- mir:: AggregateKind :: Adt ( adt_def, index, _)
104- if adt_def. variants [ index] . kind ( ) == ty:: VariantKind :: Unit => {
101+ mir:: AggregateKind :: Adt ( adt_def, index, _) => {
105102 let repr = adt:: represent_type ( bcx. ccx ( ) , dest. ty . to_ty ( bcx. tcx ( ) ) ) ;
106103 let disr = adt_def. variants [ index] . disr_val ;
107104 adt:: trans_set_discr ( bcx, & * repr, dest. llval , disr) ;
105+ for ( i, operand) in operands. iter ( ) . enumerate ( ) {
106+ let op = self . trans_operand ( bcx, operand) ;
107+ // Do not generate stores and GEPis for zero-sized fields.
108+ if !common:: type_is_zero_size ( bcx. ccx ( ) , op. ty ) {
109+ let val = adt:: MaybeSizedValue :: sized ( dest. llval ) ;
110+ let lldest_i = adt:: trans_field_ptr ( bcx, & * repr, val, disr, i) ;
111+ self . store_operand ( bcx, lldest_i, op) ;
112+ }
113+ }
108114 } ,
109115 _ => {
110116 for ( i, operand) in operands. iter ( ) . enumerate ( ) {
0 commit comments