@@ -328,7 +328,7 @@ pub fn at_box_body(bcx: &Block, body_t: ty::t, boxptr: ValueRef) -> ValueRef {
328328// malloc_raw_dyn: allocates a box to contain a given type, but with a
329329// potentially dynamic size.
330330pub fn malloc_raw_dyn < ' a > (
331- bcx : & ' a Block ,
331+ bcx : & ' a Block < ' a > ,
332332 t : ty:: t ,
333333 heap : heap ,
334334 size : ValueRef )
@@ -425,7 +425,7 @@ pub fn malloc_general_dyn<'a>(
425425 }
426426}
427427
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 )
429429 -> MallocResult < ' a > {
430430 let ty = type_of ( bcx. ccx ( ) , t) ;
431431 assert ! ( heap != heap_exchange) ;
@@ -1230,18 +1230,19 @@ pub fn make_return_pointer(fcx: &FunctionContext, output_type: ty::t)
12301230//
12311231// Be warned! You must call `init_function` before doing anything with the
12321232// 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 > {
12421243 for p in param_substs. iter ( ) { p. validate ( ) ; }
12431244
1244- debug ! ( "new_fn_ctxt_detailed (path={},
1245+ debug ! ( "new_fn_ctxt (path={},
12451246 id={:?}, \
12461247 param_substs={})",
12471248 path_str( ccx. sess, path) ,
@@ -1258,25 +1259,25 @@ pub fn new_fn_ctxt_detailed(ccx: @CrateContext,
12581259 let debug_context = debuginfo:: create_function_debug_context ( ccx, id, param_substs, llfndecl) ;
12591260
12601261 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 ( ~[ ] )
12801281 } ;
12811282
12821283 if has_env {
@@ -1328,18 +1329,6 @@ pub fn init_function<'a>(
13281329 }
13291330}
13301331
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-
13431332// NB: must keep 4 fns in sync:
13441333//
13451334// - type_of_fn
@@ -1411,7 +1400,8 @@ fn copy_args_to_allocas<'a>(fcx: &FunctionContext<'a>,
14111400
14121401// Ties up the llstaticallocas -> llloadenv -> lltop edges,
14131402// 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 > ) {
14151405 let _icx = push_ctxt ( "finish_fn" ) ;
14161406
14171407 let ret_cx = match fcx. llreturn . get ( ) {
@@ -1469,7 +1459,7 @@ pub fn trans_closure<'a>(ccx: @CrateContext,
14691459 id : ast:: NodeId ,
14701460 _attributes : & [ ast:: Attribute ] ,
14711461 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 > ) {
14731463 ccx. stats. n_closures. set ( ccx. stats. n_closures. get ( ) + 1 ) ;
14741464
14751465 let _icx = push_ctxt( "trans_closure" ) ;
@@ -1483,8 +1473,16 @@ pub fn trans_closure<'a>(ccx: @CrateContext,
14831473 _ => false
14841474 } ;
14851475
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) ;
14881486 init_function( & fcx, false , output_type, param_substs) ;
14891487
14901488 // cleanup scope for the incoming arguments
@@ -1626,8 +1624,16 @@ fn trans_enum_variant_or_tuple_like_struct(ccx: @CrateContext,
16261624 ty_to_str( ccx. tcx, ctor_ty) ) )
16271625 } ;
16281626
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) ;
16311637 init_function( & fcx, false , result_ty, param_substs) ;
16321638
16331639 let arg_tys = ty:: ty_fn_args ( ctor_ty ) ;
0 commit comments