@@ -1400,20 +1400,23 @@ impl<'blk, 'tcx> FunctionContext<'blk, 'tcx> {
14001400 pub fn new ( ccx : & ' blk CrateContext < ' blk , ' tcx > ,
14011401 llfndecl : ValueRef ,
14021402 fn_ty : FnType ,
1403- def_id : Option < DefId > ,
1404- param_substs : & ' tcx Substs < ' tcx > ,
1403+ instance : Option < Instance < ' tcx > > ,
14051404 block_arena : & ' blk TypedArena < common:: BlockS < ' blk , ' tcx > > )
14061405 -> FunctionContext < ' blk , ' tcx > {
1407- common:: validate_substs ( param_substs) ;
1406+ let ( param_substs, def_id) = match instance {
1407+ Some ( instance) => {
1408+ common:: validate_substs ( instance. substs ) ;
1409+ ( instance. substs , Some ( instance. def ) )
1410+ }
1411+ None => ( ccx. tcx ( ) . mk_substs ( Substs :: empty ( ) ) , None )
1412+ } ;
14081413
14091414 let inlined_did = def_id. and_then ( |def_id| inline:: get_local_instance ( ccx, def_id) ) ;
14101415 let inlined_id = inlined_did. and_then ( |id| ccx. tcx ( ) . map . as_local_node_id ( id) ) ;
14111416 let local_id = def_id. and_then ( |id| ccx. tcx ( ) . map . as_local_node_id ( id) ) ;
14121417
1413- debug ! ( "FunctionContext::new(path={}, def_id={:?}, param_substs={:?})" ,
1414- inlined_id. map_or( String :: new( ) , |id| ccx. tcx( ) . node_path_str( id) ) ,
1415- def_id,
1416- param_substs) ;
1418+ debug ! ( "FunctionContext::new({})" ,
1419+ instance. map_or( String :: new( ) , |i| i. to_string( ) ) ) ;
14171420
14181421 let debug_context = debuginfo:: create_function_debug_context ( ccx,
14191422 inlined_id. unwrap_or ( ast:: DUMMY_NODE_ID ) , param_substs, llfndecl) ;
@@ -1810,27 +1813,25 @@ pub fn trans_closure<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
18101813 decl : & hir:: FnDecl ,
18111814 body : & hir:: Block ,
18121815 llfndecl : ValueRef ,
1813- param_substs : & ' tcx Substs < ' tcx > ,
1814- def_id : DefId ,
1816+ instance : Instance < ' tcx > ,
18151817 inlined_id : ast:: NodeId ,
18161818 fn_ty : FnType ,
18171819 abi : Abi ,
18181820 closure_env : closure:: ClosureEnv ) {
18191821 ccx. stats ( ) . n_closures . set ( ccx. stats ( ) . n_closures . get ( ) + 1 ) ;
18201822
18211823 if collector:: collecting_debug_information ( ccx) {
1822- ccx. record_translation_item_as_generated (
1823- TransItem :: Fn ( Instance :: new ( def_id, param_substs) ) ) ;
1824+ ccx. record_translation_item_as_generated ( TransItem :: Fn ( instance) ) ;
18241825 }
18251826
18261827 let _icx = push_ctxt ( "trans_closure" ) ;
18271828 attributes:: emit_uwtable ( llfndecl, true ) ;
18281829
1829- debug ! ( "trans_closure(..., param_substs={:? })" , param_substs ) ;
1830+ debug ! ( "trans_closure(..., { })" , instance ) ;
18301831
18311832 let ( arena, fcx) : ( TypedArena < _ > , FunctionContext ) ;
18321833 arena = TypedArena :: new ( ) ;
1833- fcx = FunctionContext :: new ( ccx, llfndecl, fn_ty, Some ( def_id ) , param_substs , & arena) ;
1834+ fcx = FunctionContext :: new ( ccx, llfndecl, fn_ty, Some ( instance ) , & arena) ;
18341835
18351836 if fcx. mir . is_some ( ) {
18361837 return mir:: trans_mir ( & fcx) ;
@@ -1921,8 +1922,7 @@ pub fn trans_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
19211922 decl,
19221923 body,
19231924 llfndecl,
1924- param_substs,
1925- def_id,
1925+ Instance :: new ( def_id, param_substs) ,
19261926 id,
19271927 fn_ty,
19281928 abi,
@@ -2015,9 +2015,7 @@ pub fn trans_ctor_shim<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
20152015
20162016 let ( arena, fcx) : ( TypedArena < _ > , FunctionContext ) ;
20172017 arena = TypedArena :: new ( ) ;
2018- fcx = FunctionContext :: new ( ccx, llfndecl, fn_ty,
2019- Some ( ccx. tcx ( ) . map . local_def_id ( ctor_id) ) ,
2020- param_substs, & arena) ;
2018+ fcx = FunctionContext :: new ( ccx, llfndecl, fn_ty, None , & arena) ;
20212019 let bcx = fcx. init ( false , None ) ;
20222020
20232021 assert ! ( !fcx. needs_ret_allocas) ;
0 commit comments