about summary refs log tree commit diff
path: root/src/comp
diff options
context:
space:
mode:
authorNiko Matsakis <niko@alum.mit.edu>2012-01-11 13:24:30 -0800
committerNiko Matsakis <niko@alum.mit.edu>2012-03-02 06:47:25 -0800
commit12c68bcd6df325cc369adce018c07dfe3e2b767a (patch)
tree5f0136c67cf30df88601a837fe5559dcdddf0fb8 /src/comp
parent8478349b8be3b15d50569f55bd97ef2d62786fe4 (diff)
downloadrust-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.rs21
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);