diff options
| author | Niko Matsakis <niko@alum.mit.edu> | 2012-01-11 13:24:30 -0800 |
|---|---|---|
| committer | Niko Matsakis <niko@alum.mit.edu> | 2012-03-02 06:47:25 -0800 |
| commit | 12c68bcd6df325cc369adce018c07dfe3e2b767a (patch) | |
| tree | 5f0136c67cf30df88601a837fe5559dcdddf0fb8 /src/comp | |
| parent | 8478349b8be3b15d50569f55bd97ef2d62786fe4 (diff) | |
| download | rust-12c68bcd6df325cc369adce018c07dfe3e2b767a.tar.gz rust-12c68bcd6df325cc369adce018c07dfe3e2b767a.zip | |
make sure we do not bind unique closures (or blocks, for that matter)
Diffstat (limited to 'src/comp')
| -rw-r--r-- | src/comp/middle/typeck.rs | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/src/comp/middle/typeck.rs b/src/comp/middle/typeck.rs index 40cd1d37a8d..e1c56b9fc54 100644 --- a/src/comp/middle/typeck.rs +++ b/src/comp/middle/typeck.rs @@ -2394,6 +2394,16 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, expr: @ast::expr, unify: unifier, _ { fail "LHS of bind expr didn't have a function type?!"; } } + let proto = alt proto { + ast::proto_bare | ast::proto_box { ast::proto_box } + ast::proto_uniq | ast::proto_any | ast::proto_block { + tcx.sess.span_err(expr.span, + #fmt["cannot bind %s closures", + proto_to_str(proto)]); + proto // dummy value so compilation can proceed + } + }; + // For each blank argument, add the type of that argument // to the resulting function type. let out_args = []; @@ -2406,16 +2416,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, expr: @ast::expr, unify: unifier, i += 1u; } - // Determine what fn prototype results from binding - fn lower_bound_proto(proto: ast::proto) -> ast::proto { - // FIXME: This is right for bare fns, possibly not others - alt proto { - ast::proto_bare { ast::proto_box } - _ { proto } - } - } - - let ft = ty::mk_fn(tcx, {proto: lower_bound_proto(proto), + let ft = ty::mk_fn(tcx, {proto: proto, inputs: out_args, output: rt, ret_style: cf, constraints: constrs}); write_ty(tcx, id, ft); |
