@@ -107,35 +107,31 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
107107 }
108108
109109 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)
118114 }
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 ) ,
124116 } ;
117+ if active_field_index. is_some ( ) {
118+ assert_eq ! ( operands. len( ) , 1 ) ;
119+ }
125120 for ( i, operand) in operands. iter ( ) . enumerate ( ) {
126121 let op = self . codegen_operand ( bx, operand) ;
127122 // Do not generate stores and GEPis for zero-sized fields.
128123 if !op. layout . is_zst ( ) {
129124 let field_index = active_field_index. unwrap_or ( i) ;
130125 let field = if let mir:: AggregateKind :: Array ( _) = * * kind {
131126 let llindex = bx. cx ( ) . const_usize ( field_index as u64 ) ;
132- dest . project_index ( bx, llindex)
127+ variant_dest . project_index ( bx, llindex)
133128 } else {
134- dest . project_field ( bx, field_index)
129+ variant_dest . project_field ( bx, field_index)
135130 } ;
136131 op. val . store ( bx, field) ;
137132 }
138133 }
134+ dest. codegen_set_discr ( bx, variant_index) ;
139135 }
140136
141137 _ => {
0 commit comments