@@ -38,6 +38,7 @@ use metadata::{csearch, encoder, loader};
38
38
use middle:: astencode;
39
39
use middle:: cfg;
40
40
use middle:: def_id:: DefId ;
41
+ use middle:: infer;
41
42
use middle:: lang_items:: { LangItem , ExchangeMallocFnLangItem , StartFnLangItem } ;
42
43
use middle:: weak_lang_items;
43
44
use middle:: pat_util:: simple_name;
@@ -1905,7 +1906,11 @@ pub fn trans_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
1905
1906
debug ! ( "trans_fn(param_substs={:?})" , param_substs) ;
1906
1907
let _icx = push_ctxt ( "trans_fn" ) ;
1907
1908
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 ;
1909
1914
let abi = fn_ty. fn_abi ( ) ;
1910
1915
trans_closure ( ccx, decl, body, llfndecl, param_substs, id, attrs, output_type, abi,
1911
1916
closure:: ClosureEnv :: NotClosure ) ;
@@ -1936,15 +1941,9 @@ pub fn trans_named_tuple_constructor<'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
1936
1941
1937
1942
let ccx = bcx. fcx . ccx ;
1938
1943
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 ( ) ;
1948
1947
1949
1948
// Get location to store the result. If the user does not care about
1950
1949
// 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
2026
2025
let ctor_ty = ccx. tcx ( ) . node_id_to_type ( ctor_id) ;
2027
2026
let ctor_ty = monomorphize:: apply_param_substs ( ccx. tcx ( ) , param_substs, & ctor_ty) ;
2028
2027
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 ;
2038
2032
2039
2033
let ( arena, fcx) : ( TypedArena < _ > , FunctionContext ) ;
2040
2034
arena = TypedArena :: new ( ) ;
@@ -2044,8 +2038,6 @@ fn trans_enum_variant_or_tuple_like_struct<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx
2044
2038
2045
2039
assert ! ( !fcx. needs_ret_allocas) ;
2046
2040
2047
- let arg_tys = ccx. tcx ( ) . erase_late_bound_regions ( & ctor_ty. fn_args ( ) ) ;
2048
-
2049
2041
if !type_is_zero_size ( fcx. ccx , result_ty. unwrap ( ) ) {
2050
2042
let dest = fcx. get_ret_slot ( bcx, result_ty, "eret_slot" ) ;
2051
2043
let repr = adt:: represent_type ( ccx, result_ty. unwrap ( ) ) ;
0 commit comments