Skip to content

Commit f3c2069

Browse files
committed
---
yaml --- r: 5879 b: refs/heads/master c: 342a400 h: refs/heads/master i: 5877: 29304ff 5875: c0d3d31 5871: 4b3f7ec v: v3
1 parent 66fc41c commit f3c2069

File tree

2 files changed

+5
-49
lines changed

2 files changed

+5
-49
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: 8136b92ee8e47fc460e64eb7ab65bc59f33efb71
2+
refs/heads/master: 342a400e79c44e8035b944129617734009a5abcb

trunk/src/comp/middle/typeck.rs

Lines changed: 4 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -891,43 +891,6 @@ fn do_autoderef(fcx: @fn_ctxt, sp: span, t: ty::t) -> ty::t {
891891
fail;
892892
}
893893

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-
931894
fn resolve_type_vars_if_possible(fcx: @fn_ctxt, typ: ty::t) -> ty::t {
932895
alt ty::unify::fixup_vars(fcx.ccx.tcx, none, fcx.var_bindings, typ) {
933896
fix_ok(new_type) { ret new_type; }
@@ -943,26 +906,19 @@ type ty_param_substs_and_ty = {substs: [ty::t], ty: ty::t};
943906
mod demand {
944907
fn simple(fcx: @fn_ctxt, sp: span, expected: ty::t, actual: ty::t) ->
945908
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
951910
}
952911

953912
fn with_substs(fcx: @fn_ctxt, sp: span, expected: ty::t, actual: ty::t,
954913
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)
956915
}
957916

958917
// Requires that the two types unify, and prints an error message if they
959918
// don't. Returns the unified type and the type parameter substitutions.
960919
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]) ->
962921
ty_param_substs_and_ty {
963-
if do_fn_coerce {
964-
actual = do_fn_ty_coerce(fcx, sp, actual, expected);
965-
}
966922

967923
let ty_param_substs: [mutable ty::t] = [mutable];
968924
let ty_param_subst_var_ids: [int] = [];
@@ -1689,7 +1645,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, expr: @ast::expr, unify: unifier,
16891645
if is_block == check_blocks {
16901646
bot |=
16911647
check_expr_with_unifier(fcx, a,
1692-
demand::fn_coerce,
1648+
demand::simple,
16931649
arg_tys[i].ty);
16941650
}
16951651
}

0 commit comments

Comments
 (0)