diff --git a/src/libcore/future.rs b/src/libcore/future.rs index ba11138d9ae..e0321b45287 100644 --- a/src/libcore/future.rs +++ b/src/libcore/future.rs @@ -28,7 +28,7 @@ enum future = { }; #[doc = "Methods on the `future` type"] -impl future for future { +impl future for future { fn get() -> A { #[doc = "Get the value of the future"]; diff --git a/src/libstd/timer.rs b/src/libstd/timer.rs index 524accf6f1a..cf2c10aa998 100644 --- a/src/libstd/timer.rs +++ b/src/libstd/timer.rs @@ -20,7 +20,7 @@ for *at least* that period of time. * ch - a channel of type T to send a `val` on * val - a value of type T to send over the provided `ch` "] -fn delayed_send(msecs: uint, ch: comm::chan, val: T) { +fn delayed_send(msecs: uint, ch: comm::chan, val: T) { task::spawn() {|| unsafe { let timer_done_po = comm::port::<()>(); @@ -94,7 +94,9 @@ An `option` representing the outcome of the call. If the call `recv`'d on the provided port in the allotted timeout period, then the result will be a `some(T)`. If not, then `none` will be returned. "] -fn recv_timeout(msecs: uint, wait_po: comm::port) -> option { +fn recv_timeout(msecs: uint, wait_po: comm::port) + -> option { + let timeout_po = comm::port::<()>(); let timeout_ch = comm::chan(timeout_po); delayed_send(msecs, timeout_ch, ()); diff --git a/src/rustc/middle/kind.rs b/src/rustc/middle/kind.rs index e7c318b7da5..effa593109c 100644 --- a/src/rustc/middle/kind.rs +++ b/src/rustc/middle/kind.rs @@ -24,10 +24,12 @@ import freevars::freevar_entry; // types. fn kind_to_str(k: kind) -> str { - if k == kind_sendable() { "sendable" } - else if k == kind_copyable() { "copyable" } - else if k == kind_noncopyable() { "noncopyable" } - else { fail "unknown kind" } + alt (ty::kind_can_be_copied(k), ty::kind_can_be_sent(k)) { + (false, false) { "noncopyable" } + (false, true) { "sendable" } + (true, false) { "copyable" } + (true, true) { "copy-sendable" } + } } type rval_map = std::map::hashmap; diff --git a/src/rustc/middle/ty.rs b/src/rustc/middle/ty.rs index 998dc9d5951..52cee2fd07b 100644 --- a/src/rustc/middle/ty.rs +++ b/src/rustc/middle/ty.rs @@ -425,9 +425,9 @@ fn param_bounds_to_kind(bounds: param_bounds) -> kind { for vec::each(*bounds) {|bound| alt bound { bound_copy { - if kind != kind_sendable() { kind = kind_copyable(); } + kind = lower_kind(kind, kind_copyable()); } - bound_send { kind = kind_sendable(); } + bound_send { kind = lower_kind(kind, kind_send_only()); } _ {} } } @@ -1277,6 +1277,10 @@ fn kind_sendable() -> kind { kind_(KIND_MASK_COPY | KIND_MASK_SEND) } +fn kind_send_only() -> kind { + kind_(KIND_MASK_SEND) +} + // Using these query functons is preferable to direct comparison or matching // against the kind constants, as we may modify the kind hierarchy in the // future. @@ -1303,7 +1307,7 @@ fn kind_lteq(a: kind, b: kind) -> bool { } fn lower_kind(a: kind, b: kind) -> kind { - if kind_lteq(a, b) { a } else { b } + kind_(*a | *b) } #[test] @@ -1402,7 +1406,7 @@ fn type_kind(cx: ctxt, ty: t) -> kind { } lowest } - ty_res(did, inner, tps) { kind_noncopyable() } + ty_res(did, inner, tps) { kind_send_only() } ty_param(_, did) { param_bounds_to_kind(cx.ty_param_bounds.get(did.node)) } diff --git a/src/rustdoc/fold.rs b/src/rustdoc/fold.rs index 87b9d85637c..b4921771e04 100644 --- a/src/rustdoc/fold.rs +++ b/src/rustdoc/fold.rs @@ -85,7 +85,7 @@ fn mk_fold( }) } -fn default_any_fold(ctxt: T) -> fold { +fn default_any_fold(ctxt: T) -> fold { mk_fold( ctxt, {|f, d| default_seq_fold_doc(f, d)}, @@ -121,7 +121,7 @@ fn default_seq_fold(ctxt: T) -> fold { ) } -fn default_par_fold(ctxt: T) -> fold { +fn default_par_fold(ctxt: T) -> fold { mk_fold( ctxt, {|f, d| default_seq_fold_doc(f, d)}, diff --git a/src/test/compile-fail/kindck-nonsendable-2.rs b/src/test/compile-fail/kindck-nonsendable-2.rs deleted file mode 100644 index 3e5a501e691..00000000000 --- a/src/test/compile-fail/kindck-nonsendable-2.rs +++ /dev/null @@ -1,17 +0,0 @@ -fn foo(_x: r) {} - -resource r(_x: ()) {} - -fn main() { - let x = r(()); - let _ = fn~() { - // Error even though this is the last use: - foo(x); //! ERROR not a sendable value - }; - - let x = r(()); - let _ = fn@() { - // OK in fn@ because this is the last use: - foo(x); - }; -} \ No newline at end of file diff --git a/src/test/compile-fail/pinned-deep-copy.rs b/src/test/compile-fail/pinned-deep-copy.rs deleted file mode 100644 index 1a07b3f1de0..00000000000 --- a/src/test/compile-fail/pinned-deep-copy.rs +++ /dev/null @@ -1,16 +0,0 @@ -// error-pattern: copying a noncopyable value - -resource r(i: @mut int) { - *i = *i + 1; -} - -fn main() { - let i = @mut 0; - { - // Can't do this copy - let x = ~~~{y: r(i)}; - let z = x; - log(debug, x); - } - log(error, *i); -} \ No newline at end of file diff --git a/src/test/run-pass/alignment-gep-tup-like-2.rs b/src/test/run-pass/alignment-gep-tup-like-2.rs index 641aceb9b16..ab599a44c0b 100644 --- a/src/test/run-pass/alignment-gep-tup-like-2.rs +++ b/src/test/run-pass/alignment-gep-tup-like-2.rs @@ -13,7 +13,7 @@ fn make_cycle(a: A) { g.rec = some(g); } -fn f(a: A, b: B) -> fn@() -> (A, B) { +fn f(a: A, b: B) -> fn@() -> (A, B) { fn@() -> (A, B) { (a, b) } } diff --git a/src/test/run-pass/generic-alias-unique.rs b/src/test/run-pass/generic-alias-unique.rs index 0af9855de0d..4d2811da7b1 100644 --- a/src/test/run-pass/generic-alias-unique.rs +++ b/src/test/run-pass/generic-alias-unique.rs @@ -1,6 +1,6 @@ -fn id(t: T) -> T { ret t; } +fn id(t: T) -> T { ret t; } fn main() { let expected = ~100; diff --git a/src/test/run-pass/send-resource.rs b/src/test/run-pass/send-resource.rs new file mode 100644 index 00000000000..666f253c9a1 --- /dev/null +++ b/src/test/run-pass/send-resource.rs @@ -0,0 +1,20 @@ +import task::*; +import comm::*; + +resource test(_f: int) { + // Do nothing +} + +fn main() { + let p = port(); + let c = chan(p); + + spawn() {|| + let p = port(); + c.send(chan(p)); + + let _r = p.recv(); + } + + p.recv().send(test(42)); +} \ No newline at end of file