@@ -891,43 +891,6 @@ fn do_autoderef(fcx: @fn_ctxt, sp: span, t: ty::t) -> ty::t {
891
891
fail;
892
892
}
893
893
894
- fn do_fn_ty_coerce ( fcx : @fn_ctxt , sp : span , actual : ty:: t , expected : ty:: t )
895
- -> ty:: t {
896
-
897
- // fns can be silently coerced to blocks when being used as
898
- // function call or bind arguments, but not the reverse.
899
- // If our actual type is a fn and our expected type is a block,
900
- // build up a new expected type that is identical to the old one
901
- // except for its proto. If we don't know the expected or actual
902
- // types, that's fine, but we can't do the coercion.
903
- ret alt structure_of_maybe ( fcx, sp, actual) {
904
- some ( ty:: ty_fn ( ast:: proto_fn. , args , ret_ty, cf, constrs) ) {
905
- alt structure_of_maybe ( fcx, sp, expected) {
906
- some ( ty:: ty_fn ( ast:: proto_block. , _, _, _, _) ) {
907
- ty:: mk_fn ( fcx. ccx . tcx , ast:: proto_block, args, ret_ty, cf,
908
- constrs)
909
- }
910
- _ { actual }
911
- }
912
- }
913
- some ( ty:: ty_fn ( ast:: proto_bare. , args , ret_ty, cf, constrs) ) {
914
- alt structure_of_maybe ( fcx, sp, expected) {
915
- some ( ty:: ty_fn ( ast:: proto_fn. , _, _, _, _) ) {
916
- ty:: mk_fn ( fcx. ccx . tcx , ast:: proto_fn, args, ret_ty, cf,
917
- constrs)
918
- }
919
- some ( ty:: ty_fn ( ast:: proto_block. , _, _, _, _) ) {
920
- ty:: mk_fn ( fcx. ccx . tcx , ast:: proto_block, args, ret_ty, cf,
921
- constrs)
922
- }
923
- _ { actual }
924
- }
925
- }
926
- _ { actual }
927
- }
928
- }
929
-
930
-
931
894
fn resolve_type_vars_if_possible ( fcx : @fn_ctxt , typ : ty:: t ) -> ty:: t {
932
895
alt ty:: unify:: fixup_vars ( fcx. ccx . tcx , none, fcx. var_bindings , typ) {
933
896
fix_ok ( new_type) { ret new_type; }
@@ -943,26 +906,19 @@ type ty_param_substs_and_ty = {substs: [ty::t], ty: ty::t};
943
906
mod demand {
944
907
fn simple ( fcx : @fn_ctxt , sp : span , expected : ty:: t , actual : ty:: t ) ->
945
908
ty:: t {
946
- full ( fcx, sp, expected, actual, [ ] , false ) . ty
947
- }
948
- fn fn_coerce ( fcx : @fn_ctxt , sp : span , expected : ty:: t , actual : ty:: t )
949
- -> ty:: t {
950
- full ( fcx, sp, expected, actual, [ ] , true ) . ty
909
+ full ( fcx, sp, expected, actual, [ ] ) . ty
951
910
}
952
911
953
912
fn with_substs ( fcx : @fn_ctxt , sp : span , expected : ty:: t , actual : ty:: t ,
954
913
ty_param_substs_0 : [ ty:: t ] ) -> ty_param_substs_and_ty {
955
- full ( fcx, sp, expected, actual, ty_param_substs_0, false )
914
+ full ( fcx, sp, expected, actual, ty_param_substs_0)
956
915
}
957
916
958
917
// Requires that the two types unify, and prints an error message if they
959
918
// don't. Returns the unified type and the type parameter substitutions.
960
919
fn full ( fcx : @fn_ctxt , sp : span , expected : ty:: t , actual : ty:: t ,
961
- ty_param_substs_0 : [ ty:: t ] , do_fn_coerce : bool ) ->
920
+ ty_param_substs_0 : [ ty:: t ] ) ->
962
921
ty_param_substs_and_ty {
963
- if do_fn_coerce {
964
- actual = do_fn_ty_coerce ( fcx, sp, actual, expected) ;
965
- }
966
922
967
923
let ty_param_substs: [ mutable ty:: t ] = [ mutable] ;
968
924
let ty_param_subst_var_ids: [ int ] = [ ] ;
@@ -1689,7 +1645,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, expr: @ast::expr, unify: unifier,
1689
1645
if is_block == check_blocks {
1690
1646
bot |=
1691
1647
check_expr_with_unifier( fcx, a,
1692
- demand : : fn_coerce ,
1648
+ demand : : simple ,
1693
1649
arg_tys[ i] . ty) ;
1694
1650
}
1695
1651
}
0 commit comments