@@ -328,7 +328,7 @@ pub fn at_box_body(bcx: &Block, body_t: ty::t, boxptr: ValueRef) -> ValueRef {
328
328
// malloc_raw_dyn: allocates a box to contain a given type, but with a
329
329
// potentially dynamic size.
330
330
pub fn malloc_raw_dyn < ' a > (
331
- bcx : & ' a Block ,
331
+ bcx : & ' a Block < ' a > ,
332
332
t : ty:: t ,
333
333
heap : heap ,
334
334
size : ValueRef )
@@ -425,7 +425,7 @@ pub fn malloc_general_dyn<'a>(
425
425
}
426
426
}
427
427
428
- pub fn malloc_general < ' a > ( bcx : & ' a Block , t : ty:: t , heap : heap )
428
+ pub fn malloc_general < ' a > ( bcx : & ' a Block < ' a > , t : ty:: t , heap : heap )
429
429
-> MallocResult < ' a > {
430
430
let ty = type_of ( bcx. ccx ( ) , t) ;
431
431
assert ! ( heap != heap_exchange) ;
@@ -1230,18 +1230,19 @@ pub fn make_return_pointer(fcx: &FunctionContext, output_type: ty::t)
1230
1230
//
1231
1231
// Be warned! You must call `init_function` before doing anything with the
1232
1232
// returned function context.
1233
- pub fn new_fn_ctxt_detailed ( ccx : @CrateContext ,
1234
- path : ast_map:: Path ,
1235
- llfndecl : ValueRef ,
1236
- id : ast:: NodeId ,
1237
- has_env : bool ,
1238
- output_type : ty:: t ,
1239
- param_substs : Option < @param_substs > ,
1240
- sp : Option < Span > )
1241
- -> FunctionContext {
1233
+ pub fn new_fn_ctxt < ' a > ( ccx : @CrateContext ,
1234
+ path : ast_map:: Path ,
1235
+ llfndecl : ValueRef ,
1236
+ id : ast:: NodeId ,
1237
+ has_env : bool ,
1238
+ output_type : ty:: t ,
1239
+ param_substs : Option < @param_substs > ,
1240
+ sp : Option < Span > ,
1241
+ block_arena : & ' a TypedArena < Block < ' a > > )
1242
+ -> FunctionContext < ' a > {
1242
1243
for p in param_substs. iter ( ) { p. validate ( ) ; }
1243
1244
1244
- debug ! ( "new_fn_ctxt_detailed (path={},
1245
+ debug ! ( "new_fn_ctxt (path={},
1245
1246
id={:?}, \
1246
1247
param_substs={})",
1247
1248
path_str( ccx. sess, path) ,
@@ -1258,25 +1259,25 @@ pub fn new_fn_ctxt_detailed(ccx: @CrateContext,
1258
1259
let debug_context = debuginfo:: create_function_debug_context ( ccx, id, param_substs, llfndecl) ;
1259
1260
1260
1261
let mut fcx = FunctionContext {
1261
- llfn : llfndecl,
1262
- llenv : None ,
1263
- llretptr : Cell :: new ( None ) ,
1264
- entry_bcx : RefCell :: new ( None ) ,
1265
- alloca_insert_pt : Cell :: new ( None ) ,
1266
- llreturn : Cell :: new ( None ) ,
1267
- personality : Cell :: new ( None ) ,
1268
- caller_expects_out_pointer : uses_outptr,
1269
- llargs : RefCell :: new ( HashMap :: new ( ) ) ,
1270
- lllocals : RefCell :: new ( HashMap :: new ( ) ) ,
1271
- llupvars : RefCell :: new ( HashMap :: new ( ) ) ,
1272
- id : id,
1273
- param_substs : param_substs,
1274
- span : sp,
1275
- path : path,
1276
- block_arena : TypedArena :: new ( ) ,
1277
- ccx : ccx,
1278
- debug_context : debug_context,
1279
- scopes : RefCell :: new ( ~[ ] )
1262
+ llfn : llfndecl,
1263
+ llenv : None ,
1264
+ llretptr : Cell :: new ( None ) ,
1265
+ entry_bcx : RefCell :: new ( None ) ,
1266
+ alloca_insert_pt : Cell :: new ( None ) ,
1267
+ llreturn : Cell :: new ( None ) ,
1268
+ personality : Cell :: new ( None ) ,
1269
+ caller_expects_out_pointer : uses_outptr,
1270
+ llargs : RefCell :: new ( HashMap :: new ( ) ) ,
1271
+ lllocals : RefCell :: new ( HashMap :: new ( ) ) ,
1272
+ llupvars : RefCell :: new ( HashMap :: new ( ) ) ,
1273
+ id : id,
1274
+ param_substs : param_substs,
1275
+ span : sp,
1276
+ path : path,
1277
+ block_arena : block_arena ,
1278
+ ccx : ccx,
1279
+ debug_context : debug_context,
1280
+ scopes : RefCell :: new ( ~[ ] )
1280
1281
} ;
1281
1282
1282
1283
if has_env {
@@ -1328,18 +1329,6 @@ pub fn init_function<'a>(
1328
1329
}
1329
1330
}
1330
1331
1331
- pub fn new_fn_ctxt ( ccx : @CrateContext ,
1332
- path : ast_map:: Path ,
1333
- llfndecl : ValueRef ,
1334
- has_env : bool ,
1335
- output_type : ty:: t ,
1336
- sp : Option < Span > )
1337
- -> FunctionContext {
1338
- // FIXME(#11385): Do not call `init_function` here; it will typecheck
1339
- // but segfault.
1340
- new_fn_ctxt_detailed ( ccx, path, llfndecl, -1 , has_env, output_type, None , sp)
1341
- }
1342
-
1343
1332
// NB: must keep 4 fns in sync:
1344
1333
//
1345
1334
// - type_of_fn
@@ -1411,7 +1400,8 @@ fn copy_args_to_allocas<'a>(fcx: &FunctionContext<'a>,
1411
1400
1412
1401
// Ties up the llstaticallocas -> llloadenv -> lltop edges,
1413
1402
// and builds the return block.
1414
- pub fn finish_fn ( fcx : & FunctionContext , last_bcx : & Block ) {
1403
+ pub fn finish_fn < ' a > ( fcx : & ' a FunctionContext < ' a > ,
1404
+ last_bcx : & ' a Block < ' a > ) {
1415
1405
let _icx = push_ctxt ( "finish_fn" ) ;
1416
1406
1417
1407
let ret_cx = match fcx. llreturn . get ( ) {
@@ -1469,7 +1459,7 @@ pub fn trans_closure<'a>(ccx: @CrateContext,
1469
1459
id : ast:: NodeId ,
1470
1460
_attributes : & [ ast:: Attribute ] ,
1471
1461
output_type : ty:: t ,
1472
- maybe_load_env : |& ' a Block < ' a > | -> & ' a Block < ' a > ) {
1462
+ maybe_load_env: < ' b > |& ' b Block < ' b > | -> & ' b Block < ' b > ) {
1473
1463
ccx. stats. n_closures. set ( ccx. stats. n_closures. get ( ) + 1 ) ;
1474
1464
1475
1465
let _icx = push_ctxt( "trans_closure" ) ;
@@ -1483,8 +1473,16 @@ pub fn trans_closure<'a>(ccx: @CrateContext,
1483
1473
_ => false
1484
1474
} ;
1485
1475
1486
- let fcx = new_fn_ctxt_detailed ( ccx, path, llfndecl, id, has_env, output_type,
1487
- param_substs, Some ( body. span ) ) ;
1476
+ let arena = TypedArena :: new ( ) ;
1477
+ let fcx = new_fn_ctxt( ccx,
1478
+ path,
1479
+ llfndecl,
1480
+ id,
1481
+ has_env,
1482
+ output_type,
1483
+ param_substs,
1484
+ Some ( body. span) ,
1485
+ & arena) ;
1488
1486
init_function( & fcx, false , output_type, param_substs) ;
1489
1487
1490
1488
// cleanup scope for the incoming arguments
@@ -1626,8 +1624,16 @@ fn trans_enum_variant_or_tuple_like_struct(ccx: @CrateContext,
1626
1624
ty_to_str( ccx. tcx, ctor_ty) ) )
1627
1625
} ;
1628
1626
1629
- let fcx = new_fn_ctxt_detailed ( ccx, ~[ ] , llfndecl, ctor_id, false ,
1630
- result_ty, param_substs, None ) ;
1627
+ let arena = TypedArena :: new ( ) ;
1628
+ let fcx = new_fn_ctxt( ccx,
1629
+ ~[ ] ,
1630
+ llfndecl,
1631
+ ctor_id,
1632
+ false ,
1633
+ result_ty,
1634
+ param_substs,
1635
+ None ,
1636
+ & arena) ;
1631
1637
init_function( & fcx, false , result_ty, param_substs) ;
1632
1638
1633
1639
let arg_tys = ty:: ty_fn_args ( ctor_ty ) ;
0 commit comments