]> git.lizzy.rs Git - rust.git/commitdiff
sendable functions now "work", meaning pass through trans/typestate
authorNiko Matsakis <niko@alum.mit.edu>
Sat, 10 Dec 2011 03:12:03 +0000 (19:12 -0800)
committerNiko Matsakis <niko@alum.mit.edu>
Wed, 14 Dec 2011 22:32:19 +0000 (14:32 -0800)
but they do not generate correct code

src/comp/middle/resolve.rs
src/comp/middle/trans.rs

index 1fe94a14345620e7be4fc24fe7d6a186771d8366..b898a73b3be6da9e69cdb79e7ff1390826a038a0 100644 (file)
@@ -678,9 +678,14 @@ fn scope_is_fn(sc: scope) -> bool {
         };
 }
 
+// Returns:
+//   none - does not close
+//   some(true) - closes and permits mutation
+//   some(false) - closes but no mutation
 fn scope_closes(sc: scope) -> option::t<bool> {
     alt sc {
       scope_fn(_, ast::proto_block., _) { some(true) }
+      scope_fn(_, ast::proto_send., _) { some(false) }
       scope_fn(_, ast::proto_shared(_), _) { some(false) }
       _ { none }
     }
index 0654b6da6994ebdfca5309d39e3b9bfb7e54443d..8f2f79a9dc3381e9978de18555c7f4e4f3420fdb 100644 (file)
@@ -2192,7 +2192,7 @@ fn trans_expr_fn(bcx: @block_ctxt, f: ast::_fn, sp: span,
                || f.proto == ast::proto_shared(ast::sugar_sexy);
     let env;
     alt f.proto {
-      ast::proto_block. | ast::proto_shared(_) {
+      ast::proto_block. | ast::proto_shared(_) | ast::proto_send. {
         let upvars = get_freevars(ccx.tcx, id);
         let env_r = build_closure(bcx, upvars, copying);
         env = env_r.ptr;
@@ -2201,7 +2201,7 @@ fn trans_expr_fn(bcx: @block_ctxt, f: ast::_fn, sp: span,
             load_environment(bcx, fcx, env_r.ptrty, upvars, copying);
         });
       }
-      _ {
+      ast::proto_bare. {
         env = C_null(T_opaque_closure_ptr(ccx));
         trans_closure(sub_cx, sp, f, llfn, none, [], id, {|_fcx|});
       }