@@ -166,6 +166,31 @@ impl<'tcx, 'body> ParseCtxt<'tcx, 'body> {
166166 let cast_kind = mir_cast_kind( source_ty, expr. ty) ;
167167 Ok ( Rvalue :: Cast ( cast_kind, source, expr. ty) )
168168 } ,
169+ ExprKind :: Tuple { fields } => Ok (
170+ Rvalue :: Aggregate (
171+ Box :: new( AggregateKind :: Tuple ) ,
172+ fields. iter( ) . map( |e| self . parse_operand( * e) ) . collect:: <Result <_, _>>( ) ?
173+ )
174+ ) ,
175+ ExprKind :: Array { fields } => {
176+ let elem_ty = match expr. ty. kind( ) {
177+ ty:: Array ( ty, ..) => ty,
178+ _ => unreachable!( "ty is array" ) ,
179+ } ;
180+ Ok ( Rvalue :: Aggregate (
181+ Box :: new( AggregateKind :: Array ( * elem_ty) ) ,
182+ fields. iter( ) . map( |e| self . parse_operand( * e) ) . collect:: <Result <_, _>>( ) ?
183+ ) )
184+ } ,
185+ ExprKind :: Adt ( box AdtExpr { adt_def, variant_index, substs, fields, .. } ) => {
186+ let is_union = adt_def. is_union( ) ;
187+ let active_field_index = is_union. then( || fields[ 0 ] . name. index( ) ) ;
188+
189+ Ok ( Rvalue :: Aggregate (
190+ Box :: new( AggregateKind :: Adt ( adt_def. did( ) , * variant_index, substs, None , active_field_index) ) ,
191+ fields. iter( ) . map( |f| self . parse_operand( f. expr) ) . collect:: <Result <_, _>>( ) ?
192+ ) )
193+ } ,
169194 _ => self . parse_operand( expr_id) . map( Rvalue :: Use ) ,
170195 )
171196 }
0 commit comments