@@ -139,33 +139,30 @@ impl<'a,'tcx> Builder<'a,'tcx> {
139139 . collect ( ) ;
140140 block. and ( Rvalue :: Aggregate ( AggregateKind :: Closure ( closure_id, substs) , upvars) )
141141 }
142- ExprKind :: Adt { adt_def, variant_index, substs, fields, base } => { // see (*) above
142+ ExprKind :: Adt {
143+ adt_def, variant_index, substs, fields, base
144+ } => { // see (*) above
143145 // first process the set of fields that were provided
144146 // (evaluating them in order given by user)
145147 let fields_map: FnvHashMap < _ , _ > =
146148 fields. into_iter ( )
147149 . map ( |f| ( f. name , unpack ! ( block = this. as_operand( block, f. expr) ) ) )
148150 . collect ( ) ;
149151
150- // if base expression is given, evaluate it now
151- let base = base. map ( |base| unpack ! ( block = this. as_lvalue( block, base) ) ) ;
152-
153- // get list of all fields that we will need
154152 let field_names = this. hir . all_fields ( adt_def, variant_index) ;
155153
156- // for the actual values we use, take either the
157- // expr the user specified or, if they didn't
158- // specify something for this field name, create a
159- // path relative to the base (which must have been
160- // supplied, or the IR is internally
161- // inconsistent).
162- let fields: Vec < _ > =
154+ let fields = if let Some ( FruInfo { base, field_types } ) = base {
155+ let base = unpack ! ( block = this. as_lvalue( block, base) ) ;
163156 field_names. into_iter ( )
164- . map ( |n| match fields_map. get ( & n) {
165- Some ( v) => v. clone ( ) ,
166- None => Operand :: Consume ( base. clone ( ) . unwrap ( ) . field ( n) ) ,
167- } )
168- . collect ( ) ;
157+ . zip ( field_types. into_iter ( ) )
158+ . map ( |( n, ty) | match fields_map. get ( & n) {
159+ Some ( v) => v. clone ( ) ,
160+ None => Operand :: Consume ( base. clone ( ) . field ( n, ty) )
161+ } )
162+ . collect ( )
163+ } else {
164+ field_names. iter ( ) . map ( |n| fields_map[ n] . clone ( ) ) . collect ( )
165+ } ;
169166
170167 block. and ( Rvalue :: Aggregate ( AggregateKind :: Adt ( adt_def, variant_index, substs) ,
171168 fields) )
0 commit comments