@@ -38,6 +38,7 @@ use metadata::{csearch, encoder, loader};
3838use middle:: astencode;
3939use middle:: cfg;
4040use middle:: def_id:: DefId ;
41+ use middle:: infer;
4142use middle:: lang_items:: { LangItem , ExchangeMallocFnLangItem , StartFnLangItem } ;
4243use middle:: weak_lang_items;
4344use middle:: pat_util:: simple_name;
@@ -1905,7 +1906,11 @@ pub fn trans_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
19051906 debug ! ( "trans_fn(param_substs={:?})" , param_substs) ;
19061907 let _icx = push_ctxt ( "trans_fn" ) ;
19071908 let fn_ty = ccx. tcx ( ) . node_id_to_type ( id) ;
1908- let output_type = ccx. tcx ( ) . erase_late_bound_regions ( & fn_ty. fn_ret ( ) ) ;
1909+ let fn_ty = monomorphize:: apply_param_substs ( ccx. tcx ( ) , param_substs, & fn_ty) ;
1910+ let sig = fn_ty. fn_sig ( ) ;
1911+ let sig = ccx. tcx ( ) . erase_late_bound_regions ( & sig) ;
1912+ let sig = infer:: normalize_associated_type ( ccx. tcx ( ) , & sig) ;
1913+ let output_type = sig. output ;
19091914 let abi = fn_ty. fn_abi ( ) ;
19101915 trans_closure ( ccx, decl, body, llfndecl, param_substs, id, attrs, output_type, abi,
19111916 closure:: ClosureEnv :: NotClosure ) ;
@@ -1936,15 +1941,9 @@ pub fn trans_named_tuple_constructor<'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
19361941
19371942 let ccx = bcx. fcx . ccx ;
19381943
1939- let result_ty = match ctor_ty. sty {
1940- ty:: TyBareFn ( _, ref bft) => {
1941- bcx. tcx ( ) . erase_late_bound_regions ( & bft. sig . output ( ) ) . unwrap ( )
1942- }
1943- _ => ccx. sess ( ) . bug (
1944- & format ! ( "trans_enum_variant_constructor: \
1945- unexpected ctor return type {}",
1946- ctor_ty) )
1947- } ;
1944+ let sig = ccx. tcx ( ) . erase_late_bound_regions ( & ctor_ty. fn_sig ( ) ) ;
1945+ let sig = infer:: normalize_associated_type ( ccx. tcx ( ) , & sig) ;
1946+ let result_ty = sig. output . unwrap ( ) ;
19481947
19491948 // Get location to store the result. If the user does not care about
19501949 // the result, just make a stack slot
@@ -2026,15 +2025,10 @@ fn trans_enum_variant_or_tuple_like_struct<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx
20262025 let ctor_ty = ccx. tcx ( ) . node_id_to_type ( ctor_id) ;
20272026 let ctor_ty = monomorphize:: apply_param_substs ( ccx. tcx ( ) , param_substs, & ctor_ty) ;
20282027
2029- let result_ty = match ctor_ty. sty {
2030- ty:: TyBareFn ( _, ref bft) => {
2031- ccx. tcx ( ) . erase_late_bound_regions ( & bft. sig . output ( ) )
2032- }
2033- _ => ccx. sess ( ) . bug (
2034- & format ! ( "trans_enum_variant_or_tuple_like_struct: \
2035- unexpected ctor return type {}",
2036- ctor_ty) )
2037- } ;
2028+ let sig = ccx. tcx ( ) . erase_late_bound_regions ( & ctor_ty. fn_sig ( ) ) ;
2029+ let sig = infer:: normalize_associated_type ( ccx. tcx ( ) , & sig) ;
2030+ let arg_tys = sig. inputs ;
2031+ let result_ty = sig. output ;
20382032
20392033 let ( arena, fcx) : ( TypedArena < _ > , FunctionContext ) ;
20402034 arena = TypedArena :: new ( ) ;
@@ -2044,8 +2038,6 @@ fn trans_enum_variant_or_tuple_like_struct<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx
20442038
20452039 assert ! ( !fcx. needs_ret_allocas) ;
20462040
2047- let arg_tys = ccx. tcx ( ) . erase_late_bound_regions ( & ctor_ty. fn_args ( ) ) ;
2048-
20492041 if !type_is_zero_size ( fcx. ccx , result_ty. unwrap ( ) ) {
20502042 let dest = fcx. get_ret_slot ( bcx, result_ty, "eret_slot" ) ;
20512043 let repr = adt:: represent_type ( ccx, result_ty. unwrap ( ) ) ;
0 commit comments