@@ -137,26 +137,6 @@ fn tuplify_box_ty<'tcx>(tcx: &ty::ctxt<'tcx>, t: Ty<'tcx>) -> Ty<'tcx> {
137
137
ty:: mk_tup ( tcx, vec ! ( ty:: mk_uint( ) , ty:: mk_nil_ptr( tcx) , ptr, ptr, t) )
138
138
}
139
139
140
- fn allocate_cbox < ' blk , ' tcx > ( bcx : Block < ' blk , ' tcx > ,
141
- store : ty:: TraitStore ,
142
- cdata_ty : Ty < ' tcx > )
143
- -> Result < ' blk , ' tcx > {
144
- let _icx = push_ctxt ( "closure::allocate_cbox" ) ;
145
- let tcx = bcx. tcx ( ) ;
146
-
147
- // Allocate and initialize the box:
148
- let cbox_ty = tuplify_box_ty ( tcx, cdata_ty) ;
149
- match store {
150
- ty:: UniqTraitStore => {
151
- malloc_raw_dyn_proc ( bcx, cbox_ty)
152
- }
153
- ty:: RegionTraitStore ( ..) => {
154
- let llbox = alloc_ty ( bcx, cbox_ty, "__closure" ) ;
155
- Result :: new ( bcx, llbox)
156
- }
157
- }
158
- }
159
-
160
140
pub struct ClosureResult < ' blk , ' tcx : ' blk > {
161
141
llbox : ValueRef , // llvalue of ptr to closure
162
142
cdata_ty : Ty < ' tcx > , // type of the closure data
@@ -168,8 +148,7 @@ pub struct ClosureResult<'blk, 'tcx: 'blk> {
168
148
// heap allocated closure that copies the upvars into environment.
169
149
// Otherwise, it is stack allocated and copies pointers to the upvars.
170
150
pub fn store_environment < ' blk , ' tcx > ( bcx : Block < ' blk , ' tcx > ,
171
- bound_values : Vec < EnvValue < ' tcx > > ,
172
- store : ty:: TraitStore )
151
+ bound_values : Vec < EnvValue < ' tcx > > )
173
152
-> ClosureResult < ' blk , ' tcx > {
174
153
let _icx = push_ctxt ( "closure::store_environment" ) ;
175
154
let ccx = bcx. ccx ( ) ;
@@ -193,7 +172,7 @@ pub fn store_environment<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
193
172
}
194
173
195
174
// allocate closure in the heap
196
- let Result { bcx , val : llbox} = allocate_cbox ( bcx, store , cdata_ty ) ;
175
+ let llbox = alloc_ty ( bcx, cbox_ty , "__closure" ) ;
197
176
198
177
let llbox = PointerCast ( bcx, llbox, llboxptr_ty) ;
199
178
debug ! ( "tuplify_box_ty = {}" , ty_to_string( tcx, cbox_ty) ) ;
@@ -227,8 +206,7 @@ pub fn store_environment<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
227
206
// collects the upvars and packages them up for store_environment.
228
207
fn build_closure < ' blk , ' tcx > ( bcx0 : Block < ' blk , ' tcx > ,
229
208
freevar_mode : ast:: CaptureClause ,
230
- freevars : & Vec < ty:: Freevar > ,
231
- store : ty:: TraitStore )
209
+ freevars : & Vec < ty:: Freevar > )
232
210
-> ClosureResult < ' blk , ' tcx > {
233
211
let _icx = push_ctxt ( "closure::build_closure" ) ;
234
212
@@ -242,7 +220,7 @@ fn build_closure<'blk, 'tcx>(bcx0: Block<'blk, 'tcx>,
242
220
env_vals. push ( EnvValue { action : freevar_mode, datum : datum} ) ;
243
221
}
244
222
245
- store_environment ( bcx, env_vals, store )
223
+ store_environment ( bcx, env_vals)
246
224
}
247
225
248
226
// Given an enclosing block context, a new function context, a closure type,
@@ -456,7 +434,7 @@ pub fn trans_expr_fn<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
456
434
llbox,
457
435
cdata_ty,
458
436
bcx
459
- } = build_closure ( bcx, freevar_mode, & freevars, store ) ;
437
+ } = build_closure ( bcx, freevar_mode, & freevars) ;
460
438
461
439
trans_closure ( ccx,
462
440
decl,
0 commit comments