@@ -891,7 +891,7 @@ fn do_autoderef(fcx: @fn_ctxt, sp: span, t: ty::t) -> ty::t {
891
891
fail;
892
892
}
893
893
894
- fn do_fn_block_coerce ( fcx : @fn_ctxt , sp : span , actual : ty:: t , expected : ty:: t )
894
+ fn do_fn_ty_coerce ( fcx : @fn_ctxt , sp : span , actual : ty:: t , expected : ty:: t )
895
895
-> ty:: t {
896
896
897
897
// fns can be silently coerced to blocks when being used as
@@ -910,6 +910,15 @@ fn do_fn_block_coerce(fcx: @fn_ctxt, sp: span, actual: ty::t, expected: ty::t)
910
910
_ { actual }
911
911
}
912
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
+ _ { actual }
920
+ }
921
+ }
913
922
_ { actual }
914
923
}
915
924
}
@@ -932,7 +941,7 @@ mod demand {
932
941
ty:: t {
933
942
full ( fcx, sp, expected, actual, [ ] , false ) . ty
934
943
}
935
- fn block_coerce ( fcx : @fn_ctxt , sp : span , expected : ty:: t , actual : ty:: t )
944
+ fn fn_coerce ( fcx : @fn_ctxt , sp : span , expected : ty:: t , actual : ty:: t )
936
945
-> ty:: t {
937
946
full ( fcx, sp, expected, actual, [ ] , true ) . ty
938
947
}
@@ -945,10 +954,10 @@ mod demand {
945
954
// Requires that the two types unify, and prints an error message if they
946
955
// don't. Returns the unified type and the type parameter substitutions.
947
956
fn full ( fcx : @fn_ctxt , sp : span , expected : ty:: t , actual : ty:: t ,
948
- ty_param_substs_0 : [ ty:: t ] , do_block_coerce : bool ) ->
957
+ ty_param_substs_0 : [ ty:: t ] , do_fn_coerce : bool ) ->
949
958
ty_param_substs_and_ty {
950
- if do_block_coerce {
951
- actual = do_fn_block_coerce ( fcx, sp, actual, expected) ;
959
+ if do_fn_coerce {
960
+ actual = do_fn_ty_coerce ( fcx, sp, actual, expected) ;
952
961
}
953
962
954
963
let ty_param_substs: [ mutable ty:: t ] = [ mutable] ;
@@ -1676,7 +1685,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, expr: @ast::expr, unify: unifier,
1676
1685
if is_block == check_blocks {
1677
1686
bot |=
1678
1687
check_expr_with_unifier( fcx, a,
1679
- demand : : block_coerce ,
1688
+ demand : : fn_coerce ,
1680
1689
arg_tys[ i] . ty) ;
1681
1690
}
1682
1691
}
0 commit comments