]> git.lizzy.rs Git - rust.git/commitdiff
Mostly rote conversion of `proc()` to `move||` (and occasionally `Thunk::new`)
authorNiko Matsakis <niko@alum.mit.edu>
Wed, 26 Nov 2014 13:12:18 +0000 (08:12 -0500)
committerNiko Matsakis <niko@alum.mit.edu>
Sun, 14 Dec 2014 09:21:56 +0000 (04:21 -0500)
208 files changed:
src/compiletest/compiletest.rs
src/compiletest/runtest.rs
src/doc/guide-tasks.md
src/doc/rustdoc.md
src/liballoc/arc.rs
src/libcollections/dlist.rs
src/libflate/lib.rs
src/liblog/lib.rs
src/librustc_driver/lib.rs
src/librustc_typeck/check/mod.rs
src/librustdoc/lib.rs
src/librustdoc/test.rs
src/librustrt/c_str.rs
src/librustrt/exclusive.rs
src/librustrt/local.rs
src/librustrt/mutex.rs
src/libstd/c_vec.rs
src/libstd/comm/mod.rs
src/libstd/comm/mpsc_queue.rs
src/libstd/comm/select.rs
src/libstd/comm/spsc_queue.rs
src/libstd/io/comm_adapters.rs
src/libstd/io/mod.rs
src/libstd/io/net/pipe.rs
src/libstd/io/net/tcp.rs
src/libstd/io/net/udp.rs
src/libstd/io/pipe.rs
src/libstd/io/process.rs
src/libstd/io/stdio.rs
src/libstd/io/timer.rs
src/libstd/macros.rs
src/libstd/path/posix.rs
src/libstd/path/windows.rs
src/libstd/rand/os.rs
src/libstd/sync/atomic.rs
src/libstd/sync/barrier.rs
src/libstd/sync/condvar.rs
src/libstd/sync/mutex.rs
src/libstd/sync/once.rs
src/libstd/sync/rwlock.rs
src/libstd/sync/semaphore.rs
src/libstd/sync/task_pool.rs
src/libstd/sys/common/helper_thread.rs
src/libstd/sys/unix/process.rs
src/libstd/sys/windows/thread_local.rs
src/libstd/thread_local/mod.rs
src/libtest/lib.rs
src/test/auxiliary/cci_capture_clause.rs
src/test/bench/msgsend-pipes-shared.rs
src/test/bench/msgsend-pipes.rs
src/test/bench/msgsend-ring-mutex-arcs.rs
src/test/bench/rt-messaging-ping-pong.rs
src/test/bench/rt-parfib.rs
src/test/bench/shootout-binarytrees.rs
src/test/bench/shootout-chameneos-redux.rs
src/test/bench/shootout-fannkuch-redux.rs
src/test/bench/shootout-k-nucleotide-pipes.rs
src/test/bench/shootout-k-nucleotide.rs
src/test/bench/shootout-mandelbrot.rs
src/test/bench/shootout-meteor.rs
src/test/bench/shootout-pfib.rs
src/test/bench/shootout-regex-dna.rs
src/test/bench/shootout-reverse-complement.rs
src/test/bench/shootout-spectralnorm.rs
src/test/bench/shootout-threadring.rs
src/test/bench/spawnone.rs
src/test/bench/task-perf-alloc-unwind.rs
src/test/bench/task-perf-jargon-metal-smoke.rs
src/test/bench/task-perf-one-million.rs
src/test/bench/task-perf-spawnalot.rs
src/test/compile-fail/borrowck-loan-blocks-move-cc.rs
src/test/compile-fail/borrowck-move-by-capture.rs
src/test/compile-fail/borrowck-move-moved-value-into-closure.rs
src/test/compile-fail/borrowck-multiple-captures.rs
src/test/compile-fail/cannot-mutate-captured-non-mut-var.rs
src/test/compile-fail/coerce-bare-fn-to-closure-and-proc.rs
src/test/compile-fail/issue-10398.rs
src/test/compile-fail/issue-11515.rs
src/test/compile-fail/issue-11925.rs
src/test/compile-fail/issue-12041.rs
src/test/compile-fail/issue-12127.rs
src/test/compile-fail/kindck-nonsendable-1.rs
src/test/compile-fail/kindck-send-object.rs
src/test/compile-fail/kindck-send-object1.rs
src/test/compile-fail/moves-based-on-type-capture-clause-bad.rs
src/test/compile-fail/moves-sru-moved-field.rs
src/test/compile-fail/no-capture-arc.rs
src/test/compile-fail/no-reuse-move-arc.rs
src/test/compile-fail/no-send-res-ports.rs
src/test/compile-fail/once-cant-call-twice-on-heap.rs
src/test/compile-fail/regions-bounded-by-send.rs
src/test/compile-fail/regions-infer-proc-static-upvar.rs
src/test/compile-fail/regions-infer-region-in-fn-but-not-type.rs [deleted file]
src/test/compile-fail/regions-proc-bound-capture.rs
src/test/compile-fail/spawn-non-nil-fn.rs
src/test/compile-fail/unboxed-closure-feature-gate.rs [new file with mode: 0644]
src/test/compile-fail/unboxed-closures-static-call-wrong-trait.rs
src/test/compile-fail/unused-mut-warning-captured-var.rs
src/test/debuginfo/lexical-scope-in-unique-closure.rs
src/test/debuginfo/type-names.rs
src/test/pretty/closure-reform-pretty.rs
src/test/pretty/fn-types.rs
src/test/run-fail/extern-panic.rs
src/test/run-fail/panic-task-name-none.rs
src/test/run-fail/panic-task-name-owned.rs
src/test/run-fail/panic-task-name-send-str.rs
src/test/run-fail/panic-task-name-static.rs
src/test/run-fail/rt-set-exit-status-panic2.rs
src/test/run-make/bootstrap-from-c-with-native/lib.rs
src/test/run-make/static-unwinding/main.rs
src/test/run-pass/block-arg-call-as.rs
src/test/run-pass/block-arg.rs
src/test/run-pass/borrowck-move-by-capture-ok.rs
src/test/run-pass/capturing-logging.rs
src/test/run-pass/child-outlives-parent.rs
src/test/run-pass/clone-with-exterior.rs
src/test/run-pass/closure-bounds-can-capture-chan.rs
src/test/run-pass/closure-reform.rs
src/test/run-pass/closure-syntax.rs
src/test/run-pass/coerce-to-closure-and-proc.rs
src/test/run-pass/comm.rs
src/test/run-pass/core-run-destroy.rs
src/test/run-pass/drop-trait-enum.rs
src/test/run-pass/enum-null-pointer-opt.rs
src/test/run-pass/explicit-self-generic.rs
src/test/run-pass/extern-call-deep2.rs
src/test/run-pass/extern-call-scrub.rs
src/test/run-pass/extern-stress.rs
src/test/run-pass/extern-yield.rs
src/test/run-pass/foreign-call-no-runtime.rs
src/test/run-pass/hashmap-memory.rs
src/test/run-pass/hrtb-parse.rs
src/test/run-pass/infinite-loops.rs
src/test/run-pass/issue-10682.rs
src/test/run-pass/issue-10718.rs
src/test/run-pass/issue-11709.rs
src/test/run-pass/issue-11958.rs
src/test/run-pass/issue-12684.rs
src/test/run-pass/issue-13352.rs
src/test/run-pass/issue-13494.rs
src/test/run-pass/issue-14039.rs
src/test/run-pass/issue-15571.rs
src/test/run-pass/issue-16560.rs
src/test/run-pass/issue-16671.rs
src/test/run-pass/issue-2190-1.rs
src/test/run-pass/issue-3424.rs
src/test/run-pass/issue-3609.rs
src/test/run-pass/issue-4446.rs
src/test/run-pass/issue-4448.rs
src/test/run-pass/issue-8460.rs
src/test/run-pass/issue-8827.rs
src/test/run-pass/issue-9396.rs
src/test/run-pass/ivec-tag.rs
src/test/run-pass/kindck-implicit-close-over-mut-var.rs
src/test/run-pass/logging-only-prints-once.rs
src/test/run-pass/macro-with-braces-in-expr-position.rs
src/test/run-pass/moves-based-on-type-capture-clause.rs
src/test/run-pass/newlambdas-ret-infer.rs
src/test/run-pass/newlambdas-ret-infer2.rs
src/test/run-pass/no-landing-pads.rs
src/test/run-pass/once-move-out-on-heap.rs
src/test/run-pass/operator-overloading.rs
src/test/run-pass/out-of-stack-new-thread-no-split.rs
src/test/run-pass/panic-in-dtor-drops-fields.rs
src/test/run-pass/preempt.rs
src/test/run-pass/regions-infer-region-in-fn-but-not-type.rs [new file with mode: 0644]
src/test/run-pass/regions-infer-static-from-proc.rs
src/test/run-pass/return-from-closure.rs
src/test/run-pass/running-with-no-runtime.rs
src/test/run-pass/rust-log-filter.rs
src/test/run-pass/send-resource.rs
src/test/run-pass/sendfn-spawn-with-fn-arg.rs
src/test/run-pass/sepcomp-unwind.rs
src/test/run-pass/slice-panic-1.rs
src/test/run-pass/slice-panic-2.rs
src/test/run-pass/spawn-fn.rs
src/test/run-pass/spawn-types.rs
src/test/run-pass/spawn.rs
src/test/run-pass/spawn2.rs
src/test/run-pass/spawning-with-debug.rs
src/test/run-pass/swap-overlapping.rs
src/test/run-pass/task-comm-0.rs
src/test/run-pass/task-comm-1.rs
src/test/run-pass/task-comm-10.rs
src/test/run-pass/task-comm-11.rs
src/test/run-pass/task-comm-12.rs
src/test/run-pass/task-comm-13.rs
src/test/run-pass/task-comm-14.rs
src/test/run-pass/task-comm-15.rs
src/test/run-pass/task-comm-17.rs
src/test/run-pass/task-comm-3.rs
src/test/run-pass/task-comm-7.rs
src/test/run-pass/task-comm-9.rs
src/test/run-pass/task-life-0.rs
src/test/run-pass/task-spawn-move-and-copy.rs
src/test/run-pass/task-stderr.rs
src/test/run-pass/tcp-accept-stress.rs
src/test/run-pass/tcp-connect-timeouts.rs
src/test/run-pass/tcp-stress.rs
src/test/run-pass/tempfile.rs
src/test/run-pass/terminate-in-initializer.rs
src/test/run-pass/threads.rs
src/test/run-pass/trait-bounds-in-arc.rs
src/test/run-pass/unique-send-2.rs
src/test/run-pass/unit-like-struct-drop-run.rs
src/test/run-pass/unwind-resource.rs
src/test/run-pass/vector-sort-panic-safe.rs
src/test/run-pass/weak-lang-item.rs

index 47ab675aff9347f95e99d1e7a2ce80a31abf940d..196c38215f463e3a865b9e8ee2bc4274b5a60f60 100644 (file)
@@ -9,7 +9,7 @@
 // except according to those terms.
 
 #![crate_type = "bin"]
-#![feature(phase, slicing_syntax, globs)]
+#![feature(phase, slicing_syntax, globs, unboxed_closures)]
 
 #![deny(warnings)]
 
@@ -23,6 +23,7 @@
 use std::io;
 use std::io::fs;
 use std::str::FromStr;
+use std::thunk::{Thunk};
 use getopts::{optopt, optflag, reqopt};
 use common::Config;
 use common::{Pretty, DebugInfoGdb, DebugInfoLldb, Codegen};
@@ -369,16 +370,16 @@ pub fn make_test_closure(config: &Config, testfile: &Path) -> test::TestFn {
     let config = (*config).clone();
     // FIXME (#9639): This needs to handle non-utf8 paths
     let testfile = testfile.as_str().unwrap().to_string();
-    test::DynTestFn(proc() {
+    test::DynTestFn(Thunk::new(move || {
         runtest::run(config, testfile)
-    })
+    }))
 }
 
 pub fn make_metrics_test_closure(config: &Config, testfile: &Path) -> test::TestFn {
     let config = (*config).clone();
     // FIXME (#9639): This needs to handle non-utf8 paths
     let testfile = testfile.as_str().unwrap().to_string();
-    test::DynMetricFn(proc(mm) {
+    test::DynMetricFn(box move |: mm: &mut test::MetricMap| {
         runtest::run_metrics(config, testfile, mm)
     })
 }
index 5c3e5e12adbcbc325db0c88f490b67b56e4bdb16..ea6f180ec39acbff6bcfca3cd8b24bd47d2c3430 100644 (file)
@@ -445,7 +445,7 @@ fn run_debuginfo_gdb_test(config: &Config, props: &TestProps, testfile: &Path) {
             loop {
                 //waiting 1 second for gdbserver start
                 timer::sleep(Duration::milliseconds(1000));
-                let result = task::try(proc() {
+                let result = task::try(move || {
                     tcp::TcpStream::connect("127.0.0.1:5039").unwrap();
                 });
                 if result.is_err() {
index c2309ba479ea605dc3373a3456bff698221f1f51..1938d3e38783fd2ac305dd78de5f49d6181b96f3 100644 (file)
@@ -29,10 +29,11 @@ with a closure argument. `spawn` executes the closure in the new task.
 fn print_message() { println!("I am running in a different task!"); }
 spawn(print_message);
 
-// Alternatively, use a `proc` expression instead of a named function.
-// The `proc` expression evaluates to an (unnamed) proc.
-// That proc will call `println!(...)` when the spawned task runs.
-spawn(proc() println!("I am also running in a different task!") );
+// Alternatively, use a `move ||` expression instead of a named function.
+// `||` expressions evaluate to an unnamed closures. The `move` keyword
+// indicates that the closure should take ownership of any variables it
+// touches.
+spawn(move || println!("I am also running in a different task!"));
 ```
 
 In Rust, a task is not a concept that appears in the language semantics.
@@ -40,11 +41,13 @@ Instead, Rust's type system provides all the tools necessary to implement safe
 concurrency: particularly, ownership. The language leaves the implementation
 details to the standard library.
 
-The `spawn` function has a very simple type signature: `fn spawn(f: proc():
-Send)`. Because it accepts only procs, and procs contain only owned data,
-`spawn` can safely move the entire proc and all its associated state into an
-entirely different task for execution. Like any closure, the function passed to
-`spawn` may capture an environment that it carries across tasks.
+The `spawn` function has the type signature: `fn
+spawn<F:FnOnce()+Send>(f: F)`.  This indicates that it takes as
+argument a closure (of type `F`) that it will run exactly once. This
+closure is limited to capturing `Send`-able data form its environment
+(that is, data which is deeply owned). Limiting the closure to `Send`
+ensures that `spawn` can safely move the entire closure and all its
+associated state into an entirely different task for execution.
 
 ```{rust}
 # use std::task::spawn;
@@ -52,8 +55,11 @@ entirely different task for execution. Like any closure, the function passed to
 // Generate some state locally
 let child_task_number = generate_task_number();
 
-spawn(proc() {
-    // Capture it in the remote task
+spawn(move || {
+    // Capture it in the remote task. The `move` keyword indicates
+    // that this closure should move `child_task_number` into its
+    // environment, rather than capturing a reference into the
+    // enclosing stack frame.
     println!("I am child number {}", child_task_number);
 });
 ```
@@ -74,7 +80,7 @@ example of calculating two results concurrently:
 
 let (tx, rx): (Sender<int>, Receiver<int>) = channel();
 
-spawn(proc() {
+spawn(move || {
     let result = some_expensive_computation();
     tx.send(result);
 });
@@ -102,7 +108,7 @@ task.
 # use std::task::spawn;
 # fn some_expensive_computation() -> int { 42 }
 # let (tx, rx) = channel();
-spawn(proc() {
+spawn(move || {
     let result = some_expensive_computation();
     tx.send(result);
 });
@@ -135,13 +141,13 @@ results across a number of tasks? The following program is ill-typed:
 # fn some_expensive_computation() -> int { 42 }
 let (tx, rx) = channel();
 
-spawn(proc() {
+spawn(move || {
     tx.send(some_expensive_computation());
 });
 
 // ERROR! The previous spawn statement already owns the sender,
 // so the compiler will not allow it to be captured again
-spawn(proc() {
+spawn(move || {
     tx.send(some_expensive_computation());
 });
 ```
@@ -154,7 +160,7 @@ let (tx, rx) = channel();
 for init_val in range(0u, 3) {
     // Create a new channel handle to distribute to the child task
     let child_tx = tx.clone();
-    spawn(proc() {
+    spawn(move || {
         child_tx.send(some_expensive_computation(init_val));
     });
 }
@@ -179,7 +185,7 @@ reference, written with multiple streams, it might look like the example below.
 // Create a vector of ports, one for each child task
 let rxs = Vec::from_fn(3, |init_val| {
     let (tx, rx) = channel();
-    spawn(proc() {
+    spawn(move || {
         tx.send(some_expensive_computation(init_val));
     });
     rx
@@ -207,7 +213,7 @@ fn fib(n: u64) -> u64 {
     12586269025
 }
 
-let mut delayed_fib = Future::spawn(proc() fib(50));
+let mut delayed_fib = Future::spawn(move || fib(50));
 make_a_sandwich();
 println!("fib(50) = {}", delayed_fib.get())
 # }
@@ -236,7 +242,7 @@ fn partial_sum(start: uint) -> f64 {
 }
 
 fn main() {
-    let mut futures = Vec::from_fn(200, |ind| Future::spawn( proc() { partial_sum(ind) }));
+    let mut futures = Vec::from_fn(200, |ind| Future::spawn(move || partial_sum(ind)));
 
     let mut final_res = 0f64;
     for ft in futures.iter_mut()  {
@@ -278,7 +284,7 @@ fn main() {
     for num in range(1u, 10) {
         let task_numbers = numbers_arc.clone();
 
-        spawn(proc() {
+        spawn(move || {
             println!("{}-norm = {}", num, pnorm(task_numbers.as_slice(), num));
         });
     }
@@ -312,7 +318,7 @@ if it were local.
 # let numbers_arc = Arc::new(numbers);
 # let num = 4;
 let task_numbers = numbers_arc.clone();
-spawn(proc() {
+spawn(move || {
     // Capture task_numbers and use it as if it was the underlying vector
     println!("{}-norm = {}", num, pnorm(task_numbers.as_slice(), num));
 });
@@ -344,7 +350,7 @@ result with an `int` field (representing a successful result) or an `Err` result
 # use std::task;
 # fn some_condition() -> bool { false }
 # fn calculate_result() -> int { 0 }
-let result: Result<int, Box<std::any::Any + Send>> = task::try(proc() {
+let result: Result<int, Box<std::any::Any + Send>> = task::try(move || {
     if some_condition() {
         calculate_result()
     } else {
index 05475c605ea7214a11eb9901c3b65f1d40264136..054552559dbec077fb5a1fd4533b3f0d40b83efb 100644 (file)
@@ -210,11 +210,11 @@ that one can still write things like `#[deriving(Eq)]`).
 # // what's actually being documented.
 # fn fib(n: int) { n + 2 }
 
-spawn(proc() { fib(200); })
+spawn(move || { fib(200); })
 ```
 ~~~
 
-The documentation online would look like `spawn(proc() { fib(200); })`, but when
+The documentation online would look like `spawn(move || { fib(200); })`, but when
 testing this code, the `fib` function will be included (so it can compile).
 
 ## Running tests (advanced)
index 1d2157b7e2fa3594ed8f36b7a36f9a11169bfadb..1f1909fd33cc18add67dbce919ffd70dac1679b8 100644 (file)
@@ -46,7 +46,7 @@
 ///     for _ in range(0u, 10) {
 ///         let child_numbers = shared_numbers.clone();
 ///
-///         spawn(proc() {
+///         spawn(move || {
 ///             let local_numbers = child_numbers.as_slice();
 ///
 ///             // Work with the local numbers
@@ -358,7 +358,7 @@ fn manually_share_arc() {
 
         let (tx, rx) = channel();
 
-        task::spawn(proc() {
+        task::spawn(move || {
             let arc_v: Arc<Vec<int>> = rx.recv();
             assert_eq!((*arc_v)[3], 4);
         });
index f49a0c037de84372133d35cc23b9caac9fc4fafa..df86ac96424b5529cf23f0e5edad29700f823066 100644 (file)
@@ -1133,7 +1133,7 @@ fn test_mut_rev_iter() {
     #[test]
     fn test_send() {
         let n = list_from(&[1i,2,3]);
-        spawn(proc() {
+        spawn(move || {
             check_links(&n);
             let a: &[_] = &[&1,&2,&3];
             assert_eq!(a, n.iter().collect::<Vec<&int>>());
index cc36c2eef4552e43d2a90d0a9bac92876334098f..2c8e5638e4949206aea08522c732f7f3c0031024 100644 (file)
@@ -21,7 +21,7 @@
 #![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
        html_favicon_url = "http://www.rust-lang.org/favicon.ico",
        html_root_url = "http://doc.rust-lang.org/nightly/")]
-#![feature(phase)]
+#![feature(phase, unboxed_closures)]
 
 #[cfg(test)] #[phase(plugin, link)] extern crate log;
 
@@ -59,7 +59,7 @@ fn deflate_bytes_internal(bytes: &[u8], flags: c_int) -> Option<CVec<u8>> {
                                              &mut outsz,
                                              flags);
         if !res.is_null() {
-            Some(CVec::new_with_dtor(res as *mut u8, outsz as uint, proc() libc::free(res)))
+            Some(CVec::new_with_dtor(res as *mut u8, outsz as uint, move|:| libc::free(res)))
         } else {
             None
         }
@@ -84,7 +84,7 @@ fn inflate_bytes_internal(bytes: &[u8], flags: c_int) -> Option<CVec<u8>> {
                                                &mut outsz,
                                                flags);
         if !res.is_null() {
-            Some(CVec::new_with_dtor(res as *mut u8, outsz as uint, proc() libc::free(res)))
+            Some(CVec::new_with_dtor(res as *mut u8, outsz as uint, move|:| libc::free(res)))
         } else {
             None
         }
index 8b79078eac6ad1548f53f6434bf22588138ea30b..8731f7084ed7d15db6595acc56cf7e160cffe4c8 100644 (file)
        html_favicon_url = "http://www.rust-lang.org/favicon.ico",
        html_root_url = "http://doc.rust-lang.org/nightly/",
        html_playground_url = "http://play.rust-lang.org/")]
-#![feature(macro_rules)]
+#![feature(macro_rules, unboxed_closures)]
 #![deny(missing_docs)]
 
 extern crate regex;
@@ -422,7 +422,7 @@ fn init() {
         DIRECTIVES = mem::transmute(box directives);
 
         // Schedule the cleanup for the globals for when the runtime exits.
-        rt::at_exit(proc() {
+        rt::at_exit(move |:| {
             assert!(!DIRECTIVES.is_null());
             let _directives: Box<Vec<directive::LogDirective>> =
                 mem::transmute(DIRECTIVES);
index d655b704053096fe7aad68e03756e2304bf35a26..b0f8b3bdbe7df8970b367f2a93a00627570baef3 100644 (file)
@@ -71,7 +71,7 @@
 pub mod pretty;
 
 pub fn run(args: Vec<String>) -> int {
-    monitor(proc() run_compiler(args.as_slice()));
+    monitor(move |:| run_compiler(args.as_slice()));
     0
 }
 
@@ -471,7 +471,7 @@ pub fn list_metadata(sess: &Session, path: &Path,
 ///
 /// The diagnostic emitter yielded to the procedure should be used for reporting
 /// errors of the compiler.
-pub fn monitor(f: proc():Send) {
+pub fn monitor<F:FnOnce()+Send>(f: F) {
     static STACK_SIZE: uint = 32000000; // 32MB
 
     let (tx, rx) = channel();
index fccd6605df713457965035e57924bde02f0c031f..37147eb8a87a839b69633f66957ba56e364fd96a 100644 (file)
 /// closures defined within the function.  For example:
 ///
 ///     fn foo() {
-///         bar(proc() { ... })
+///         bar(move|| { ... })
 ///     }
 ///
 /// Here, the function `foo()` and the closure passed to
index d3a766285809bdee95d157255ae8917354301b91..78117c9cb06d43b5c1249ada912af35317e13e83 100644 (file)
@@ -342,7 +342,7 @@ fn rust_input(cratefile: &str, externs: core::Externs, matches: &getopts::Matche
 
     let cr = Path::new(cratefile);
     info!("starting to run rustc");
-    let (mut krate, analysis) = std::task::try(proc() {
+    let (mut krate, analysis) = std::task::try(move |:| {
         let cr = cr;
         core::run_core(libs, cfgs, externs, &cr, triple)
     }).map_err(|_| "rustc failed").unwrap();
index 5759adf32440ee90ed0753674e4fda87621d5b78..0c64a0d29dffe71ba4caed1877535fdd4792e244 100644 (file)
@@ -15,6 +15,7 @@
 use std::os;
 use std::str;
 use std::string::String;
+use std::thunk::Thunk;
 
 use std::collections::{HashSet, HashMap};
 use testing;
@@ -142,7 +143,7 @@ fn runtest(test: &str, cratename: &str, libs: Vec<Path>, externs: core::Externs,
     let w1 = io::ChanWriter::new(tx);
     let w2 = w1.clone();
     let old = io::stdio::set_stderr(box w1);
-    spawn(proc() {
+    spawn(move |:| {
         let mut p = io::ChanReader::new(rx);
         let mut err = match old {
             Some(old) => {
@@ -282,7 +283,7 @@ pub fn add_test(&mut self, test: String,
                 ignore: should_ignore,
                 should_fail: testing::ShouldFail::No, // compiler failures are test failures
             },
-            testfn: testing::DynTestFn(proc() {
+            testfn: testing::DynTestFn(Thunk::new(move|| {
                 runtest(test.as_slice(),
                         cratename.as_slice(),
                         libs,
@@ -290,7 +291,7 @@ pub fn add_test(&mut self, test: String,
                         should_fail,
                         no_run,
                         as_test_harness);
-            }),
+            }))
         });
     }
 
index 865c1af1d14272e6c8f85970c43b8a45dcb710cb..bba81383f7b2ec772fc51f8b06764edf452556cb 100644 (file)
@@ -639,7 +639,7 @@ fn test_iterator() {
 
     #[test]
     fn test_to_c_str_fail() {
-        assert!(task::try(proc() { "he\x00llo".to_c_str() }).is_err());
+        assert!(task::try(move|| { "he\x00llo".to_c_str() }).is_err());
     }
 
     #[test]
index d40f149a2a1f8316a5cd4514efae81eb26d00d14..9adcc0a844dffb072b6abf616fdbb7ec2af90269 100644 (file)
@@ -99,7 +99,7 @@ fn exclusive_new_arc() {
                 let (tx, rx) = channel();
                 futures.push(rx);
 
-                task::spawn(proc() {
+                task::spawn(move || {
                     for _ in range(0u, count) {
                         **total.lock() += 1;
                     }
index b1d387a9cc358239d02342c62b296585d78244d4..df733d7ee225be4a3b71e9c7bdb20e7211732ed9 100644 (file)
@@ -59,7 +59,7 @@ mod test {
 
     #[test]
     fn thread_local_task_smoke_test() {
-        Thread::start(proc() {
+        Thread::start(move|| {
             let task = box Task::new(None, None);
             Local::put(task);
             let task: Box<Task> = Local::take();
@@ -69,7 +69,7 @@ fn thread_local_task_smoke_test() {
 
     #[test]
     fn thread_local_task_two_instances() {
-        Thread::start(proc() {
+        Thread::start(move|| {
             let task = box Task::new(None, None);
             Local::put(task);
             let task: Box<Task> = Local::take();
@@ -83,7 +83,7 @@ fn thread_local_task_two_instances() {
 
     #[test]
     fn borrow_smoke_test() {
-        Thread::start(proc() {
+        Thread::start(move|| {
             let task = box Task::new(None, None);
             Local::put(task);
 
@@ -97,7 +97,7 @@ fn borrow_smoke_test() {
 
     #[test]
     fn borrow_with_return() {
-        Thread::start(proc() {
+        Thread::start(move|| {
             let task = box Task::new(None, None);
             Local::put(task);
 
@@ -112,7 +112,7 @@ fn borrow_with_return() {
 
     #[test]
     fn try_take() {
-        Thread::start(proc() {
+        Thread::start(move|| {
             let task = box Task::new(None, None);
             Local::put(task);
 
index 5b58ec8fd3a8bb4e834cdeff52cdfebc27bca8e5..cbfb86a6ac7b2ac7ada773d9afa131ae587108d4 100644 (file)
@@ -680,7 +680,7 @@ fn smoke_cond() {
         static LK: StaticNativeMutex = NATIVE_MUTEX_INIT;
         unsafe {
             let guard = LK.lock();
-            let t = Thread::start(proc() {
+            let t = Thread::start(move|| {
                 let guard = LK.lock();
                 guard.signal();
             });
@@ -705,7 +705,7 @@ fn smoke_cond_noguard() {
         static LK: StaticNativeMutex = NATIVE_MUTEX_INIT;
         unsafe {
             LK.lock_noguard();
-            let t = Thread::start(proc() {
+            let t = Thread::start(move|| {
                 LK.lock_noguard();
                 LK.signal_noguard();
                 LK.unlock_noguard();
index f89876f7245e60c861a73df35ce717f58d1df24e..44e7291150ef9e0a9c27567a08ab91828a3b27a9 100644 (file)
 
 use kinds::Send;
 use mem;
-use ops::Drop;
+use ops::{Drop, FnOnce};
 use option::Option;
 use option::Option::{Some, None};
 use ptr::RawPtr;
 use ptr;
 use raw;
 use slice::AsSlice;
+use thunk::{Thunk};
 
 /// The type representing a foreign chunk of memory
 pub struct CVec<T> {
     base: *mut T,
     len: uint,
-    dtor: Option<proc():Send>,
+    dtor: Option<Thunk>,
 }
 
 #[unsafe_destructor]
@@ -57,7 +58,7 @@ impl<T> Drop for CVec<T> {
     fn drop(&mut self) {
         match self.dtor.take() {
             None => (),
-            Some(f) => f()
+            Some(f) => f.invoke(())
         }
     }
 }
@@ -90,15 +91,20 @@ pub unsafe fn new(base: *mut T, len: uint) -> CVec<T> {
     ///
     /// * base - A foreign pointer to a buffer
     /// * len - The number of elements in the buffer
-    /// * dtor - A proc to run when the value is destructed, useful
+    /// * dtor - A fn to run when the value is destructed, useful
     ///          for freeing the buffer, etc.
-    pub unsafe fn new_with_dtor(base: *mut T, len: uint,
-                                dtor: proc():Send) -> CVec<T> {
+    pub unsafe fn new_with_dtor<F>(base: *mut T,
+                                   len: uint,
+                                   dtor: F)
+                                   -> CVec<T>
+        where F : FnOnce(), F : Send
+    {
         assert!(base != ptr::null_mut());
+        let dtor: Thunk = Thunk::new(dtor);
         CVec {
             base: base,
             len: len,
-            dtor: Some(dtor),
+            dtor: Some(dtor)
         }
     }
 
@@ -177,8 +183,9 @@ fn malloc(n: uint) -> CVec<u8> {
             let mem = libc::malloc(n as libc::size_t);
             if mem.is_null() { ::alloc::oom() }
 
-            CVec::new_with_dtor(mem as *mut u8, n,
-                proc() { libc::free(mem as *mut libc::c_void); })
+            CVec::new_with_dtor(mem as *mut u8,
+                                n,
+                                move|| { libc::free(mem as *mut libc::c_void); })
         }
     }
 
@@ -218,8 +225,9 @@ fn test_overrun_set() {
     #[test]
     fn test_unwrap() {
         unsafe {
-            let cv = CVec::new_with_dtor(1 as *mut int, 0,
-                proc() { panic!("Don't run this destructor!") });
+            let cv = CVec::new_with_dtor(1 as *mut int,
+                                         0,
+                                         move|:| panic!("Don't run this destructor!"));
             let p = cv.unwrap();
             assert_eq!(p, 1 as *mut int);
         }
index 6cff5a3dd239dd15586491116bd1da1c79678008..0a5b3e5771b79d8d10d32a5493d03242aeff320e 100644 (file)
@@ -72,7 +72,7 @@
 //! ```
 //! // Create a simple streaming channel
 //! let (tx, rx) = channel();
-//! spawn(proc() {
+//! spawn(move|| {
 //!     tx.send(10i);
 //! });
 //! assert_eq!(rx.recv(), 10i);
@@ -87,7 +87,7 @@
 //! let (tx, rx) = channel();
 //! for i in range(0i, 10i) {
 //!     let tx = tx.clone();
-//!     spawn(proc() {
+//!     spawn(move|| {
 //!         tx.send(i);
 //!     })
 //! }
 //!
 //! ```
 //! let (tx, rx) = sync_channel::<int>(0);
-//! spawn(proc() {
+//! spawn(move|| {
 //!     // This will wait for the parent task to start receiving
 //!     tx.send(53);
 //! });
@@ -465,7 +465,7 @@ fn inner_unsafe<'a>(&'a self) -> &'a UnsafeCell<Flavor<T>> {
 /// let (tx, rx) = channel();
 ///
 /// // Spawn off an expensive computation
-/// spawn(proc() {
+/// spawn(move|| {
 /// #   fn expensive_computation() {}
 ///     tx.send(expensive_computation());
 /// });
@@ -504,7 +504,7 @@ pub fn channel<T: Send>() -> (Sender<T>, Receiver<T>) {
 /// // this returns immediately
 /// tx.send(1i);
 ///
-/// spawn(proc() {
+/// spawn(move|| {
 ///     // this will block until the previous message has been received
 ///     tx.send(2i);
 /// });
@@ -1065,7 +1065,7 @@ pub fn stress_factor() -> uint {
 
     test!(fn smoke_threads() {
         let (tx, rx) = channel::<int>();
-        spawn(proc() {
+        spawn(move|| {
             tx.send(1);
         });
         assert_eq!(rx.recv(), 1);
@@ -1093,7 +1093,7 @@ pub fn stress_factor() -> uint {
 
     test!(fn port_gone_concurrent() {
         let (tx, rx) = channel::<int>();
-        spawn(proc() {
+        spawn(move|| {
             rx.recv();
         });
         loop { tx.send(1) }
@@ -1102,7 +1102,7 @@ pub fn stress_factor() -> uint {
     test!(fn port_gone_concurrent_shared() {
         let (tx, rx) = channel::<int>();
         let tx2 = tx.clone();
-        spawn(proc() {
+        spawn(move|| {
             rx.recv();
         });
         loop {
@@ -1127,7 +1127,7 @@ pub fn stress_factor() -> uint {
 
     test!(fn chan_gone_concurrent() {
         let (tx, rx) = channel::<int>();
-        spawn(proc() {
+        spawn(move|| {
             tx.send(1);
             tx.send(1);
         });
@@ -1136,7 +1136,7 @@ pub fn stress_factor() -> uint {
 
     test!(fn stress() {
         let (tx, rx) = channel::<int>();
-        spawn(proc() {
+        spawn(move|| {
             for _ in range(0u, 10000) { tx.send(1i); }
         });
         for _ in range(0u, 10000) {
@@ -1150,7 +1150,7 @@ pub fn stress_factor() -> uint {
         let (tx, rx) = channel::<int>();
         let (dtx, drx) = channel::<()>();
 
-        spawn(proc() {
+        spawn(move|| {
             for _ in range(0, AMT * NTHREADS) {
                 assert_eq!(rx.recv(), 1);
             }
@@ -1163,7 +1163,7 @@ pub fn stress_factor() -> uint {
 
         for _ in range(0, NTHREADS) {
             let tx = tx.clone();
-            spawn(proc() {
+            spawn(move|| {
                 for _ in range(0, AMT) { tx.send(1); }
             });
         }
@@ -1177,7 +1177,7 @@ fn send_from_outside_runtime() {
         let (tx2, rx2) = channel::<int>();
         let (tx3, rx3) = channel::<()>();
         let tx4 = tx3.clone();
-        spawn(proc() {
+        spawn(move|| {
             tx1.send(());
             for _ in range(0i, 40) {
                 assert_eq!(rx2.recv(), 1);
@@ -1185,7 +1185,7 @@ fn send_from_outside_runtime() {
             tx3.send(());
         });
         rx1.recv();
-        spawn(proc() {
+        spawn(move|| {
             for _ in range(0i, 40) {
                 tx2.send(1);
             }
@@ -1199,7 +1199,7 @@ fn send_from_outside_runtime() {
     fn recv_from_outside_runtime() {
         let (tx, rx) = channel::<int>();
         let (dtx, drx) = channel();
-        spawn(proc() {
+        spawn(move|| {
             for _ in range(0i, 40) {
                 assert_eq!(rx.recv(), 1);
             }
@@ -1217,12 +1217,12 @@ fn no_runtime() {
         let (tx2, rx2) = channel::<int>();
         let (tx3, rx3) = channel::<()>();
         let tx4 = tx3.clone();
-        spawn(proc() {
+        spawn(move|| {
             assert_eq!(rx1.recv(), 1);
             tx2.send(2);
             tx4.send(());
         });
-        spawn(proc() {
+        spawn(move|| {
             tx1.send(1);
             assert_eq!(rx2.recv(), 2);
             tx3.send(());
@@ -1252,7 +1252,7 @@ fn no_runtime() {
 
     test!(fn oneshot_single_thread_recv_chan_close() {
         // Receiving on a closed chan will panic
-        let res = task::try(proc() {
+        let res = task::try(move|| {
             let (tx, rx) = channel::<int>();
             drop(tx);
             rx.recv();
@@ -1312,7 +1312,7 @@ fn no_runtime() {
 
     test!(fn oneshot_multi_task_recv_then_send() {
         let (tx, rx) = channel::<Box<int>>();
-        spawn(proc() {
+        spawn(move|| {
             assert!(rx.recv() == box 10);
         });
 
@@ -1321,10 +1321,10 @@ fn no_runtime() {
 
     test!(fn oneshot_multi_task_recv_then_close() {
         let (tx, rx) = channel::<Box<int>>();
-        spawn(proc() {
+        spawn(move|| {
             drop(tx);
         });
-        let res = task::try(proc() {
+        let res = task::try(move|| {
             assert!(rx.recv() == box 10);
         });
         assert!(res.is_err());
@@ -1333,7 +1333,7 @@ fn no_runtime() {
     test!(fn oneshot_multi_thread_close_stress() {
         for _ in range(0, stress_factor()) {
             let (tx, rx) = channel::<int>();
-            spawn(proc() {
+            spawn(move|| {
                 drop(rx);
             });
             drop(tx);
@@ -1343,10 +1343,10 @@ fn no_runtime() {
     test!(fn oneshot_multi_thread_send_close_stress() {
         for _ in range(0, stress_factor()) {
             let (tx, rx) = channel::<int>();
-            spawn(proc() {
+            spawn(move|| {
                 drop(rx);
             });
-            let _ = task::try(proc() {
+            let _ = task::try(move|| {
                 tx.send(1);
             });
         }
@@ -1355,14 +1355,14 @@ fn no_runtime() {
     test!(fn oneshot_multi_thread_recv_close_stress() {
         for _ in range(0, stress_factor()) {
             let (tx, rx) = channel::<int>();
-            spawn(proc() {
-                let res = task::try(proc() {
+            spawn(move|| {
+                let res = task::try(move|| {
                     rx.recv();
                 });
                 assert!(res.is_err());
             });
-            spawn(proc() {
-                spawn(proc() {
+            spawn(move|| {
+                spawn(move|| {
                     drop(tx);
                 });
             });
@@ -1372,10 +1372,10 @@ fn no_runtime() {
     test!(fn oneshot_multi_thread_send_recv_stress() {
         for _ in range(0, stress_factor()) {
             let (tx, rx) = channel();
-            spawn(proc() {
+            spawn(move|| {
                 tx.send(box 10i);
             });
-            spawn(proc() {
+            spawn(move|| {
                 assert!(rx.recv() == box 10i);
             });
         }
@@ -1391,7 +1391,7 @@ fn no_runtime() {
             fn send(tx: Sender<Box<int>>, i: int) {
                 if i == 10 { return }
 
-                spawn(proc() {
+                spawn(move|| {
                     tx.send(box i);
                     send(tx, i + 1);
                 });
@@ -1400,7 +1400,7 @@ fn send(tx: Sender<Box<int>>, i: int) {
             fn recv(rx: Receiver<Box<int>>, i: int) {
                 if i == 10 { return }
 
-                spawn(proc() {
+                spawn(move|| {
                     assert!(rx.recv() == box i);
                     recv(rx, i + 1);
                 });
@@ -1420,7 +1420,7 @@ fn recv(rx: Receiver<Box<int>>, i: int) {
         let total = stress_factor() + 100;
         for _ in range(0, total) {
             let tx = tx.clone();
-            spawn(proc() {
+            spawn(move|| {
                 tx.send(());
             });
         }
@@ -1434,7 +1434,7 @@ fn recv(rx: Receiver<Box<int>>, i: int) {
         let (tx, rx) = channel::<int>();
         let (total_tx, total_rx) = channel::<int>();
 
-        spawn(proc() {
+        spawn(move|| {
             let mut acc = 0;
             for x in rx.iter() {
                 acc += x;
@@ -1453,7 +1453,7 @@ fn recv(rx: Receiver<Box<int>>, i: int) {
         let (tx, rx) = channel::<int>();
         let (count_tx, count_rx) = channel();
 
-        spawn(proc() {
+        spawn(move|| {
             let mut count = 0;
             for x in rx.iter() {
                 if count >= 3 {
@@ -1477,7 +1477,7 @@ fn recv(rx: Receiver<Box<int>>, i: int) {
         let (tx1, rx1) = channel::<int>();
         let (tx2, rx2) = channel::<()>();
         let (tx3, rx3) = channel::<()>();
-        spawn(proc() {
+        spawn(move|| {
             rx2.recv();
             tx1.send(1);
             tx3.send(());
@@ -1501,7 +1501,7 @@ fn recv(rx: Receiver<Box<int>>, i: int) {
     test!(fn destroy_upgraded_shared_port_when_sender_still_active() {
         let (tx, rx) = channel();
         let (tx2, rx2) = channel();
-        spawn(proc() {
+        spawn(move|| {
             rx.recv(); // wait on a oneshot
             drop(rx);  // destroy a shared
             tx2.send(());
@@ -1522,7 +1522,7 @@ fn recv(rx: Receiver<Box<int>>, i: int) {
         use rustrt::thread::Thread;
 
         let (tx, rx) = channel();
-        let t = Thread::start(proc() {
+        let t = Thread::start(move|| {
             for _ in range(0u, 1000) {
                 tx.send(());
             }
@@ -1538,7 +1538,7 @@ fn recv(rx: Receiver<Box<int>>, i: int) {
 
         let (tx, rx) = channel();
         let (cdone, pdone) = channel();
-        let t = Thread::start(proc() {
+        let t = Thread::start(move|| {
             let mut hits = 0u;
             while hits < 10 {
                 match rx.try_recv() {
@@ -1591,7 +1591,7 @@ pub fn stress_factor() -> uint {
 
     test!(fn smoke_threads() {
         let (tx, rx) = sync_channel::<int>(0);
-        spawn(proc() {
+        spawn(move|| {
             tx.send(1);
         });
         assert_eq!(rx.recv(), 1);
@@ -1613,7 +1613,7 @@ pub fn stress_factor() -> uint {
 
     test!(fn port_gone_concurrent() {
         let (tx, rx) = sync_channel::<int>(0);
-        spawn(proc() {
+        spawn(move|| {
             rx.recv();
         });
         loop { tx.send(1) }
@@ -1622,7 +1622,7 @@ pub fn stress_factor() -> uint {
     test!(fn port_gone_concurrent_shared() {
         let (tx, rx) = sync_channel::<int>(0);
         let tx2 = tx.clone();
-        spawn(proc() {
+        spawn(move|| {
             rx.recv();
         });
         loop {
@@ -1647,7 +1647,7 @@ pub fn stress_factor() -> uint {
 
     test!(fn chan_gone_concurrent() {
         let (tx, rx) = sync_channel::<int>(0);
-        spawn(proc() {
+        spawn(move|| {
             tx.send(1);
             tx.send(1);
         });
@@ -1656,7 +1656,7 @@ pub fn stress_factor() -> uint {
 
     test!(fn stress() {
         let (tx, rx) = sync_channel::<int>(0);
-        spawn(proc() {
+        spawn(move|| {
             for _ in range(0u, 10000) { tx.send(1); }
         });
         for _ in range(0u, 10000) {
@@ -1670,7 +1670,7 @@ pub fn stress_factor() -> uint {
         let (tx, rx) = sync_channel::<int>(0);
         let (dtx, drx) = sync_channel::<()>(0);
 
-        spawn(proc() {
+        spawn(move|| {
             for _ in range(0, AMT * NTHREADS) {
                 assert_eq!(rx.recv(), 1);
             }
@@ -1683,7 +1683,7 @@ pub fn stress_factor() -> uint {
 
         for _ in range(0, NTHREADS) {
             let tx = tx.clone();
-            spawn(proc() {
+            spawn(move|| {
                 for _ in range(0, AMT) { tx.send(1); }
             });
         }
@@ -1712,7 +1712,7 @@ pub fn stress_factor() -> uint {
 
     test!(fn oneshot_single_thread_recv_chan_close() {
         // Receiving on a closed chan will panic
-        let res = task::try(proc() {
+        let res = task::try(move|| {
             let (tx, rx) = sync_channel::<int>(0);
             drop(tx);
             rx.recv();
@@ -1777,7 +1777,7 @@ pub fn stress_factor() -> uint {
 
     test!(fn oneshot_multi_task_recv_then_send() {
         let (tx, rx) = sync_channel::<Box<int>>(0);
-        spawn(proc() {
+        spawn(move|| {
             assert!(rx.recv() == box 10);
         });
 
@@ -1786,10 +1786,10 @@ pub fn stress_factor() -> uint {
 
     test!(fn oneshot_multi_task_recv_then_close() {
         let (tx, rx) = sync_channel::<Box<int>>(0);
-        spawn(proc() {
+        spawn(move|| {
             drop(tx);
         });
-        let res = task::try(proc() {
+        let res = task::try(move|| {
             assert!(rx.recv() == box 10);
         });
         assert!(res.is_err());
@@ -1798,7 +1798,7 @@ pub fn stress_factor() -> uint {
     test!(fn oneshot_multi_thread_close_stress() {
         for _ in range(0, stress_factor()) {
             let (tx, rx) = sync_channel::<int>(0);
-            spawn(proc() {
+            spawn(move|| {
                 drop(rx);
             });
             drop(tx);
@@ -1808,10 +1808,10 @@ pub fn stress_factor() -> uint {
     test!(fn oneshot_multi_thread_send_close_stress() {
         for _ in range(0, stress_factor()) {
             let (tx, rx) = sync_channel::<int>(0);
-            spawn(proc() {
+            spawn(move|| {
                 drop(rx);
             });
-            let _ = task::try(proc() {
+            let _ = task::try(move|| {
                 tx.send(1);
             });
         }
@@ -1820,14 +1820,14 @@ pub fn stress_factor() -> uint {
     test!(fn oneshot_multi_thread_recv_close_stress() {
         for _ in range(0, stress_factor()) {
             let (tx, rx) = sync_channel::<int>(0);
-            spawn(proc() {
-                let res = task::try(proc() {
+            spawn(move|| {
+                let res = task::try(move|| {
                     rx.recv();
                 });
                 assert!(res.is_err());
             });
-            spawn(proc() {
-                spawn(proc() {
+            spawn(move|| {
+                spawn(move|| {
                     drop(tx);
                 });
             });
@@ -1837,10 +1837,10 @@ pub fn stress_factor() -> uint {
     test!(fn oneshot_multi_thread_send_recv_stress() {
         for _ in range(0, stress_factor()) {
             let (tx, rx) = sync_channel::<Box<int>>(0);
-            spawn(proc() {
+            spawn(move|| {
                 tx.send(box 10i);
             });
-            spawn(proc() {
+            spawn(move|| {
                 assert!(rx.recv() == box 10i);
             });
         }
@@ -1856,7 +1856,7 @@ pub fn stress_factor() -> uint {
             fn send(tx: SyncSender<Box<int>>, i: int) {
                 if i == 10 { return }
 
-                spawn(proc() {
+                spawn(move|| {
                     tx.send(box i);
                     send(tx, i + 1);
                 });
@@ -1865,7 +1865,7 @@ fn send(tx: SyncSender<Box<int>>, i: int) {
             fn recv(rx: Receiver<Box<int>>, i: int) {
                 if i == 10 { return }
 
-                spawn(proc() {
+                spawn(move|| {
                     assert!(rx.recv() == box i);
                     recv(rx, i + 1);
                 });
@@ -1885,7 +1885,7 @@ fn recv(rx: Receiver<Box<int>>, i: int) {
         let total = stress_factor() + 100;
         for _ in range(0, total) {
             let tx = tx.clone();
-            spawn(proc() {
+            spawn(move|| {
                 tx.send(());
             });
         }
@@ -1899,7 +1899,7 @@ fn recv(rx: Receiver<Box<int>>, i: int) {
         let (tx, rx) = sync_channel::<int>(0);
         let (total_tx, total_rx) = sync_channel::<int>(0);
 
-        spawn(proc() {
+        spawn(move|| {
             let mut acc = 0;
             for x in rx.iter() {
                 acc += x;
@@ -1918,7 +1918,7 @@ fn recv(rx: Receiver<Box<int>>, i: int) {
         let (tx, rx) = sync_channel::<int>(0);
         let (count_tx, count_rx) = sync_channel(0);
 
-        spawn(proc() {
+        spawn(move|| {
             let mut count = 0;
             for x in rx.iter() {
                 if count >= 3 {
@@ -1942,7 +1942,7 @@ fn recv(rx: Receiver<Box<int>>, i: int) {
         let (tx1, rx1) = sync_channel::<int>(1);
         let (tx2, rx2) = sync_channel::<()>(1);
         let (tx3, rx3) = sync_channel::<()>(1);
-        spawn(proc() {
+        spawn(move|| {
             rx2.recv();
             tx1.send(1);
             tx3.send(());
@@ -1966,7 +1966,7 @@ fn recv(rx: Receiver<Box<int>>, i: int) {
     test!(fn destroy_upgraded_shared_port_when_sender_still_active() {
         let (tx, rx) = sync_channel::<()>(0);
         let (tx2, rx2) = sync_channel::<()>(0);
-        spawn(proc() {
+        spawn(move|| {
             rx.recv(); // wait on a oneshot
             drop(rx);  // destroy a shared
             tx2.send(());
@@ -1988,7 +1988,7 @@ fn recv(rx: Receiver<Box<int>>, i: int) {
 
         let (tx, rx) = sync_channel::<()>(0);
         let (cdone, pdone) = channel();
-        let t = Thread::start(proc() {
+        let t = Thread::start(move|| {
             let mut hits = 0u;
             while hits < 10 {
                 match rx.try_recv() {
@@ -2008,20 +2008,20 @@ fn recv(rx: Receiver<Box<int>>, i: int) {
 
     test!(fn send_opt1() {
         let (tx, rx) = sync_channel::<int>(0);
-        spawn(proc() { rx.recv(); });
+        spawn(move|| { rx.recv(); });
         assert_eq!(tx.send_opt(1), Ok(()));
     })
 
     test!(fn send_opt2() {
         let (tx, rx) = sync_channel::<int>(0);
-        spawn(proc() { drop(rx); });
+        spawn(move|| { drop(rx); });
         assert_eq!(tx.send_opt(1), Err(1));
     })
 
     test!(fn send_opt3() {
         let (tx, rx) = sync_channel::<int>(1);
         assert_eq!(tx.send_opt(1), Ok(()));
-        spawn(proc() { drop(rx); });
+        spawn(move|| { drop(rx); });
         assert_eq!(tx.send_opt(1), Err(1));
     })
 
@@ -2030,11 +2030,11 @@ fn recv(rx: Receiver<Box<int>>, i: int) {
         let tx2 = tx.clone();
         let (done, donerx) = channel();
         let done2 = done.clone();
-        spawn(proc() {
+        spawn(move|| {
             assert_eq!(tx.send_opt(1), Err(1));
             done.send(());
         });
-        spawn(proc() {
+        spawn(move|| {
             assert_eq!(tx2.send_opt(2), Err(2));
             done2.send(());
         });
@@ -2063,7 +2063,7 @@ fn recv(rx: Receiver<Box<int>>, i: int) {
 
     test!(fn try_send4() {
         let (tx, rx) = sync_channel::<int>(0);
-        spawn(proc() {
+        spawn(move|| {
             for _ in range(0u, 1000) { task::deschedule(); }
             assert_eq!(tx.try_send(1), Ok(()));
         });
@@ -2075,7 +2075,7 @@ fn repro() {
             let (tx1, rx1) = sync_channel::<()>(3);
             let (tx2, rx2) = sync_channel::<()>(3);
 
-            spawn(proc() {
+            spawn(move|| {
                 rx1.recv();
                 tx2.try_send(()).unwrap();
             });
index d4249abc3dda1188715d076f48b409a5c4cff36a..db4e3eac449507992df1bb8932c5ec6d6c732cf4 100644 (file)
@@ -178,7 +178,7 @@ fn test() {
         for _ in range(0, nthreads) {
             let tx = tx.clone();
             let q = q.clone();
-            spawn(proc() {
+            spawn(move|| {
                 for i in range(0, nmsgs) {
                     q.push(i);
                 }
index 3191519815ae46ed6801162eb76260dfb96cfbde..e145b0df7f32acfafff418965f02fe4092a19e94 100644 (file)
@@ -403,7 +403,7 @@ macro_rules! select {
         let (_tx2, rx2) = channel::<int>();
         let (tx3, rx3) = channel::<int>();
 
-        spawn(proc() {
+        spawn(move|| {
             for _ in range(0u, 20) { task::deschedule(); }
             tx1.send(1);
             rx3.recv();
@@ -426,7 +426,7 @@ macro_rules! select {
         let (tx2, rx2) = channel::<int>();
         let (tx3, rx3) = channel::<()>();
 
-        spawn(proc() {
+        spawn(move|| {
             for _ in range(0u, 20) { task::deschedule(); }
             tx1.send(1);
             tx2.send(2);
@@ -452,7 +452,7 @@ macro_rules! select {
         let (tx2, rx2) = channel::<int>();
         let (tx3, rx3) = channel::<()>();
 
-        spawn(proc() {
+        spawn(move|| {
             for i in range(0, AMT) {
                 if i % 2 == 0 {
                     tx1.send(i);
@@ -477,7 +477,7 @@ macro_rules! select {
         let (_tx2, rx2) = channel::<int>();
         let (tx3, rx3) = channel::<()>();
 
-        spawn(proc() {
+        spawn(move|| {
             rx3.recv();
             tx1.clone();
             assert_eq!(rx3.try_recv(), Err(Empty));
@@ -498,7 +498,7 @@ macro_rules! select {
         let (_tx2, rx2) = channel::<int>();
         let (tx3, rx3) = channel::<()>();
 
-        spawn(proc() {
+        spawn(move|| {
             rx3.recv();
             tx1.clone();
             assert_eq!(rx3.try_recv(), Err(Empty));
@@ -518,7 +518,7 @@ macro_rules! select {
         let (tx1, rx1) = channel::<()>();
         let (tx2, rx2) = channel::<()>();
         let (tx3, rx3) = channel::<()>();
-        spawn(proc() {
+        spawn(move|| {
             let s = Select::new();
             let mut h1 = s.handle(&rx1);
             let mut h2 = s.handle(&rx2);
@@ -624,7 +624,7 @@ macro_rules! select {
     test!(fn oneshot_data_waiting() {
         let (tx1, rx1) = channel();
         let (tx2, rx2) = channel();
-        spawn(proc() {
+        spawn(move|| {
             select! {
                 () = rx1.recv() => {}
             }
@@ -643,7 +643,7 @@ macro_rules! select {
         tx1.send(());
         rx1.recv();
         rx1.recv();
-        spawn(proc() {
+        spawn(move|| {
             select! {
                 () = rx1.recv() => {}
             }
@@ -661,7 +661,7 @@ macro_rules! select {
         drop(tx1.clone());
         tx1.send(());
         rx1.recv();
-        spawn(proc() {
+        spawn(move|| {
             select! {
                 () = rx1.recv() => {}
             }
@@ -683,7 +683,7 @@ macro_rules! select {
 
     test!(fn sync2() {
         let (tx, rx) = sync_channel::<int>(0);
-        spawn(proc() {
+        spawn(move|| {
             for _ in range(0u, 100) { task::deschedule() }
             tx.send(1);
         });
@@ -695,8 +695,8 @@ macro_rules! select {
     test!(fn sync3() {
         let (tx1, rx1) = sync_channel::<int>(0);
         let (tx2, rx2): (Sender<int>, Receiver<int>) = channel();
-        spawn(proc() { tx1.send(1); });
-        spawn(proc() { tx2.send(2); });
+        spawn(move|| { tx1.send(1); });
+        spawn(move|| { tx2.send(2); });
         select! {
             n = rx1.recv() => {
                 assert_eq!(n, 1);
index a6b4ab71bacc1be1acabe6fc15192f63c15146cd..db8fff772a4d3a6b97e432b23fd911b38a1e7ada 100644 (file)
@@ -316,7 +316,7 @@ unsafe fn stress_bound(bound: uint) {
 
             let (tx, rx) = channel();
             let q2 = q.clone();
-            spawn(proc() {
+            spawn(move|| {
                 for _ in range(0u, 100000) {
                     loop {
                         match q2.pop() {
index 4ec1a3764db66ca94ec9ce6ce682cfbbbc105a18..308dc0941013818b619adf070da157988b193ebf 100644 (file)
@@ -161,7 +161,7 @@ mod test {
     #[test]
     fn test_rx_reader() {
         let (tx, rx) = channel();
-        task::spawn(proc() {
+        task::spawn(move|| {
           tx.send(vec![1u8, 2u8]);
           tx.send(vec![]);
           tx.send(vec![3u8, 4u8]);
@@ -203,7 +203,7 @@ fn test_rx_reader() {
     #[test]
     fn test_rx_buffer() {
         let (tx, rx) = channel();
-        task::spawn(proc() {
+        task::spawn(move|| {
           tx.send(b"he".to_vec());
           tx.send(b"llo wo".to_vec());
           tx.send(b"".to_vec());
@@ -229,7 +229,7 @@ fn test_chan_writer() {
         writer.write_be_u32(42).unwrap();
 
         let wanted = vec![0u8, 0u8, 0u8, 42u8];
-        let got = match task::try(proc() { rx.recv() }) {
+        let got = match task::try(move|| { rx.recv() }) {
             Ok(got) => got,
             Err(_) => panic!(),
         };
index bad86258bb85db44d2702a13716a30b7f7582f91..d21e0f57b07067b02a8dfcb0bba6f57f3f140372 100644 (file)
 //!     for stream in acceptor.incoming() {
 //!         match stream {
 //!             Err(e) => { /* connection failed */ }
-//!             Ok(stream) => spawn(proc() {
+//!             Ok(stream) => spawn(move|| {
 //!                 // connection succeeded
 //!                 handle_client(stream)
 //!             })
index ec997b71986cc4782471827e2dee86a72a5d2a66..9f2f41c002108425e16c3eaa3e9bd2602ee272a8 100644 (file)
@@ -273,13 +273,16 @@ mod tests {
     use io::fs::PathExtensions;
     use time::Duration;
 
-    pub fn smalltest(server: proc(UnixStream):Send, client: proc(UnixStream):Send) {
+    pub fn smalltest<F,G>(server: F, client: G)
+        where F : FnOnce(UnixStream), F : Send,
+              G : FnOnce(UnixStream), G : Send
+    {
         let path1 = next_test_unix();
         let path2 = path1.clone();
 
         let mut acceptor = UnixListener::bind(&path1).listen();
 
-        spawn(proc() {
+        spawn(move|| {
             match UnixStream::connect(&path2) {
                 Ok(c) => client(c),
                 Err(e) => panic!("failed connect: {}", e),
@@ -321,11 +324,11 @@ fn connect_error() {
 
     #[test]
     fn smoke() {
-        smalltest(proc(mut server) {
+        smalltest(move |mut server| {
             let mut buf = [0];
             server.read(&mut buf).unwrap();
             assert!(buf[0] == 99);
-        }, proc(mut client) {
+        }, move|mut client| {
             client.write(&[99]).unwrap();
         })
     }
@@ -333,18 +336,18 @@ fn smoke() {
     #[cfg_attr(windows, ignore)] // FIXME(#12516)
     #[test]
     fn read_eof() {
-        smalltest(proc(mut server) {
+        smalltest(move|mut server| {
             let mut buf = [0];
             assert!(server.read(&mut buf).is_err());
             assert!(server.read(&mut buf).is_err());
-        }, proc(_client) {
+        }, move|_client| {
             // drop the client
         })
     }
 
     #[test]
     fn write_begone() {
-        smalltest(proc(mut server) {
+        smalltest(move|mut server| {
             let buf = [0];
             loop {
                 match server.write(&buf) {
@@ -358,7 +361,7 @@ fn write_begone() {
                     }
                 }
             }
-        }, proc(_client) {
+        }, move|_client| {
             // drop the client
         })
     }
@@ -374,7 +377,7 @@ fn accept_lots() {
             Err(e) => panic!("failed listen: {}", e),
         };
 
-        spawn(proc() {
+        spawn(move|| {
             for _ in range(0u, times) {
                 let mut stream = UnixStream::connect(&path2);
                 match stream.write(&[100]) {
@@ -408,7 +411,7 @@ fn unix_clone_smoke() {
         let addr = next_test_unix();
         let mut acceptor = UnixListener::bind(&addr).listen();
 
-        spawn(proc() {
+        spawn(move|| {
             let mut s = UnixStream::connect(&addr);
             let mut buf = [0, 0];
             debug!("client reading");
@@ -424,7 +427,7 @@ fn unix_clone_smoke() {
 
         let (tx1, rx1) = channel();
         let (tx2, rx2) = channel();
-        spawn(proc() {
+        spawn(move|| {
             let mut s2 = s2;
             rx1.recv();
             debug!("writer writing");
@@ -447,7 +450,7 @@ fn unix_clone_two_read() {
         let (tx1, rx) = channel();
         let tx2 = tx1.clone();
 
-        spawn(proc() {
+        spawn(move|| {
             let mut s = UnixStream::connect(&addr);
             s.write(&[1]).unwrap();
             rx.recv();
@@ -459,7 +462,7 @@ fn unix_clone_two_read() {
         let s2 = s1.clone();
 
         let (done, rx) = channel();
-        spawn(proc() {
+        spawn(move|| {
             let mut s2 = s2;
             let mut buf = [0, 0];
             s2.read(&mut buf).unwrap();
@@ -478,7 +481,7 @@ fn unix_clone_two_write() {
         let addr = next_test_unix();
         let mut acceptor = UnixListener::bind(&addr).listen();
 
-        spawn(proc() {
+        spawn(move|| {
             let mut s = UnixStream::connect(&addr);
             let buf = &mut [0, 1];
             s.read(buf).unwrap();
@@ -489,7 +492,7 @@ fn unix_clone_two_write() {
         let s2 = s1.clone();
 
         let (tx, rx) = channel();
-        spawn(proc() {
+        spawn(move|| {
             let mut s2 = s2;
             s2.write(&[1]).unwrap();
             tx.send(());
@@ -536,7 +539,7 @@ fn accept_timeout() {
         // continue to receive any pending connections.
         let (tx, rx) = channel();
         let addr2 = addr.clone();
-        spawn(proc() {
+        spawn(move|| {
             tx.send(UnixStream::connect(&addr2).unwrap());
         });
         let l = rx.recv();
@@ -554,7 +557,7 @@ fn accept_timeout() {
         // Unset the timeout and make sure that this always blocks.
         a.set_timeout(None);
         let addr2 = addr.clone();
-        spawn(proc() {
+        spawn(move|| {
             drop(UnixStream::connect(&addr2).unwrap());
         });
         a.accept().unwrap();
@@ -592,7 +595,7 @@ fn close_readwrite_smoke() {
         let addr = next_test_unix();
         let a = UnixListener::bind(&addr).listen().unwrap();
         let (_tx, rx) = channel::<()>();
-        spawn(proc() {
+        spawn(move|| {
             let mut a = a;
             let _s = a.accept().unwrap();
             let _ = rx.recv_opt();
@@ -629,7 +632,7 @@ fn close_read_wakes_up() {
         let addr = next_test_unix();
         let a = UnixListener::bind(&addr).listen().unwrap();
         let (_tx, rx) = channel::<()>();
-        spawn(proc() {
+        spawn(move|| {
             let mut a = a;
             let _s = a.accept().unwrap();
             let _ = rx.recv_opt();
@@ -638,7 +641,7 @@ fn close_read_wakes_up() {
         let mut s = UnixStream::connect(&addr).unwrap();
         let s2 = s.clone();
         let (tx, rx) = channel();
-        spawn(proc() {
+        spawn(move|| {
             let mut s2 = s2;
             assert!(s2.read(&mut [0]).is_err());
             tx.send(());
@@ -655,7 +658,7 @@ fn readwrite_timeouts() {
         let addr = next_test_unix();
         let mut a = UnixListener::bind(&addr).listen().unwrap();
         let (tx, rx) = channel::<()>();
-        spawn(proc() {
+        spawn(move|| {
             let mut s = UnixStream::connect(&addr).unwrap();
             rx.recv();
             assert!(s.write(&[0]).is_ok());
@@ -693,7 +696,7 @@ fn read_timeouts() {
         let addr = next_test_unix();
         let mut a = UnixListener::bind(&addr).listen().unwrap();
         let (tx, rx) = channel::<()>();
-        spawn(proc() {
+        spawn(move|| {
             let mut s = UnixStream::connect(&addr).unwrap();
             rx.recv();
             let mut amt = 0;
@@ -722,7 +725,7 @@ fn write_timeouts() {
         let addr = next_test_unix();
         let mut a = UnixListener::bind(&addr).listen().unwrap();
         let (tx, rx) = channel::<()>();
-        spawn(proc() {
+        spawn(move|| {
             let mut s = UnixStream::connect(&addr).unwrap();
             rx.recv();
             assert!(s.write(&[0]).is_ok());
@@ -749,7 +752,7 @@ fn timeout_concurrent_read() {
         let addr = next_test_unix();
         let mut a = UnixListener::bind(&addr).listen().unwrap();
         let (tx, rx) = channel::<()>();
-        spawn(proc() {
+        spawn(move|| {
             let mut s = UnixStream::connect(&addr).unwrap();
             rx.recv();
             assert!(s.write(&[0]).is_ok());
@@ -759,7 +762,7 @@ fn timeout_concurrent_read() {
         let mut s = a.accept().unwrap();
         let s2 = s.clone();
         let (tx2, rx2) = channel();
-        spawn(proc() {
+        spawn(move|| {
             let mut s2 = s2;
             assert!(s2.read(&mut [0]).is_ok());
             tx2.send(());
@@ -781,10 +784,10 @@ fn clone_accept_smoke() {
         let mut a2 = a.clone();
 
         let addr2 = addr.clone();
-        spawn(proc() {
+        spawn(move|| {
             let _ = UnixStream::connect(&addr2);
         });
-        spawn(proc() {
+        spawn(move|| {
             let _ = UnixStream::connect(&addr);
         });
 
@@ -804,14 +807,14 @@ fn clone_accept_concurrent() {
         let (tx, rx) = channel();
         let tx2 = tx.clone();
 
-        spawn(proc() { let mut a = a; tx.send(a.accept()) });
-        spawn(proc() { let mut a = a2; tx2.send(a.accept()) });
+        spawn(move|| { let mut a = a; tx.send(a.accept()) });
+        spawn(move|| { let mut a = a2; tx2.send(a.accept()) });
 
         let addr2 = addr.clone();
-        spawn(proc() {
+        spawn(move|| {
             let _ = UnixStream::connect(&addr2);
         });
-        spawn(proc() {
+        spawn(move|| {
             let _ = UnixStream::connect(&addr);
         });
 
@@ -837,7 +840,7 @@ fn close_accept_concurrent() {
         let mut a2 = a.clone();
 
         let (tx, rx) = channel();
-        spawn(proc() {
+        spawn(move|| {
             let mut a = a;
             tx.send(a.accept());
         });
index a7b1b077eff0b1b46cc7d88828a38c6ccbaabe4c..3c38e23183fe7e3e840ef920a15f44d6cde2afd0 100644 (file)
@@ -140,7 +140,7 @@ pub fn set_keepalive(&mut self, delay_in_seconds: Option<uint>) -> IoResult<()>
     /// let mut stream = TcpStream::connect("127.0.0.1:34254").unwrap();
     /// let stream2 = stream.clone();
     ///
-    /// spawn(proc() {
+    /// spawn(move|| {
     ///     // close this stream after one second
     ///     timer::sleep(Duration::seconds(1));
     ///     let mut stream = stream2;
@@ -293,7 +293,7 @@ fn as_inner(&self) -> &TcpStreamImp {
 /// for stream in acceptor.incoming() {
 ///     match stream {
 ///         Err(e) => { /* connection failed */ }
-///         Ok(stream) => spawn(proc() {
+///         Ok(stream) => spawn(move|| {
 ///             // connection succeeded
 ///             handle_client(stream)
 ///         })
@@ -420,7 +420,7 @@ impl TcpAcceptor {
     /// let mut a = TcpListener::bind("127.0.0.1:8482").listen().unwrap();
     /// let a2 = a.clone();
     ///
-    /// spawn(proc() {
+    /// spawn(move|| {
     ///     let mut a2 = a2;
     ///     for socket in a2.incoming() {
     ///         match socket {
@@ -509,7 +509,7 @@ fn listen_ip4_localhost() {
         let listener = TcpListener::bind(socket_addr);
         let mut acceptor = listener.listen();
 
-        spawn(proc() {
+        spawn(move|| {
             let mut stream = TcpStream::connect(("localhost", socket_addr.port));
             stream.write(&[144]).unwrap();
         });
@@ -525,7 +525,7 @@ fn connect_localhost() {
         let addr = next_test_ip4();
         let mut acceptor = TcpListener::bind(addr).listen();
 
-        spawn(proc() {
+        spawn(move|| {
             let mut stream = TcpStream::connect(("localhost", addr.port));
             stream.write(&[64]).unwrap();
         });
@@ -541,7 +541,7 @@ fn connect_ip4_loopback() {
         let addr = next_test_ip4();
         let mut acceptor = TcpListener::bind(addr).listen();
 
-        spawn(proc() {
+        spawn(move|| {
             let mut stream = TcpStream::connect(("127.0.0.1", addr.port));
             stream.write(&[44]).unwrap();
         });
@@ -557,7 +557,7 @@ fn connect_ip6_loopback() {
         let addr = next_test_ip6();
         let mut acceptor = TcpListener::bind(addr).listen();
 
-        spawn(proc() {
+        spawn(move|| {
             let mut stream = TcpStream::connect(("::1", addr.port));
             stream.write(&[66]).unwrap();
         });
@@ -573,7 +573,7 @@ fn smoke_test_ip4() {
         let addr = next_test_ip4();
         let mut acceptor = TcpListener::bind(addr).listen();
 
-        spawn(proc() {
+        spawn(move|| {
             let mut stream = TcpStream::connect(addr);
             stream.write(&[99]).unwrap();
         });
@@ -589,7 +589,7 @@ fn smoke_test_ip6() {
         let addr = next_test_ip6();
         let mut acceptor = TcpListener::bind(addr).listen();
 
-        spawn(proc() {
+        spawn(move|| {
             let mut stream = TcpStream::connect(addr);
             stream.write(&[99]).unwrap();
         });
@@ -605,7 +605,7 @@ fn read_eof_ip4() {
         let addr = next_test_ip4();
         let mut acceptor = TcpListener::bind(addr).listen();
 
-        spawn(proc() {
+        spawn(move|| {
             let _stream = TcpStream::connect(addr);
             // Close
         });
@@ -621,7 +621,7 @@ fn read_eof_ip6() {
         let addr = next_test_ip6();
         let mut acceptor = TcpListener::bind(addr).listen();
 
-        spawn(proc() {
+        spawn(move|| {
             let _stream = TcpStream::connect(addr);
             // Close
         });
@@ -637,7 +637,7 @@ fn read_eof_twice_ip4() {
         let addr = next_test_ip4();
         let mut acceptor = TcpListener::bind(addr).listen();
 
-        spawn(proc() {
+        spawn(move|| {
             let _stream = TcpStream::connect(addr);
             // Close
         });
@@ -661,7 +661,7 @@ fn read_eof_twice_ip6() {
         let addr = next_test_ip6();
         let mut acceptor = TcpListener::bind(addr).listen();
 
-        spawn(proc() {
+        spawn(move|| {
             let _stream = TcpStream::connect(addr);
             // Close
         });
@@ -686,7 +686,7 @@ fn write_close_ip4() {
         let mut acceptor = TcpListener::bind(addr).listen();
 
         let (tx, rx) = channel();
-        spawn(proc() {
+        spawn(move|| {
             drop(TcpStream::connect(addr));
             tx.send(());
         });
@@ -711,7 +711,7 @@ fn write_close_ip6() {
         let mut acceptor = TcpListener::bind(addr).listen();
 
         let (tx, rx) = channel();
-        spawn(proc() {
+        spawn(move|| {
             drop(TcpStream::connect(addr));
             tx.send(());
         });
@@ -736,7 +736,7 @@ fn multiple_connect_serial_ip4() {
         let max = 10u;
         let mut acceptor = TcpListener::bind(addr).listen();
 
-        spawn(proc() {
+        spawn(move|| {
             for _ in range(0, max) {
                 let mut stream = TcpStream::connect(addr);
                 stream.write(&[99]).unwrap();
@@ -756,7 +756,7 @@ fn multiple_connect_serial_ip6() {
         let max = 10u;
         let mut acceptor = TcpListener::bind(addr).listen();
 
-        spawn(proc() {
+        spawn(move|| {
             for _ in range(0, max) {
                 let mut stream = TcpStream::connect(addr);
                 stream.write(&[99]).unwrap();
@@ -776,11 +776,11 @@ fn multiple_connect_interleaved_greedy_schedule_ip4() {
         static MAX: int = 10;
         let acceptor = TcpListener::bind(addr).listen();
 
-        spawn(proc() {
+        spawn(move|| {
             let mut acceptor = acceptor;
             for (i, stream) in acceptor.incoming().enumerate().take(MAX as uint) {
                 // Start another task to handle the connection
-                spawn(proc() {
+                spawn(move|| {
                     let mut stream = stream;
                     let mut buf = [0];
                     stream.read(&mut buf).unwrap();
@@ -795,7 +795,7 @@ fn multiple_connect_interleaved_greedy_schedule_ip4() {
         fn connect(i: int, addr: SocketAddr) {
             if i == MAX { return }
 
-            spawn(proc() {
+            spawn(move|| {
                 debug!("connecting");
                 let mut stream = TcpStream::connect(addr);
                 // Connect again before writing
@@ -812,11 +812,11 @@ fn multiple_connect_interleaved_greedy_schedule_ip6() {
         static MAX: int = 10;
         let acceptor = TcpListener::bind(addr).listen();
 
-        spawn(proc() {
+        spawn(move|| {
             let mut acceptor = acceptor;
             for (i, stream) in acceptor.incoming().enumerate().take(MAX as uint) {
                 // Start another task to handle the connection
-                spawn(proc() {
+                spawn(move|| {
                     let mut stream = stream;
                     let mut buf = [0];
                     stream.read(&mut buf).unwrap();
@@ -831,7 +831,7 @@ fn multiple_connect_interleaved_greedy_schedule_ip6() {
         fn connect(i: int, addr: SocketAddr) {
             if i == MAX { return }
 
-            spawn(proc() {
+            spawn(move|| {
                 debug!("connecting");
                 let mut stream = TcpStream::connect(addr);
                 // Connect again before writing
@@ -848,11 +848,11 @@ fn multiple_connect_interleaved_lazy_schedule_ip4() {
         let addr = next_test_ip4();
         let acceptor = TcpListener::bind(addr).listen();
 
-        spawn(proc() {
+        spawn(move|| {
             let mut acceptor = acceptor;
             for stream in acceptor.incoming().take(MAX as uint) {
                 // Start another task to handle the connection
-                spawn(proc() {
+                spawn(move|| {
                     let mut stream = stream;
                     let mut buf = [0];
                     stream.read(&mut buf).unwrap();
@@ -867,7 +867,7 @@ fn multiple_connect_interleaved_lazy_schedule_ip4() {
         fn connect(i: int, addr: SocketAddr) {
             if i == MAX { return }
 
-            spawn(proc() {
+            spawn(move|| {
                 debug!("connecting");
                 let mut stream = TcpStream::connect(addr);
                 // Connect again before writing
@@ -884,11 +884,11 @@ fn multiple_connect_interleaved_lazy_schedule_ip6() {
         let addr = next_test_ip6();
         let acceptor = TcpListener::bind(addr).listen();
 
-        spawn(proc() {
+        spawn(move|| {
             let mut acceptor = acceptor;
             for stream in acceptor.incoming().take(MAX as uint) {
                 // Start another task to handle the connection
-                spawn(proc() {
+                spawn(move|| {
                     let mut stream = stream;
                     let mut buf = [0];
                     stream.read(&mut buf).unwrap();
@@ -903,7 +903,7 @@ fn multiple_connect_interleaved_lazy_schedule_ip6() {
         fn connect(i: int, addr: SocketAddr) {
             if i == MAX { return }
 
-            spawn(proc() {
+            spawn(move|| {
                 debug!("connecting");
                 let mut stream = TcpStream::connect(addr);
                 // Connect again before writing
@@ -926,7 +926,7 @@ pub fn socket_name(addr: SocketAddr) {
 
     pub fn peer_name(addr: SocketAddr) {
         let acceptor = TcpListener::bind(addr).listen();
-        spawn(proc() {
+        spawn(move|| {
             let mut acceptor = acceptor;
             acceptor.accept().unwrap();
         });
@@ -961,7 +961,7 @@ fn socket_and_peer_name_ip6() {
     fn partial_read() {
         let addr = next_test_ip4();
         let (tx, rx) = channel();
-        spawn(proc() {
+        spawn(move|| {
             let mut srv = TcpListener::bind(addr).listen().unwrap();
             tx.send(());
             let mut cl = srv.accept().unwrap();
@@ -998,7 +998,7 @@ fn fast_rebind() {
         let addr = next_test_ip4();
         let (tx, rx) = channel();
 
-        spawn(proc() {
+        spawn(move|| {
             rx.recv();
             let _stream = TcpStream::connect(addr).unwrap();
             // Close
@@ -1023,7 +1023,7 @@ fn tcp_clone_smoke() {
         let addr = next_test_ip4();
         let mut acceptor = TcpListener::bind(addr).listen();
 
-        spawn(proc() {
+        spawn(move|| {
             let mut s = TcpStream::connect(addr);
             let mut buf = [0, 0];
             assert_eq!(s.read(&mut buf), Ok(1));
@@ -1036,7 +1036,7 @@ fn tcp_clone_smoke() {
 
         let (tx1, rx1) = channel();
         let (tx2, rx2) = channel();
-        spawn(proc() {
+        spawn(move|| {
             let mut s2 = s2;
             rx1.recv();
             s2.write(&[1]).unwrap();
@@ -1055,7 +1055,7 @@ fn tcp_clone_two_read() {
         let (tx1, rx) = channel();
         let tx2 = tx1.clone();
 
-        spawn(proc() {
+        spawn(move|| {
             let mut s = TcpStream::connect(addr);
             s.write(&[1]).unwrap();
             rx.recv();
@@ -1067,7 +1067,7 @@ fn tcp_clone_two_read() {
         let s2 = s1.clone();
 
         let (done, rx) = channel();
-        spawn(proc() {
+        spawn(move|| {
             let mut s2 = s2;
             let mut buf = [0, 0];
             s2.read(&mut buf).unwrap();
@@ -1086,7 +1086,7 @@ fn tcp_clone_two_write() {
         let addr = next_test_ip4();
         let mut acceptor = TcpListener::bind(addr).listen();
 
-        spawn(proc() {
+        spawn(move|| {
             let mut s = TcpStream::connect(addr);
             let mut buf = [0, 1];
             s.read(&mut buf).unwrap();
@@ -1097,7 +1097,7 @@ fn tcp_clone_two_write() {
         let s2 = s1.clone();
 
         let (done, rx) = channel();
-        spawn(proc() {
+        spawn(move|| {
             let mut s2 = s2;
             s2.write(&[1]).unwrap();
             done.send(());
@@ -1111,7 +1111,7 @@ fn tcp_clone_two_write() {
     fn shutdown_smoke() {
         let addr = next_test_ip4();
         let a = TcpListener::bind(addr).unwrap().listen();
-        spawn(proc() {
+        spawn(move|| {
             let mut a = a;
             let mut c = a.accept().unwrap();
             assert_eq!(c.read_to_end(), Ok(vec!()));
@@ -1145,7 +1145,7 @@ fn accept_timeout() {
         //        flakiness.
         if !cfg!(target_os = "freebsd") {
             let (tx, rx) = channel();
-            spawn(proc() {
+            spawn(move|| {
                 tx.send(TcpStream::connect(addr).unwrap());
             });
             let _l = rx.recv();
@@ -1162,7 +1162,7 @@ fn accept_timeout() {
 
         // Unset the timeout and make sure that this always blocks.
         a.set_timeout(None);
-        spawn(proc() {
+        spawn(move|| {
             drop(TcpStream::connect(addr).unwrap());
         });
         a.accept().unwrap();
@@ -1173,7 +1173,7 @@ fn close_readwrite_smoke() {
         let addr = next_test_ip4();
         let a = TcpListener::bind(addr).listen().unwrap();
         let (_tx, rx) = channel::<()>();
-        spawn(proc() {
+        spawn(move|| {
             let mut a = a;
             let _s = a.accept().unwrap();
             let _ = rx.recv_opt();
@@ -1210,7 +1210,7 @@ fn close_read_wakes_up() {
         let addr = next_test_ip4();
         let a = TcpListener::bind(addr).listen().unwrap();
         let (_tx, rx) = channel::<()>();
-        spawn(proc() {
+        spawn(move|| {
             let mut a = a;
             let _s = a.accept().unwrap();
             let _ = rx.recv_opt();
@@ -1219,7 +1219,7 @@ fn close_read_wakes_up() {
         let mut s = TcpStream::connect(addr).unwrap();
         let s2 = s.clone();
         let (tx, rx) = channel();
-        spawn(proc() {
+        spawn(move|| {
             let mut s2 = s2;
             assert!(s2.read(&mut [0]).is_err());
             tx.send(());
@@ -1236,7 +1236,7 @@ fn readwrite_timeouts() {
         let addr = next_test_ip6();
         let mut a = TcpListener::bind(addr).listen().unwrap();
         let (tx, rx) = channel::<()>();
-        spawn(proc() {
+        spawn(move|| {
             let mut s = TcpStream::connect(addr).unwrap();
             rx.recv();
             assert!(s.write(&[0]).is_ok());
@@ -1269,7 +1269,7 @@ fn read_timeouts() {
         let addr = next_test_ip6();
         let mut a = TcpListener::bind(addr).listen().unwrap();
         let (tx, rx) = channel::<()>();
-        spawn(proc() {
+        spawn(move|| {
             let mut s = TcpStream::connect(addr).unwrap();
             rx.recv();
             let mut amt = 0;
@@ -1298,7 +1298,7 @@ fn write_timeouts() {
         let addr = next_test_ip6();
         let mut a = TcpListener::bind(addr).listen().unwrap();
         let (tx, rx) = channel::<()>();
-        spawn(proc() {
+        spawn(move|| {
             let mut s = TcpStream::connect(addr).unwrap();
             rx.recv();
             assert!(s.write(&[0]).is_ok());
@@ -1326,7 +1326,7 @@ fn timeout_concurrent_read() {
         let addr = next_test_ip6();
         let mut a = TcpListener::bind(addr).listen().unwrap();
         let (tx, rx) = channel::<()>();
-        spawn(proc() {
+        spawn(move|| {
             let mut s = TcpStream::connect(addr).unwrap();
             rx.recv();
             assert_eq!(s.write(&[0]), Ok(()));
@@ -1336,7 +1336,7 @@ fn timeout_concurrent_read() {
         let mut s = a.accept().unwrap();
         let s2 = s.clone();
         let (tx2, rx2) = channel();
-        spawn(proc() {
+        spawn(move|| {
             let mut s2 = s2;
             assert_eq!(s2.read(&mut [0]), Ok(1));
             tx2.send(());
@@ -1359,7 +1359,7 @@ fn clone_while_reading() {
         let (tx, rx) = channel();
         let (txdone, rxdone) = channel();
         let txdone2 = txdone.clone();
-        spawn(proc() {
+        spawn(move|| {
             let mut tcp = TcpStream::connect(addr).unwrap();
             rx.recv();
             tcp.write_u8(0).unwrap();
@@ -1370,7 +1370,7 @@ fn clone_while_reading() {
         let tcp = accept.accept().unwrap();
         let tcp2 = tcp.clone();
         let txdone3 = txdone.clone();
-        spawn(proc() {
+        spawn(move|| {
             let mut tcp2 = tcp2;
             tcp2.read_u8().unwrap();
             txdone3.send(());
@@ -1396,10 +1396,10 @@ fn clone_accept_smoke() {
         let mut a = l.listen().unwrap();
         let mut a2 = a.clone();
 
-        spawn(proc() {
+        spawn(move|| {
             let _ = TcpStream::connect(addr);
         });
-        spawn(proc() {
+        spawn(move|| {
             let _ = TcpStream::connect(addr);
         });
 
@@ -1417,13 +1417,13 @@ fn clone_accept_concurrent() {
         let (tx, rx) = channel();
         let tx2 = tx.clone();
 
-        spawn(proc() { let mut a = a; tx.send(a.accept()) });
-        spawn(proc() { let mut a = a2; tx2.send(a.accept()) });
+        spawn(move|| { let mut a = a; tx.send(a.accept()) });
+        spawn(move|| { let mut a = a2; tx2.send(a.accept()) });
 
-        spawn(proc() {
+        spawn(move|| {
             let _ = TcpStream::connect(addr);
         });
-        spawn(proc() {
+        spawn(move|| {
             let _ = TcpStream::connect(addr);
         });
 
@@ -1449,7 +1449,7 @@ fn close_accept_concurrent() {
         let mut a2 = a.clone();
 
         let (tx, rx) = channel();
-        spawn(proc() {
+        spawn(move|| {
             let mut a = a;
             tx.send(a.accept());
         });
index b23921ba3594d7382a86e801a1ea545af918de6d..78951b8dae2b041246689810491fd256f90dbfa5 100644 (file)
@@ -272,7 +272,7 @@ fn socket_smoke_test_ip4() {
         let (tx1, rx1) = channel();
         let (tx2, rx2) = channel();
 
-        spawn(proc() {
+        spawn(move|| {
             match UdpSocket::bind(client_ip) {
                 Ok(ref mut client) => {
                     rx1.recv();
@@ -307,7 +307,7 @@ fn socket_smoke_test_ip6() {
         let client_ip = next_test_ip6();
         let (tx, rx) = channel::<()>();
 
-        spawn(proc() {
+        spawn(move|| {
             match UdpSocket::bind(client_ip) {
                 Ok(ref mut client) => {
                     rx.recv();
@@ -343,7 +343,7 @@ fn stream_smoke_test_ip4() {
         let (tx1, rx1) = channel();
         let (tx2, rx2) = channel();
 
-        spawn(proc() {
+        spawn(move|| {
             let send_as = |ip, val: &[u8]| {
                 match UdpSocket::bind(ip) {
                     Ok(client) => {
@@ -387,7 +387,7 @@ fn stream_smoke_test_ip6() {
         let (tx1, rx1) = channel();
         let (tx2, rx2) = channel();
 
-        spawn(proc() {
+        spawn(move|| {
             match UdpSocket::bind(client_ip) {
                 Ok(client) => {
                     let client = box client;
@@ -449,7 +449,7 @@ fn udp_clone_smoke() {
         let mut sock1 = UdpSocket::bind(addr1).unwrap();
         let sock2 = UdpSocket::bind(addr2).unwrap();
 
-        spawn(proc() {
+        spawn(move|| {
             let mut sock2 = sock2;
             let mut buf = [0, 0];
             assert_eq!(sock2.recv_from(&mut buf), Ok((1, addr1)));
@@ -461,7 +461,7 @@ fn udp_clone_smoke() {
 
         let (tx1, rx1) = channel();
         let (tx2, rx2) = channel();
-        spawn(proc() {
+        spawn(move|| {
             let mut sock3 = sock3;
             rx1.recv();
             sock3.send_to(&[1], addr2).unwrap();
@@ -482,7 +482,7 @@ fn udp_clone_two_read() {
         let (tx1, rx) = channel();
         let tx2 = tx1.clone();
 
-        spawn(proc() {
+        spawn(move|| {
             let mut sock2 = sock2;
             sock2.send_to(&[1], addr1).unwrap();
             rx.recv();
@@ -493,7 +493,7 @@ fn udp_clone_two_read() {
         let sock3 = sock1.clone();
 
         let (done, rx) = channel();
-        spawn(proc() {
+        spawn(move|| {
             let mut sock3 = sock3;
             let mut buf = [0, 0];
             sock3.recv_from(&mut buf).unwrap();
@@ -517,7 +517,7 @@ fn udp_clone_two_write() {
         let (tx, rx) = channel();
         let (serv_tx, serv_rx) = channel();
 
-        spawn(proc() {
+        spawn(move|| {
             let mut sock2 = sock2;
             let mut buf = [0, 1];
 
@@ -533,7 +533,7 @@ fn udp_clone_two_write() {
 
         let (done, rx) = channel();
         let tx2 = tx.clone();
-        spawn(proc() {
+        spawn(move|| {
             let mut sock3 = sock3;
             match sock3.send_to(&[1], addr2) {
                 Ok(..) => { let _ = tx2.send_opt(()); }
@@ -560,7 +560,7 @@ fn recv_from_timeout() {
 
         let (tx, rx) = channel();
         let (tx2, rx2) = channel();
-        spawn(proc() {
+        spawn(move|| {
             let mut a = UdpSocket::bind(addr2).unwrap();
             assert_eq!(a.recv_from(&mut [0]), Ok((1, addr1)));
             assert_eq!(a.send_to(&[0], addr1), Ok(()));
index 41676cdf6e9cc704e8fc3d1d6014dfd05e51c328..73a893c4f2dcddd64196f5719af557e3ec42e034 100644 (file)
@@ -123,7 +123,7 @@ fn partial_read() {
         let out = PipeStream::open(writer);
         let mut input = PipeStream::open(reader);
         let (tx, rx) = channel();
-        spawn(proc() {
+        spawn(move|| {
             let mut out = out;
             out.write(&[10]).unwrap();
             rx.recv(); // don't close the pipe until the other read has finished
index c46a6e82e448661d3181b0f29535377fc1498760..9ba6381c8c3b3941b78400eccf0e3882c7407ff1 100644 (file)
@@ -693,7 +693,7 @@ pub fn wait_with_output(mut self) -> IoResult<ProcessOutput> {
         fn read(stream: Option<io::PipeStream>) -> Receiver<IoResult<Vec<u8>>> {
             let (tx, rx) = channel();
             match stream {
-                Some(stream) => spawn(proc() {
+                Some(stream) => spawn(move |:| {
                     let mut stream = stream;
                     tx.send(stream.read_to_end())
                 }),
@@ -1155,14 +1155,14 @@ fn wait_timeout() {
     fn wait_timeout2() {
         let (tx, rx) = channel();
         let tx2 = tx.clone();
-        spawn(proc() {
+        spawn(move|| {
             let mut p = sleeper();
             p.set_timeout(Some(10));
             assert_eq!(p.wait().err().unwrap().kind, TimedOut);
             p.signal_kill().unwrap();
             tx.send(());
         });
-        spawn(proc() {
+        spawn(move|| {
             let mut p = sleeper();
             p.set_timeout(Some(10));
             assert_eq!(p.wait().err().unwrap().kind, TimedOut);
index 8438c9fb441ed7476f5ac701a9a0a6062bc4274d..344012a09a0e39d99e4d445e04db3400a5d445dc 100644 (file)
@@ -528,7 +528,7 @@ fn capture_stdout() {
 
         let (tx, rx) = channel();
         let (mut r, w) = (ChanReader::new(rx), ChanWriter::new(tx));
-        spawn(proc() {
+        spawn(move|| {
             set_stdout(box w);
             println!("hello!");
         });
@@ -542,7 +542,7 @@ fn capture_stderr() {
 
         let (tx, rx) = channel();
         let (mut r, w) = (ChanReader::new(rx), ChanWriter::new(tx));
-        spawn(proc() {
+        spawn(move|| {
             ::realstd::io::stdio::set_stderr(box w);
             panic!("my special message");
         });
index ad02b534d04c647de4572bc41c4748519882a906..79048c37ab5bbb5bb22017ea965c0ce52149736b 100644 (file)
@@ -357,7 +357,7 @@ fn closing_channel_during_drop_doesnt_kill_everything() {
         let mut timer = Timer::new().unwrap();
         let timer_rx = timer.periodic(Duration::milliseconds(1000));
 
-        spawn(proc() {
+        spawn(move|| {
             let _ = timer_rx.recv_opt();
         });
 
@@ -371,7 +371,7 @@ fn reset_doesnt_switch_tasks() {
         let mut timer = Timer::new().unwrap();
         let timer_rx = timer.periodic(Duration::milliseconds(1000));
 
-        spawn(proc() {
+        spawn(move|| {
             let _ = timer_rx.recv_opt();
         });
 
@@ -384,7 +384,7 @@ fn reset_doesnt_switch_tasks2() {
         let mut timer = Timer::new().unwrap();
         let timer_rx = timer.periodic(Duration::milliseconds(1000));
 
-        spawn(proc() {
+        spawn(move|| {
             let _ = timer_rx.recv_opt();
         });
 
index 76419bee41c221c26aa8d6407fd65ae090572959..900c223c70bd319319818abe3a4ed6b3e00bce4e 100644 (file)
@@ -358,8 +358,8 @@ macro_rules! vec[
 /// # fn long_running_task() {}
 /// # fn calculate_the_answer() -> int { 42i }
 ///
-/// spawn(proc() { long_running_task(); tx1.send(()) });
-/// spawn(proc() { tx2.send(calculate_the_answer()) });
+/// spawn(move|| { long_running_task(); tx1.send(()) });
+/// spawn(move|| { tx2.send(calculate_the_answer()) });
 ///
 /// select! (
 ///     () = rx1.recv() => println!("the long running task finished first"),
index 3daba53cd866eb3b823853b85d6ce61597f53d4c..4041a6f60d71d06ebd1c8f450db56bd95879a16b 100644 (file)
@@ -515,17 +515,17 @@ fn test_opt_paths() {
     #[test]
     fn test_null_byte() {
         use task;
-        let result = task::try(proc() {
+        let result = task::try(move|| {
             Path::new(b"foo/bar\0")
         });
         assert!(result.is_err());
 
-        let result = task::try(proc() {
+        let result = task::try(move|| {
             Path::new("test").set_filename(b"f\0o")
         });
         assert!(result.is_err());
 
-        let result = task::try(proc() {
+        let result = task::try(move|| {
             Path::new("test").push(b"f\0o");
         });
         assert!(result.is_err());
index e1b0d9b139542e39dc4fa775f713c58abc924323..3983e365ae1f6cb6a7b89d54afbbd3a40d4165e1 100644 (file)
@@ -1299,17 +1299,17 @@ fn test_opt_paths() {
     #[test]
     fn test_null_byte() {
         use task;
-        let result = task::try(proc() {
+        let result = task::try(move|| {
             Path::new(b"foo/bar\0")
         });
         assert!(result.is_err());
 
-        let result = task::try(proc() {
+        let result = task::try(move|| {
             Path::new("test").set_filename(b"f\0o")
         });
         assert!(result.is_err());
 
-        let result = task::try(proc() {
+        let result = task::try(move|| {
             Path::new("test").push(b"f\0o");
         });
         assert!(result.is_err());
index 37628b65388e7d20266838e50c06072e7fd0fd50..5405892535cfec99e99d1dd335c4521c78ac5e51 100644 (file)
@@ -355,7 +355,7 @@ fn test_os_rng_tasks() {
         for _ in range(0u, 20) {
             let (tx, rx) = channel();
             txs.push(tx);
-            task::spawn(proc() {
+            task::spawn(move|| {
                 // wait until all the tasks are ready to go.
                 rx.recv();
 
index 2bb551881138284d11e77c26ae0347a4a182e9b2..fe5b962fa4b7499d402d16987b47c0a0aaf10c7d 100644 (file)
@@ -47,7 +47,7 @@
 //!     let spinlock = Arc::new(AtomicUint::new(1));
 //!
 //!     let spinlock_clone = spinlock.clone();
-//!     spawn(proc() {
+//!     spawn(move|| {
 //!         spinlock_clone.store(0, SeqCst);
 //!     });
 //!
@@ -68,7 +68,7 @@
 //!     let shared_big_object = Arc::new(AtomicOption::empty());
 //!
 //!     let shared_big_object_clone = shared_big_object.clone();
-//!     spawn(proc() {
+//!     spawn(move|| {
 //!         let unwrapped_big_object = shared_big_object_clone.take(SeqCst);
 //!         if unwrapped_big_object.is_some() {
 //!             println!("got a big object from another task");
index 5e6dc6ec650836ebe204a9d90d591ca5b631587c..1b8574604a0c1a8d22ea046d02d7b40990cfa77c 100644 (file)
@@ -21,7 +21,7 @@
 ///     let c = barrier.clone();
 ///     // The same messages will be printed together.
 ///     // You will NOT see any interleaving.
-///     spawn(proc() {
+///     spawn(move|| {
 ///         println!("before wait");
 ///         c.wait();
 ///         println!("after wait");
@@ -94,7 +94,7 @@ fn test_barrier() {
         for _ in range(0u, 9) {
             let c = barrier.clone();
             let tx = tx.clone();
-            spawn(proc() {
+            spawn(move|| {
                 c.wait();
                 tx.send(true);
             });
index 0fdd57b27922c50d5e9068eb8a20bc413e1f45cb..3bdab261e1957c21c8fe3e249d33de046d5748aa 100644 (file)
@@ -41,7 +41,7 @@
 /// let pair2 = pair.clone();
 ///
 /// // Inside of our lock, spawn a new thread, and then wait for it to start
-/// spawn(proc() {
+/// spawn(move|| {
 ///     let &(ref lock, ref cvar) = &*pair2;
 ///     let mut started = lock.lock();
 ///     *started = true;
@@ -282,7 +282,7 @@ fn notify_one() {
         static M: StaticMutex = MUTEX_INIT;
 
         let g = M.lock();
-        spawn(proc() {
+        spawn(move|| {
             let _g = M.lock();
             C.notify_one();
         });
@@ -300,7 +300,7 @@ fn notify_all() {
         for _ in range(0, N) {
             let data = data.clone();
             let tx = tx.clone();
-            spawn(proc() {
+            spawn(move|| {
                 let &(ref lock, ref cond) = &*data;
                 let mut cnt = lock.lock();
                 *cnt += 1;
@@ -334,7 +334,7 @@ fn wait_timeout() {
 
         let g = M.lock();
         assert!(!C.wait_timeout(&g, Duration::nanoseconds(1000)));
-        spawn(proc() {
+        spawn(move|| {
             let _g = M.lock();
             C.notify_one();
         });
@@ -351,7 +351,7 @@ fn two_mutexes() {
         static C: StaticCondvar = CONDVAR_INIT;
 
         let g = M1.lock();
-        spawn(proc() {
+        spawn(move|| {
             let _g = M1.lock();
             C.notify_one();
         });
index 4e07d54c57e7d6b79b20be42006e4492180b05d1..33f8d254c71a41e1e1f2197dbd8eef9bac45fdef 100644 (file)
@@ -47,7 +47,7 @@
 /// let (tx, rx) = channel();
 /// for _ in range(0u, 10) {
 ///     let (data, tx) = (data.clone(), tx.clone());
-///     spawn(proc() {
+///     spawn(move|| {
 ///         // The shared static can only be accessed once the lock is held.
 ///         // Our non-atomic increment is safe because we're the only thread
 ///         // which can access the shared state when the lock is held.
@@ -313,9 +313,9 @@ fn inc() {
         let (tx, rx) = channel();
         for _ in range(0, K) {
             let tx2 = tx.clone();
-            spawn(proc() { inc(); tx2.send(()); });
+            spawn(move|| { inc(); tx2.send(()); });
             let tx2 = tx.clone();
-            spawn(proc() { inc(); tx2.send(()); });
+            spawn(move|| { inc(); tx2.send(()); });
         }
 
         drop(tx);
@@ -339,7 +339,7 @@ fn test_mutex_arc_condvar() {
         let arc = Arc::new((Mutex::new(false), Condvar::new()));
         let arc2 = arc.clone();
         let (tx, rx) = channel();
-        spawn(proc() {
+        spawn(move|| {
             // wait until parent gets in
             rx.recv();
             let &(ref lock, ref cvar) = &*arc2;
@@ -364,7 +364,7 @@ fn test_arc_condvar_poison() {
         let arc2 = arc.clone();
         let (tx, rx) = channel();
 
-        spawn(proc() {
+        spawn(move|| {
             rx.recv();
             let &(ref lock, ref cvar) = &*arc2;
             let _g = lock.lock();
@@ -386,7 +386,7 @@ fn test_arc_condvar_poison() {
     fn test_mutex_arc_poison() {
         let arc = Arc::new(Mutex::new(1i));
         let arc2 = arc.clone();
-        let _ = task::try(proc() {
+        let _ = task::try(move|| {
             let lock = arc2.lock();
             assert_eq!(*lock, 2);
         });
@@ -401,7 +401,7 @@ fn test_mutex_arc_nested() {
         let arc = Arc::new(Mutex::new(1i));
         let arc2 = Arc::new(Mutex::new(arc));
         let (tx, rx) = channel();
-        spawn(proc() {
+        spawn(move|| {
             let lock = arc2.lock();
             let lock2 = lock.deref().lock();
             assert_eq!(*lock2, 1);
@@ -414,7 +414,7 @@ fn test_mutex_arc_nested() {
     fn test_mutex_arc_access_in_unwind() {
         let arc = Arc::new(Mutex::new(1i));
         let arc2 = arc.clone();
-        let _ = task::try::<()>(proc() {
+        let _ = task::try(move|| -> () {
             struct Unwinder {
                 i: Arc<Mutex<int>>,
             }
index 1bcdc760fc6803ccd8869a7986f6c7fde59455e9..263937c5cbec75e3941a8556301a1e4c98aa67cb 100644 (file)
@@ -142,7 +142,7 @@ fn stampede_once() {
         let (tx, rx) = channel();
         for _ in range(0u, 10) {
             let tx = tx.clone();
-            spawn(proc() {
+            spawn(move|| {
                 for _ in range(0u, 4) { task::deschedule() }
                 unsafe {
                     O.doit(|| {
index a4f8b1df6af527a188db0e848c9886fca164e4ec..b6d6aa989c58e7e163531a1f07176c21ed5a4726 100644 (file)
@@ -387,7 +387,7 @@ fn frob() {
         let (tx, rx) = channel::<()>();
         for _ in range(0, N) {
             let tx = tx.clone();
-            spawn(proc() {
+            spawn(move|| {
                 let mut rng = rand::task_rng();
                 for _ in range(0, M) {
                     if rng.gen_weighted_bool(N) {
@@ -409,7 +409,7 @@ fn frob() {
     fn test_rw_arc_poison_wr() {
         let arc = Arc::new(RWLock::new(1i));
         let arc2 = arc.clone();
-        let _ = task::try(proc() {
+        let _ = task::try(move|| {
             let lock = arc2.write();
             assert_eq!(*lock, 2);
         });
@@ -422,7 +422,7 @@ fn test_rw_arc_poison_wr() {
     fn test_rw_arc_poison_ww() {
         let arc = Arc::new(RWLock::new(1i));
         let arc2 = arc.clone();
-        let _ = task::try(proc() {
+        let _ = task::try(move|| {
             let lock = arc2.write();
             assert_eq!(*lock, 2);
         });
@@ -434,7 +434,7 @@ fn test_rw_arc_poison_ww() {
     fn test_rw_arc_no_poison_rr() {
         let arc = Arc::new(RWLock::new(1i));
         let arc2 = arc.clone();
-        let _ = task::try(proc() {
+        let _ = task::try(move|| {
             let lock = arc2.read();
             assert_eq!(*lock, 2);
         });
@@ -445,7 +445,7 @@ fn test_rw_arc_no_poison_rr() {
     fn test_rw_arc_no_poison_rw() {
         let arc = Arc::new(RWLock::new(1i));
         let arc2 = arc.clone();
-        let _ = task::try(proc() {
+        let _ = task::try(move|| {
             let lock = arc2.read();
             assert_eq!(*lock, 2);
         });
@@ -459,7 +459,7 @@ fn test_rw_arc() {
         let arc2 = arc.clone();
         let (tx, rx) = channel();
 
-        task::spawn(proc() {
+        task::spawn(move|| {
             let mut lock = arc2.write();
             for _ in range(0u, 10) {
                 let tmp = *lock;
@@ -474,7 +474,7 @@ fn test_rw_arc() {
         let mut children = Vec::new();
         for _ in range(0u, 5) {
             let arc3 = arc.clone();
-            children.push(task::try_future(proc() {
+            children.push(task::try_future(move|| {
                 let lock = arc3.read();
                 assert!(*lock >= 0);
             }));
@@ -495,7 +495,7 @@ fn test_rw_arc() {
     fn test_rw_arc_access_in_unwind() {
         let arc = Arc::new(RWLock::new(1i));
         let arc2 = arc.clone();
-        let _ = task::try::<()>(proc() {
+        let _ = task::try(move|| -> () {
             struct Unwinder {
                 i: Arc<RWLock<int>>,
             }
index 03fb84c38d470889ee04909afb8e758f38c3869b..574b0f22bee00ab40e30ac3219553f5fab90ceba 100644 (file)
@@ -127,7 +127,7 @@ fn test_sem_basic() {
     fn test_sem_as_mutex() {
         let s = Arc::new(Semaphore::new(1));
         let s2 = s.clone();
-        spawn(proc() {
+        spawn(move|| {
             let _g = s2.access();
         });
         let _g = s.access();
@@ -139,7 +139,7 @@ fn test_sem_as_cvar() {
         let (tx, rx) = channel();
         let s = Arc::new(Semaphore::new(0));
         let s2 = s.clone();
-        spawn(proc() {
+        spawn(move|| {
             s2.acquire();
             tx.send(());
         });
@@ -150,7 +150,7 @@ fn test_sem_as_cvar() {
         let (tx, rx) = channel();
         let s = Arc::new(Semaphore::new(0));
         let s2 = s.clone();
-        spawn(proc() {
+        spawn(move|| {
             s2.release();
             let _ = rx.recv();
         });
@@ -166,7 +166,7 @@ fn test_sem_multi_resource() {
         let s2 = s.clone();
         let (tx1, rx1) = channel();
         let (tx2, rx2) = channel();
-        spawn(proc() {
+        spawn(move|| {
             let _g = s2.access();
             let _ = rx2.recv();
             tx1.send(());
@@ -183,7 +183,7 @@ fn test_sem_runtime_friendly_blocking() {
         let (tx, rx) = channel();
         {
             let _g = s.access();
-            spawn(proc() {
+            spawn(move|| {
                 tx.send(());
                 drop(s2.access());
                 tx.send(());
index a684c6502aee9839098f758c39f2b9f1f337663b..fa5b62a202bfdcb9223125010f6da41fd47efb33 100644 (file)
 
 use core::prelude::*;
 
-use task::spawn;
+use task::{spawn};
 use comm::{channel, Sender, Receiver};
 use sync::{Arc, Mutex};
+use thunk::Thunk;
 
 struct Sentinel<'a> {
-    jobs: &'a Arc<Mutex<Receiver<proc(): Send>>>,
+    jobs: &'a Arc<Mutex<Receiver<Thunk>>>,
     active: bool
 }
 
 impl<'a> Sentinel<'a> {
-    fn new(jobs: &Arc<Mutex<Receiver<proc(): Send>>>) -> Sentinel {
+    fn new(jobs: &Arc<Mutex<Receiver<Thunk>>>) -> Sentinel {
         Sentinel {
             jobs: jobs,
             active: true
@@ -60,7 +61,7 @@ fn drop(&mut self) {
 /// let (tx, rx) = channel();
 /// for _ in range(0, 8u) {
 ///     let tx = tx.clone();
-///     pool.execute(proc() {
+///     pool.execute(move|| {
 ///         tx.send(1u);
 ///     });
 /// }
@@ -146,7 +147,7 @@ fn test_works() {
         let (tx, rx) = channel();
         for _ in range(0, TEST_TASKS) {
             let tx = tx.clone();
-            pool.execute(proc() {
+            pool.execute(move|| {
                 tx.send(1u);
             });
         }
@@ -168,14 +169,14 @@ fn test_recovery_from_subtask_panic() {
 
         // Panic all the existing tasks.
         for _ in range(0, TEST_TASKS) {
-            pool.execute(proc() { panic!() });
+            pool.execute(move|| -> () { panic!() });
         }
 
         // Ensure new tasks were spawned to compensate.
         let (tx, rx) = channel();
         for _ in range(0, TEST_TASKS) {
             let tx = tx.clone();
-            pool.execute(proc() {
+            pool.execute(move|| {
                 tx.send(1u);
             });
         }
@@ -193,7 +194,7 @@ fn test_should_not_panic_on_drop_if_subtasks_panic_after_drop() {
         // Panic all the existing tasks in a bit.
         for _ in range(0, TEST_TASKS) {
             let waiter = waiter.clone();
-            pool.execute(proc() {
+            pool.execute(move|| {
                 waiter.wait();
                 panic!();
             });
index 6c5fc3005edd27b38ecad8b9e5dd387925512279..96b4accd4bd03e9da10f262a7b1afe2be4f42bee 100644 (file)
@@ -83,7 +83,7 @@ pub fn boot<T, F>(&'static self, f: F, helper: fn(helper_signal::signal, Receive
                 *self.signal.get() = send as uint;
 
                 let t = f();
-                task::spawn(proc() {
+                task::spawn(move |:| {
                     bookkeeping::decrement();
                     helper(receive, rx, t);
                     let _g = self.lock.lock();
@@ -91,7 +91,7 @@ pub fn boot<T, F>(&'static self, f: F, helper: fn(helper_signal::signal, Receive
                     self.cond.notify_one()
                 });
 
-                rustrt::at_exit(proc() { self.shutdown() });
+                rustrt::at_exit(move|:| { self.shutdown() });
                 *self.initialized.get() = true;
             }
         }
index f71b34304abd65409e968109aa9f389cf46f5cf8..4ef1757cc3acae855d46e4d28cc78556ee1d66ba 100644 (file)
@@ -94,8 +94,8 @@ unsafe fn set_cloexec(fd: c_int) {
             mem::transmute::<&ProcessConfig<K,V>,&'static ProcessConfig<K,V>>(cfg)
         };
 
-        with_envp(cfg.env(), proc(envp) {
-            with_argv(cfg.program(), cfg.args(), proc(argv) unsafe {
+        with_envp(cfg.env(), move|: envp: *const c_void| {
+            with_argv(cfg.program(), cfg.args(), move|: argv: *const *const libc::c_char| unsafe {
                 let (input, mut output) = try!(sys::os::pipe());
 
                 // We may use this in the child, so perform allocations before the
index b841f6d3a2b2ff68199e83f1193ddec9cf5aa203..969b322af991f0a81a29675394e1fdb9dbc0393a 100644 (file)
@@ -131,7 +131,7 @@ fn init_dtors() {
         DTORS = mem::transmute(dtors);
     }
 
-    rustrt::at_exit(proc() unsafe {
+    rustrt::at_exit(move|| unsafe {
         mem::transmute::<_, Box<Exclusive<Vec<(Key, Dtor)>>>>(DTORS);
         DTORS = 0 as *mut _;
     });
index b85b6eccb771821f09410be45ec26c42bbed2abe..2d5766c2393c97831ce5fe94334ae9d13fa135ef 100644 (file)
@@ -77,7 +77,7 @@
 /// });
 ///
 /// // each thread starts out with the initial value of 1
-/// spawn(proc() {
+/// spawn(move|| {
 ///     FOO.with(|f| {
 ///         assert_eq!(*f.borrow(), 1);
 ///         *f.borrow_mut() = 3;
@@ -471,7 +471,7 @@ fn smoke_no_dtor() {
             *f.get() = 2;
         });
         let (tx, rx) = channel();
-        spawn(proc() {
+        spawn(move|| {
             FOO.with(|f| unsafe {
                 assert_eq!(*f.get(), 1);
             });
@@ -491,7 +491,7 @@ fn smoke_dtor() {
         })
 
         let (tx, rx) = channel();
-        spawn(proc() unsafe {
+        spawn(move|| unsafe {
             let mut tx = Some(tx);
             FOO.with(|f| {
                 *f.get() = Some(Foo(tx.take().unwrap()));
@@ -539,7 +539,7 @@ fn drop(&mut self) {
             }
         }
 
-        Thread::start(proc() {
+        Thread::start(move|| {
             drop(S1);
         }).join();
     }
@@ -557,7 +557,7 @@ fn drop(&mut self) {
             }
         }
 
-        Thread::start(proc() unsafe {
+        Thread::start(move|| unsafe {
             K1.with(|s| *s.get() = Some(S1));
         }).join();
     }
@@ -584,7 +584,7 @@ fn drop(&mut self) {
         }
 
         let (tx, rx) = channel();
-        spawn(proc() unsafe {
+        spawn(move|| unsafe {
             let mut tx = Some(tx);
             K1.with(|s| *s.get() = Some(S1(tx.take().unwrap())));
         });
index 7436a8af30765d17ad1d47132cb9ab566a72608d..211c5906f4533b774cd1d7153b63d6e1d73ccd5a 100644 (file)
@@ -32,7 +32,7 @@
        html_root_url = "http://doc.rust-lang.org/nightly/")]
 
 #![feature(asm, macro_rules, phase, globs, slicing_syntax)]
-#![feature(unboxed_closures)]
+#![feature(unboxed_closures, default_type_params)]
 
 extern crate getopts;
 extern crate regex;
@@ -71,6 +71,7 @@
 use std::string::String;
 use std::task::TaskBuilder;
 use std::time::Duration;
+use std::thunk::{Thunk, Invoke};
 
 // to be used by rustc to compile tests in libtest
 pub mod test {
@@ -149,9 +150,9 @@ pub trait TDynBenchFn {
 pub enum TestFn {
     StaticTestFn(fn()),
     StaticBenchFn(fn(&mut Bencher)),
-    StaticMetricFn(proc(&mut MetricMap):'static),
-    DynTestFn(proc():Send),
-    DynMetricFn(proc(&mut MetricMap):'static),
+    StaticMetricFn(fn(&mut MetricMap)),
+    DynTestFn(Thunk),
+    DynMetricFn(Box<for<'a> Invoke<&'a mut MetricMap>+'static>),
     DynBenchFn(Box<TDynBenchFn+'static>)
 }
 
@@ -1119,8 +1120,8 @@ pub fn run_test(opts: &TestOpts,
     fn run_test_inner(desc: TestDesc,
                       monitor_ch: Sender<MonitorMsg>,
                       nocapture: bool,
-                      testfn: proc():Send) {
-        spawn(proc() {
+                      testfn: Thunk) {
+        spawn(move || {
             let (tx, rx) = channel();
             let mut reader = ChanReader::new(rx);
             let stdout = ChanWriter::new(tx.clone());
@@ -1135,7 +1136,7 @@ fn run_test_inner(desc: TestDesc,
                 task = task.stdout(box stdout as Box<Writer + Send>);
                 task = task.stderr(box stderr as Box<Writer + Send>);
             }
-            let result_future = task.try_future(testfn);
+            let result_future = task.try_future(move || testfn.invoke(()));
 
             let stdout = reader.read_to_end().unwrap().into_iter().collect();
             let task_result = result_future.into_inner();
@@ -1157,7 +1158,7 @@ fn run_test_inner(desc: TestDesc,
         }
         DynMetricFn(f) => {
             let mut mm = MetricMap::new();
-            f(&mut mm);
+            f.invoke(&mut mm);
             monitor_ch.send((desc, TrMetrics(mm), Vec::new()));
             return;
         }
@@ -1169,7 +1170,7 @@ fn run_test_inner(desc: TestDesc,
         }
         DynTestFn(f) => run_test_inner(desc, monitor_ch, opts.nocapture, f),
         StaticTestFn(f) => run_test_inner(desc, monitor_ch, opts.nocapture,
-                                          proc() f())
+                                          Thunk::new(move|| f()))
     }
 }
 
@@ -1467,6 +1468,7 @@ mod tests {
                Improvement, Regression, LikelyNoise,
                StaticTestName, DynTestName, DynTestFn, ShouldFail};
     use std::io::TempDir;
+    use std::thunk::Thunk;
 
     #[test]
     pub fn do_not_run_ignored_tests() {
@@ -1477,7 +1479,7 @@ pub fn do_not_run_ignored_tests() {
                 ignore: true,
                 should_fail: ShouldFail::No,
             },
-            testfn: DynTestFn(proc() f()),
+            testfn: DynTestFn(Thunk::new(move|| f())),
         };
         let (tx, rx) = channel();
         run_test(&TestOpts::new(), false, desc, tx);
@@ -1494,7 +1496,7 @@ fn f() { }
                 ignore: true,
                 should_fail: ShouldFail::No,
             },
-            testfn: DynTestFn(proc() f()),
+            testfn: DynTestFn(Thunk::new(move|| f())),
         };
         let (tx, rx) = channel();
         run_test(&TestOpts::new(), false, desc, tx);
@@ -1511,7 +1513,7 @@ fn test_should_fail() {
                 ignore: false,
                 should_fail: ShouldFail::Yes(None)
             },
-            testfn: DynTestFn(proc() f()),
+            testfn: DynTestFn(Thunk::new(move|| f())),
         };
         let (tx, rx) = channel();
         run_test(&TestOpts::new(), false, desc, tx);
@@ -1528,7 +1530,7 @@ fn test_should_fail_good_message() {
                 ignore: false,
                 should_fail: ShouldFail::Yes(Some("error message"))
             },
-            testfn: DynTestFn(proc() f()),
+            testfn: DynTestFn(Thunk::new(move|| f())),
         };
         let (tx, rx) = channel();
         run_test(&TestOpts::new(), false, desc, tx);
@@ -1545,7 +1547,7 @@ fn test_should_fail_bad_message() {
                 ignore: false,
                 should_fail: ShouldFail::Yes(Some("foobar"))
             },
-            testfn: DynTestFn(proc() f()),
+            testfn: DynTestFn(Thunk::new(move|| f())),
         };
         let (tx, rx) = channel();
         run_test(&TestOpts::new(), false, desc, tx);
@@ -1562,7 +1564,7 @@ fn f() { }
                 ignore: false,
                 should_fail: ShouldFail::Yes(None)
             },
-            testfn: DynTestFn(proc() f()),
+            testfn: DynTestFn(Thunk::new(move|| f())),
         };
         let (tx, rx) = channel();
         run_test(&TestOpts::new(), false, desc, tx);
@@ -1608,7 +1610,7 @@ pub fn filter_for_ignored_option() {
                     ignore: true,
                     should_fail: ShouldFail::No,
                 },
-                testfn: DynTestFn(proc() {}),
+                testfn: DynTestFn(Thunk::new(move|| {})),
             },
             TestDescAndFn {
                 desc: TestDesc {
@@ -1616,7 +1618,7 @@ pub fn filter_for_ignored_option() {
                     ignore: false,
                     should_fail: ShouldFail::No,
                 },
-                testfn: DynTestFn(proc() {}),
+                testfn: DynTestFn(Thunk::new(move|| {})),
             });
         let filtered = filter_tests(&opts, tests);
 
@@ -1652,7 +1654,7 @@ fn testfn() { }
                         ignore: false,
                         should_fail: ShouldFail::No,
                     },
-                    testfn: DynTestFn(testfn),
+                    testfn: DynTestFn(Thunk::new(testfn)),
                 };
                 tests.push(test);
             }
@@ -1693,7 +1695,7 @@ fn test_fn() {}
                     ignore: false,
                     should_fail: ShouldFail::No,
                 },
-                testfn: DynTestFn(test_fn)
+                testfn: DynTestFn(Thunk::new(test_fn))
             }
         }).collect();
         let filtered = filter_tests(&opts, tests);
index 88692cf3f5e3c15f339bb2609eae598627859c15..1cccb0f7ccbe66b75a83c6c2ee2bd432fb5e54a3 100644 (file)
@@ -12,7 +12,7 @@
 
 pub fn foo<T:Send + Clone>(x: T) -> Receiver<T> {
     let (tx, rx) = channel();
-    task::spawn(proc() {
+    task::spawn(move|| {
         tx.send(x.clone());
     });
     rx
index cea03f13a4bbd306c38340ac87c28892eecaec1e..f20fb8d0cd75e3322a0c8980dc17cddbc14bb2f3 100644 (file)
@@ -64,7 +64,7 @@ fn run(args: &[String]) {
         let mut worker_results = Vec::new();
         for _ in range(0u, workers) {
             let to_child = to_child.clone();
-            worker_results.push(task::try_future(proc() {
+            worker_results.push(task::try_future(move|| {
                 for _ in range(0u, size / workers) {
                     //println!("worker {}: sending {} bytes", i, num_bytes);
                     to_child.send(request::bytes(num_bytes));
@@ -72,7 +72,7 @@ fn run(args: &[String]) {
                 //println!("worker {} exiting", i);
             }));
         }
-        task::spawn(proc() {
+        task::spawn(move|| {
             server(&from_parent, &to_parent);
         });
 
index 476e7d42d45bb7cbf693e1c702c1dc1b7f9294e8..179011be8bf4efd8749d79df88dc10b07ca1aa37 100644 (file)
@@ -58,7 +58,7 @@ fn run(args: &[String]) {
         let mut worker_results = Vec::new();
         let from_parent = if workers == 1 {
             let (to_child, from_parent) = channel();
-            worker_results.push(task::try_future(proc() {
+            worker_results.push(task::try_future(move|| {
                 for _ in range(0u, size / workers) {
                     //println!("worker {}: sending {} bytes", i, num_bytes);
                     to_child.send(request::bytes(num_bytes));
@@ -70,7 +70,7 @@ fn run(args: &[String]) {
             let (to_child, from_parent) = channel();
             for _ in range(0u, workers) {
                 let to_child = to_child.clone();
-                worker_results.push(task::try_future(proc() {
+                worker_results.push(task::try_future(move|| {
                     for _ in range(0u, size / workers) {
                         //println!("worker {}: sending {} bytes", i, num_bytes);
                         to_child.send(request::bytes(num_bytes));
@@ -80,7 +80,7 @@ fn run(args: &[String]) {
             }
             from_parent
         };
-        task::spawn(proc() {
+        task::spawn(move|| {
             server(&from_parent, &to_parent);
         });
 
index 863c3c879a7c108009e14604233c2dddfd962168..49f53bf9d3883ec555497d40fd3dc23c6f5be2da 100644 (file)
@@ -89,7 +89,7 @@ fn main() {
             //println!("spawning %?", i);
             let (new_chan, num_port) = init();
             let num_chan_2 = num_chan.clone();
-            let new_future = Future::spawn(proc() {
+            let new_future = Future::spawn(move|| {
                 thread_ring(i, msg_per_task, num_chan_2, num_port)
             });
             futures.push(new_future);
index b00adf4bdb1d4d1321490cc64882b343c36cbe2a..73d54372b274f0aa0330bf89f7e3a2e508360912 100644 (file)
@@ -34,7 +34,7 @@ fn run_pair(n: uint) {
         // Create a stream B->A
         let (btx, brx) = channel::<()>();
 
-        spawn(proc() {
+        spawn(move|| {
             let (tx, rx) = (atx, brx);
             for _ in range(0, n) {
                 tx.send(());
@@ -42,7 +42,7 @@ fn run_pair(n: uint) {
             }
         });
 
-        spawn(proc() {
+        spawn(move|| {
             let (tx, rx) = (btx, arx);
             for _ in range(0, n) {
                 rx.recv();
index 4072dc0064afba5ebe7db90a5a9ba86fd8f7ba22..bdf22cd7395889aa8647f252189a6aeb8674f73c 100644 (file)
@@ -21,7 +21,7 @@ fn parfib(n: uint) -> uint {
     }
 
     let (tx, rx) = channel();
-    spawn(proc() {
+    spawn(move|| {
         tx.send(parfib(n-1));
     });
     let m2 = parfib(n-2);
index 509cb37b2e6ff0cd7b76ff11980b15bf3eaa364b..0b16e8011e8323975d96ef792b8070b18aff1610 100644 (file)
@@ -95,7 +95,7 @@ fn main() {
     let mut messages = range_step(min_depth, max_depth + 1, 2).map(|depth| {
             use std::num::Int;
             let iterations = 2i.pow((max_depth - depth + min_depth) as uint);
-            Future::spawn(proc() {
+            Future::spawn(move|| {
                 let mut chk = 0;
                 for i in range(1, iterations + 1) {
                     let arena = TypedArena::new();
index e954d0fed5e593e323a1a07757bc97ed7e6d7b4c..dcdb90a11c88ca89f48261efc52dc48d5c60a596 100644 (file)
@@ -188,7 +188,7 @@ fn rendezvous(nn: uint, set: Vec<Color>) {
             let to_rendezvous = to_rendezvous.clone();
             let to_rendezvous_log = to_rendezvous_log.clone();
             let (to_creature, from_rendezvous) = channel();
-            spawn(proc() {
+            spawn(move|| {
                 creature(ii,
                          col,
                          from_rendezvous,
index 4b890bbd8d30e94cf18d4c2daa014e936203ceb2..4849421a3f01eceaebe07fdab4cbed2afadb1ef1 100644 (file)
@@ -168,7 +168,7 @@ fn fannkuch(n: i32) -> (i32, i32) {
     for (i, j) in range(0, N).zip(iter::count(0, k)) {
         let max = cmp::min(j+k, perm.max());
 
-        futures.push(Future::spawn(proc() {
+        futures.push(Future::spawn(move|| {
             work(perm, j as uint, max as uint)
         }))
     }
index 45d2cbea8fad985d7f52a8d3bd9b25a788998c9d..8c11c3673d5274ebc4bf2b990fae29a47760c0f0 100644 (file)
@@ -168,7 +168,7 @@ fn main() {
 
         let (to_child, from_parent) = channel();
 
-        spawn(proc() {
+        spawn(move|| {
             make_sequence_processor(sz, &from_parent, &to_parent_);
         });
 
index 847ae2c1c88cc0722ec0275a9109edc0280e97c9..d112fe60674dadc4fec5d379cffbbe2cbd00c145 100644 (file)
@@ -303,11 +303,11 @@ fn main() {
 
     let nb_freqs: Vec<(uint, Future<Table>)> = range(1u, 3).map(|i| {
         let input = input.clone();
-        (i, Future::spawn(proc() generate_frequencies(input.as_slice(), i)))
+        (i, Future::spawn(move|| generate_frequencies(input.as_slice(), i)))
     }).collect();
     let occ_freqs: Vec<Future<Table>> = OCCURRENCES.iter().map(|&occ| {
         let input = input.clone();
-        Future::spawn(proc() generate_frequencies(input.as_slice(), occ.len()))
+        Future::spawn(move|| generate_frequencies(input.as_slice(), occ.len()))
     }).collect();
 
     for (i, freq) in nb_freqs.into_iter() {
index 454b445dea0dc171cefde4ea7165578d738eb992..bb0e09370d8e9e7b3492e6ea4906f20ef2acdddb 100644 (file)
@@ -82,7 +82,7 @@ fn mandelbrot<W: io::Writer>(w: uint, mut out: W) -> io::IoResult<()> {
     let mut precalc_i = Vec::with_capacity(h);
 
     let precalc_futures = Vec::from_fn(WORKERS, |i| {
-        Future::spawn(proc () {
+        Future::spawn(move|| {
             let mut rs = Vec::with_capacity(w / WORKERS);
             let mut is = Vec::with_capacity(w / WORKERS);
 
@@ -123,7 +123,7 @@ fn mandelbrot<W: io::Writer>(w: uint, mut out: W) -> io::IoResult<()> {
         let vec_init_r = arc_init_r.clone();
         let vec_init_i = arc_init_i.clone();
 
-        Future::spawn(proc () {
+        Future::spawn(move|| {
             let mut res: Vec<u8> = Vec::with_capacity((chunk_size * w) / 8);
             let init_r_slice = vec_init_r.as_slice();
 
index ca749d47b63bd23b32444f4609fda3d85c983044..9a3b6953062b4464e42effd44e77d84fa87ef300 100644 (file)
@@ -310,7 +310,7 @@ fn par_search(masks: Vec<Vec<Vec<u64>>>) -> Data {
         let masks = masks.clone();
         let tx = tx.clone();
         let m = *m;
-        spawn(proc() {
+        spawn(move|| {
             let mut data = Data::new();
             search(&*masks, m, 1, List::Cons(m, &List::Nil), &mut data);
             tx.send(data);
index 15a5cb0c9bfffcbf01f95c2a2544805443541086..fae6d2cc3aa65c72359f9a5d96f529fd786caed2 100644 (file)
@@ -34,15 +34,15 @@ fn pfib(tx: &Sender<int>, n: int) {
         } else {
             let (tx1, rx) = channel();
             let tx2 = tx1.clone();
-            task::spawn(proc() pfib(&tx2, n - 1));
+            task::spawn(move|| pfib(&tx2, n - 1));
             let tx2 = tx1.clone();
-            task::spawn(proc() pfib(&tx2, n - 2));
+            task::spawn(move|| pfib(&tx2, n - 2));
             tx.send(rx.recv() + rx.recv());
         }
     }
 
     let (tx, rx) = channel();
-    spawn(proc() pfib(&tx, n) );
+    spawn(move|| pfib(&tx, n) );
     rx.recv()
 }
 
@@ -77,7 +77,7 @@ fn stress_task(id: int) {
 fn stress(num_tasks: int) {
     let mut results = Vec::new();
     for i in range(0, num_tasks) {
-        results.push(task::try_future(proc() {
+        results.push(task::try_future(move|| {
             stress_task(i);
         }));
     }
index 81de7a1269067b3d89dfab65ef19ce881532dfd8..9b8fd51c1c5dd8974acd199dfbb650bee9fb28bc 100644 (file)
@@ -72,7 +72,7 @@ fn main() {
     let seq_arc = Arc::new(seq.clone()); // copy before it moves
     let clen = seq.len();
 
-    let mut seqlen = Future::spawn(proc() {
+    let mut seqlen = Future::spawn(move|| {
         let substs = vec![
             (regex!("B"), "(c|g|t)"),
             (regex!("D"), "(a|g|t)"),
@@ -108,7 +108,7 @@ fn main() {
     for variant in variants.into_iter() {
         let seq_arc_copy = seq_arc.clone();
         variant_strs.push(variant.to_string());
-        counts.push(Future::spawn(proc() {
+        counts.push(Future::spawn(move|| {
             count_matches(seq_arc_copy.as_slice(), &variant)
         }));
     }
index ffe5739e0bb5e41f573172b7979b6f474c7a3019..312ee2dd27e4d3c0306d5263ad15047beabb7ec7 100644 (file)
@@ -236,7 +236,7 @@ fn parallel<'a, I, T, F>(mut iter: I, f: F)
         // boundary.
         let f = &f as *const F as *const uint;
         let raw = chunk.repr();
-        spawn(proc() {
+        spawn(move|| {
             let f = f as *const F;
             unsafe { (*f)(mem::transmute(raw)) }
             drop(tx)
index f76391b596bb3855021f9e2c7cd39df7f9a66bfc..647c47b00a0b725e4f679db5a95775755e01ecd4 100644 (file)
@@ -124,7 +124,7 @@ fn parallel<'a, T, F>(v: &'a mut [T], f: F)
         // boundary.
         let f = &f as *const _ as *const uint;
         let raw = chunk.repr();
-        spawn(proc() {
+        spawn(move|| {
             let f = f as *const F;
             unsafe { (*f)(i * size, mem::transmute(raw)) }
             drop(tx)
index cda0feb8b55a312d8eccd92bf576201c78b9daca..111a92b083aa38aa4d74cb2f4af9a9a183981f15 100644 (file)
@@ -43,10 +43,10 @@ fn start(n_tasks: int, token: int) {
     tx.send(token);
     for i in range(2, n_tasks + 1) {
         let (tx, next_rx) = channel();
-        spawn(proc() roundtrip(i, tx, rx));
+        spawn(move|| roundtrip(i, tx, rx));
         rx = next_rx;
     }
-    spawn(proc() roundtrip(1, tx, rx));
+    spawn(move|| roundtrip(1, tx, rx));
 }
 
 fn roundtrip(id: int, tx: Sender<int>, rx: Receiver<int>) {
index b55f471bdb24d40f6f7619b4b592c18dcd6eca8e..ca36d99014cf4b530b8a2805ed9c683da7df13ba 100644 (file)
@@ -10,5 +10,5 @@
 
 // Useful for checking syscall usage of baseline scheduler usage
 fn main() {
-    spawn(proc() {});
+    spawn(move|| {});
 }
index 77078b2c68d390cdfd93e4aa5fd01dde5a44285a..8bcf30b4859ff0852fedc99318f6c12821938229 100644 (file)
@@ -36,7 +36,7 @@ fn main() {
 fn run(repeat: int, depth: int) {
     for _ in range(0, repeat) {
         let dur = Duration::span(|| {
-            task::try(proc() {
+            task::try(move|| {
                 recurse_or_panic(depth, None)
             });
         });
index 3d2822e14597ff4d8400eb88144d19ac367c1d61..789ccb6142a118ee238c47b7e2ab1b2915e8106e 100644 (file)
@@ -26,7 +26,7 @@ fn child_generation(gens_left: uint, tx: comm::Sender<()>) {
     // This used to be O(n^2) in the number of generations that ever existed.
     // With this code, only as many generations are alive at a time as tasks
     // alive at a time,
-    spawn(proc() {
+    spawn(move|| {
         if gens_left & 1 == 1 {
             task::deschedule(); // shake things up a bit
         }
index 0f903be39223d7fae5c92621f581e81e72579ab6..e3b51cb6b5bfd2405967e3c8f983021bf9b75db5 100644 (file)
@@ -21,7 +21,7 @@ fn calc(children: uint, parent_wait_chan: &Sender<Sender<Sender<int>>>) {
 
     let wait_ports: Vec<Reciever<Sender<Sender<int>>>> = vec::from_fn(children, |_| {
         let (wait_port, wait_chan) = stream::<Sender<Sender<int>>>();
-        task::spawn(proc() {
+        task::spawn(move|| {
             calc(children / 2, &wait_chan);
         });
         wait_port
@@ -58,7 +58,7 @@ fn main() {
 
     let children = from_str::<uint>(args[1]).unwrap();
     let (wait_port, wait_chan) = stream();
-    task::spawn(proc() {
+    task::spawn(move|| {
         calc(children, &wait_chan);
     });
 
index 533005b1fb38c0c98d31943e36868a8a1c690bc7..a6852d396d9cf2f3c7bb721e386eb548c9a11863 100644 (file)
@@ -15,7 +15,7 @@
 fn f(n: uint) {
     let mut i = 0u;
     while i < n {
-        task::try(proc() g());
+        task::try(move|| g());
         i += 1u;
     }
 }
@@ -33,5 +33,5 @@ fn main() {
     };
     let n = from_str::<uint>(args[1].as_slice()).unwrap();
     let mut i = 0u;
-    while i < n { task::spawn(proc() f(n) ); i += 1u; }
+    while i < n { task::spawn(move|| f(n) ); i += 1u; }
 }
index b6ecb50fac873b8cff5d467b385560042cf2213a..cecb8a09c665ad1486e6a2a4bc02670fe82f7ca2 100644 (file)
@@ -17,7 +17,7 @@ fn borrow(v: &int, f: |x: &int|) {
 fn box_imm() {
     let v = box 3i;
     let _w = &v;
-    task::spawn(proc() {
+    task::spawn(move|| {
         println!("v={}", *v);
         //~^ ERROR cannot move `v` into closure
     });
@@ -26,7 +26,7 @@ fn box_imm() {
 fn box_imm_explicit() {
     let v = box 3i;
     let _w = &v;
-    task::spawn(proc() {
+    task::spawn(move|| {
         println!("v={}", *v);
         //~^ ERROR cannot move
     });
index c52924ebdb789b3408556bb9ecdf424b7ad49b26..aae661e5c537937bbd6849e1385c4b288eafbb32 100644 (file)
@@ -11,6 +11,6 @@
 pub fn main() {
     let bar = box 3;
     let _g = || {
-        let _h: proc() -> int = proc() *bar; //~ ERROR cannot move out of captured outer variable
+        let _h = move|| -> int { *bar }; //~ ERROR cannot move out of captured outer variable
     };
 }
index b385305d74aaabf6eb03e544072fe59625a2b9c7..ca484738cb6c887a2611536469a2cee41307cc1f 100644 (file)
@@ -8,13 +8,13 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-fn call_f(f: proc() -> int) -> int {
+fn call_f<F:FnOnce() -> int>(f: F) -> int {
     f()
 }
 
 fn main() {
     let t = box 3;
 
-    call_f(proc() { *t + 1 });
-    call_f(proc() { *t + 1 }); //~ ERROR capture of moved value
+    call_f(move|| { *t + 1 });
+    call_f(move|| { *t + 1 }); //~ ERROR capture of moved value
 }
index 6faa634ad00b842499424ec3b8551e836db281e2..a9c368fb052583331d9ccff96ade666c1ad63394 100644 (file)
@@ -17,7 +17,7 @@ fn different_vars_after_borrows() {
     let p1 = &x1;
     let x2 = box 2i;
     let p2 = &x2;
-    task::spawn(proc() {
+    task::spawn(move|| {
         drop(x1); //~ ERROR cannot move `x1` into closure because it is borrowed
         drop(x2); //~ ERROR cannot move `x2` into closure because it is borrowed
     });
@@ -30,7 +30,7 @@ fn different_vars_after_moves() {
     drop(x1);
     let x2 = box 2i;
     drop(x2);
-    task::spawn(proc() {
+    task::spawn(move|| {
         drop(x1); //~ ERROR capture of moved value: `x1`
         drop(x2); //~ ERROR capture of moved value: `x2`
     });
@@ -39,7 +39,7 @@ fn different_vars_after_moves() {
 fn same_var_after_borrow() {
     let x = box 1i;
     let p = &x;
-    task::spawn(proc() {
+    task::spawn(move|| {
         drop(x); //~ ERROR cannot move `x` into closure because it is borrowed
         drop(x); //~ ERROR use of moved value: `x`
     });
@@ -49,7 +49,7 @@ fn same_var_after_borrow() {
 fn same_var_after_move() {
     let x = box 1i;
     drop(x);
-    task::spawn(proc() {
+    task::spawn(move|| {
         drop(x); //~ ERROR capture of moved value: `x`
         drop(x); //~ ERROR use of moved value: `x`
     });
index daad1afedaaeae10308c5e52b1c4c24956d7c9d3..143e78e5d9f00f7fdc7dcffcbbe69a2bbaf3225b 100644 (file)
 
 fn main() {
     let x = 1i;
-    proc() { x = 2; };
-    //~^ ERROR: cannot assign to immutable captured outer variable in a proc `x`
+    move|:| { x = 2; };
+    //~^ ERROR: cannot assign to immutable captured outer variable
 
     let s = std::io::stdin();
-    proc() { s.read_to_end(); };
-    //~^ ERROR: cannot borrow immutable captured outer variable in a proc `s` as mutable
+    move|:| { s.read_to_end(); };
+    //~^ ERROR: cannot borrow immutable captured outer variable
 }
index 9f258aee746f2312643c467075e59878ccc26feb..27e339180a6cffe2b4f4c26bf088ad7d584fcc61 100644 (file)
@@ -12,10 +12,8 @@ fn foo() {}
 
 fn main() {
     let f = foo;
+
     let f_closure: || = f;
     //~^ ERROR: cannot coerce non-statically resolved bare fn to closure
     //~^^ HELP: consider embedding the function in a closure
-    let f_proc: proc() = f;
-    //~^ ERROR: cannot coerce non-statically resolved bare fn to closure
-    //~^^ HELP: consider embedding the function in a closure
 }
index 9141ab669bbc22fd06b809eef035f53985d44192..c90f064bf904c7acf6ed1e352a35e3a275cae959 100644 (file)
@@ -10,7 +10,7 @@
 
 fn main() {
     let x = box 1i;
-    let f: proc() = proc() {
+    let f = move|:| {
         let _a = x;
         drop(x);
         //~^ ERROR: use of moved value: `x`
index 82cd38ad5b0438ab349c3bee45aaf70d105827c4..46fcb2ec340f9cafdf017d823802006ca28bc644 100644 (file)
@@ -9,10 +9,10 @@
 // except according to those terms.
 
 struct Test<'s> {
-    func: ||: 's,
+    func: Box<FnMut()+'static>
 }
 
 fn main() {
-    let test = box Test { func: proc() {} };
-    //~^ ERROR: expected `||`, found `proc()`
+    let closure: Box<Fn()+'static> = box || ();
+    let test = box Test { func: closure }; //~ ERROR mismatched types
 }
index 5d62c25ea171b776ad56ef993509a28e90afbbdf..c561f0a696a9f33f7f9c73365b81027589e53646 100644 (file)
@@ -11,7 +11,7 @@
 fn main() {
     let r = {
         let x = box 42i;
-        let f = proc() &x; //~ ERROR: `x` does not live long enough
+        let f = move|:| &x; //~ ERROR: `x` does not live long enough
         f()
     };
 
index f824a06aed1b3912d66c3b00f6f8e736aecba81f..1878b5f5dea8d670c561eeacdf4c1bb59200b66b 100644 (file)
@@ -10,7 +10,7 @@
 
 fn main() {
     let (tx, rx) = channel();
-    spawn(proc() {
+    spawn(move|| {
         loop {
             let tx = tx;
             //~^ ERROR: use of moved value: `tx`
index 788924257702978d37d2345edb8a9f3a6c5827e6..5f2837d28755de1c5969e9f2ee3bce9108683d9a 100644 (file)
@@ -8,9 +8,12 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+fn do_it(x: &int) { }
+
 fn main() {
-    let f = proc() {};
-    (proc() {
+    let x = box 22;
+    let f = move|:| do_it(&*x);
+    (move|:| {
         f();
         f();
         //~^ ERROR: use of moved value: `f`
index d694fd2c79512a6d8c3ddd50e461265eda3d5d61..c96054afc2f311c8ba09f92fb166dcc913adbe5b 100644 (file)
 
 fn foo(_x: Rc<uint>) {}
 
-fn bar() {
-    let x = Rc::new(3u);
-    let _: proc():Send = proc() foo(x); //~ ERROR `core::kinds::Send` is not implemented
-}
+fn bar<F:FnOnce() + Send>(_: F) { }
 
-fn bar2() {
+fn main() {
     let x = Rc::new(3u);
-    let _: proc() = proc() foo(x);
+    bar(move|| foo(x)); //~ ERROR `core::kinds::Send` is not implemented
 }
 
-fn main() { }
index 4fbb3eab8c416234b10de8ef08ff6c2fc036cf35..3b67e98f42ca81d55e51967c243fa74a41952ef5 100644 (file)
@@ -27,10 +27,6 @@ fn box_object_with_no_bound_not_ok<'a>() {
     assert_send::<Box<Dummy>>(); //~ ERROR the trait `core::kinds::Send` is not implemented
 }
 
-fn proc_with_no_bound_not_ok<'a>() {
-    assert_send::<proc()>(); //~ ERROR the trait `core::kinds::Send` is not implemented
-}
-
 fn closure_with_no_bound_not_ok<'a>() {
     assert_send::<||:'static>(); //~ ERROR the trait `core::kinds::Send` is not implemented
 }
@@ -38,7 +34,6 @@ fn closure_with_no_bound_not_ok<'a>() {
 fn object_with_send_bound_ok() {
     assert_send::<&'static (Dummy+Send)>();
     assert_send::<Box<Dummy+Send>>();
-    assert_send::<proc():Send>;
     assert_send::<||:Send>;
 }
 
index 35e928d417c3b164ac6feefa3fb9cd5661d6abfa..d83a8031c45db51c016cb01553f53f006139d237 100644 (file)
@@ -35,11 +35,6 @@ fn test61() {
 
 // closure and object types can have lifetime bounds which make
 // them not ok
-fn test_70<'a>() {
-    assert_send::<proc():'a>();
-    //~^ ERROR the trait `core::kinds::Send` is not implemented
-}
-
 fn test_71<'a>() {
     assert_send::<Box<Dummy+'a>>();
     //~^ ERROR the trait `core::kinds::Send` is not implemented
index 97287c147d73f2d8f7da88bde0c2a923c23bb46b..458e2aaf451a0483e183b7addfc0b20951d359f0 100644 (file)
@@ -12,7 +12,7 @@
 
 fn main() {
     let x = "Hello world!".to_string();
-    task::spawn(proc() {
+    task::spawn(move|| {
         println!("{}", x);
     });
     println!("{}", x); //~ ERROR use of moved value
index 74e5e6b12027f2e8bc2e1e7e06b62c0b01ca1881..2cf7618d92dbc93f96d063d156fdaafdb3d19cb4 100644 (file)
@@ -9,7 +9,7 @@
 // except according to those terms.
 
 
-type Noncopyable = proc():'static;
+type Noncopyable = Box<int>;
 
 struct Foo {
     copied: int,
index a07317176e410e48df90a758147dd5339999c90c..affe979268d21c85d28bc0167b531f7d28d6f981 100644 (file)
@@ -17,7 +17,7 @@ fn main() {
     let v = vec!(1i, 2, 3, 4, 5, 6, 7, 8, 9, 10);
     let arc_v = Arc::new(v);
 
-    task::spawn(proc() {
+    task::spawn(move|| {
         assert_eq!((*arc_v)[3], 4);
     });
 
index 9f33f35838e2794de43214b27caa748e406d1602..60982a84b791e9e48a35474e778c63014b431312 100644 (file)
@@ -15,7 +15,7 @@ fn main() {
     let v = vec!(1i, 2, 3, 4, 5, 6, 7, 8, 9, 10);
     let arc_v = Arc::new(v);
 
-    task::spawn(proc() {
+    task::spawn(move|| {
         assert_eq!((*arc_v)[3], 4);
     });
 
index 83dbd9ac1bf7282687c0575710d36425891508e3..e1ba36de7c0324357766cd392cb559521a59432d 100644 (file)
@@ -35,9 +35,9 @@ fn foo(x: Port<()>) -> foo {
 
     let x = foo(Port(Rc::new(())));
 
-    task::spawn(proc() {
-        let y = x;
+    task::spawn(move|| {
         //~^ ERROR `core::kinds::Send` is not implemented
+        let y = x;
         println!("{}", y);
     });
 }
index 68687773f278fd361121d3c5deeba369b006e2ee..6441f308f29c6f079f4bce6c163f83d856b35bb1 100644 (file)
 #![feature(once_fns)]
 use std::sync::Arc;
 
-fn foo(blk: proc()) {
+fn foo<F:FnOnce()>(blk: F) {
     blk();
     blk(); //~ ERROR use of moved value
 }
 
 fn main() {
     let x = Arc::new(true);
-    foo(proc() {
+    foo(move|| {
         assert!(*x);
         drop(x);
     });
index ec679a7dda170991168c02b259ce2d419e20bc44..67655f323f06533ca91e12571b3147cfaff4521f 100644 (file)
@@ -66,11 +66,6 @@ fn object_with_send_bound_not_ok<'a>() {
     //~^ ERROR declared lifetime bound not satisfied
 }
 
-fn proc_with_lifetime_not_ok<'a>() {
-    assert_send::<proc():'a>();
-    //~^ ERROR not implemented
-}
-
 fn closure_with_lifetime_not_ok<'a>() {
     assert_send::<||:'a>();
     //~^ ERROR not implemented
index 7fe85290da0ecf5355f3f2e866de52f07654fdc2..8b2fdfe7cdd1547c1b3abb712cc06fb2bbc6ae54 100644 (file)
 // Test that, when a variable of type `&T` is captured inside a proc,
 // we correctly infer/require that its lifetime is 'static.
 
-fn foo(_p: proc():'static) { }
+fn foo<F:FnOnce()+'static>(_p: F) { }
 
 static i: int = 3;
 
 fn capture_local() {
     let x = 3i;
     let y = &x; //~ ERROR `x` does not live long enough
-    foo(proc() {
+    foo(move|| {
         let _a = *y;
     });
 }
@@ -26,7 +26,7 @@ fn capture_local() {
 fn capture_static() {
     // Legal because &i can have static lifetime:
     let y = &i;
-    foo(proc() {
+    foo(move|| {
         let _a = *y;
     });
 }
diff --git a/src/test/compile-fail/regions-infer-region-in-fn-but-not-type.rs b/src/test/compile-fail/regions-infer-region-in-fn-but-not-type.rs
deleted file mode 100644 (file)
index 0fa4969..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-
-// check that the &int here does not cause us to think that `foo`
-// contains region pointers
-struct foo(proc(x: &int):'static);
-
-fn take_foo(x: foo<'static>) {} //~ ERROR wrong number of lifetime parameters
-
-fn main() {
-}
index e32ef2752566bb6c14cfd646e1347b9ccd55c6d7..0841c1852f8830120f7095a5ffab70084e77e434 100644 (file)
@@ -8,19 +8,15 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-fn borrowed_proc<'a>(x: &'a int) -> proc():'a -> int {
+fn borrowed_proc<'a>(x: &'a int) -> Box<FnMut()->(int) + 'a> {
     // This is legal, because the region bound on `proc`
     // states that it captures `x`.
-    proc() {
-        *x
-    }
+    box move|| { *x }
 }
 
-fn static_proc<'a>(x: &'a int) -> proc():'static -> int {
+fn static_proc(x: &int) -> Box<FnMut()->(int) + 'static> {
     // This is illegal, because the region bound on `proc` is 'static.
-    proc() { //~ ERROR captured variable `x` outlives the `proc()`
-        *x
-    }
+    box move|| { *x } //~ ERROR cannot infer
 }
 
 fn main() { }
index 3a35d9cc309ab2f653e38b697e33abefce09d687..6cc45090b9024a70b73bb0273e326a1c57838ec2 100644 (file)
@@ -8,8 +8,10 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-// error-pattern: mismatched types
-
 use std::task;
 
-fn main() { task::spawn(|| -> int { 10 }); }
+fn main() {
+    // We get an error because return type is `->int` and not `->()`.
+    task::spawn(|| -> int { 10 });
+    //~^ ERROR type mismatch
+}
diff --git a/src/test/compile-fail/unboxed-closure-feature-gate.rs b/src/test/compile-fail/unboxed-closure-feature-gate.rs
new file mode 100644 (file)
index 0000000..9bb8037
--- /dev/null
@@ -0,0 +1,25 @@
+// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// Check that parenthetical notation is feature-gated except with the
+// `Fn` traits.
+
+trait Foo<A,R> {
+}
+
+fn main() {
+    let x: Box<Foo(int)>;
+    //~^ ERROR parenthetical notation is only stable when used with the `Fn` family
+
+    // No errors with these:
+    let x: Box<Fn(int)>;
+    let x: Box<FnMut(int)>;
+    let x: Box<FnOnce(int)>;
+}
index 4fa72b383067d5bca025e40a3492549ce980c8d0..ddd2649a3fee5f52ae7efe51ba880eb026b84d23 100644 (file)
@@ -12,6 +12,6 @@
 
 fn main() {
     let mut_ = |&mut: x| x;
-    mut_.call((0i, )); //~ ERROR type `closure` does not implement
+    mut_.call((0i, )); //~ ERROR does not implement any method in scope named `call`
 }
 
index a3db84b0ac65f671f64e4adb35c8f18f8a146071..2c000e03ce43aaa069dd111f7bc9e6df7d5c4f00 100644 (file)
@@ -13,5 +13,5 @@
 fn main() {
     let mut x = 1i;
     //~^ ERROR: variable does not need to be mutable
-    proc() { println!("{}", x); };
+    move|:| { println!("{}", x); };
 }
index 6ed6a2731257a886c5117151420cdf79fc8e7feb..fa7822495d5f15ede8117880cc1b546583fbd752 100644 (file)
@@ -77,7 +77,7 @@ fn main() {
     zzz(); // #break
     sentinel();
 
-    let unique_closure: proc(int) = proc(x) {
+    let unique_closure = |: x:int| {
         zzz(); // #break
         sentinel();
 
index e7664d1029bd8b47fb8e3950220693553765aa8a..d72b080409e1d43fa4dc942b99ab30a8de397bf1 100644 (file)
 
 
 // CLOSURES
-// gdb-command:whatis some_proc
-// gdb-check:type = struct (once proc(int, u8) -> (int, u8), uint)
-
 // gdb-command:whatis stack_closure1
 // gdb-check:type = struct (&mut|int|, uint)
 
@@ -322,8 +319,6 @@ fn main() {
     // how that maps to rustc's internal representation of these forms.
     // Once closures have reached their 1.0 form, the tests below should
     // probably be expanded.
-    let some_proc = (proc(a:int, b:u8) (a, b), 0u);
-
     let stack_closure1 = (|x:int| {}, 0u);
     let stack_closure2 = (|x:i8, y: f32| { (x as f32) + y }, 0u);
 
index eb20a09477d3cf9d642b841741590dc85c852d6f..328d4245eb61011acc5edbff4e2998a7356c513d 100644 (file)
@@ -13,7 +13,7 @@
 
 // pp-exact
 
-fn call_it(f: proc(String) -> String) { }
+fn call_it(f: Box<FnMut(String) -> String>) { }
 
 fn call_this(f: |&str|: Send) { }
 
index ffa6f03909b023a07eb3fabf491b41c96934b943..1313af2df3d88c742a5b11f7b9658ca6519157e4 100644 (file)
@@ -12,5 +12,4 @@
 
 fn from_foreign_fn(_x: fn()) { }
 fn from_stack_closure(_x: ||) { }
-fn from_unique_closure(_x: proc()) { }
 fn main() { }
index 21a332a46cb5976d38ed2ff93ba31ed658af2105..e7c6dcc2df7e7530fad6dfff4ebe7b72d7198a3b 100644 (file)
@@ -42,7 +42,7 @@ fn count(n: uint) -> uint {
 
 fn main() {
     for _ in range(0, 10u) {
-        task::spawn(proc() {
+        task::spawn(move|| {
             let result = count(5u);
             println!("result = %?", result);
             panic!();
index 3f8abc41ff74a472cb3b0a53318be28d2dc38291..b36383859320970a3b30f740110a6f9d9e5cdca1 100644 (file)
@@ -13,7 +13,7 @@
 use std::task;
 
 fn main() {
-    let r: Result<int,_> = task::try(proc() {
+    let r: Result<int,_> = task::try(move|| {
         panic!("test");
         1i
     });
index 0a303475a29ff1705b1aed7bdeb9fa94f43036c2..3c442861a44a3bad32cebe64751ad96c070fae0c 100644 (file)
@@ -14,7 +14,7 @@
 
 fn main() {
     let r: Result<int,_> = TaskBuilder::new().named("owned name".to_string())
-                                             .try(proc() {
+                                             .try(move|| {
         panic!("test");
         1i
     });
index fb4fb5c2f7081a949aa938d828e56de2f9ff237d..92ebb3b4587af6b277a3cfb8f71ecb6c482d8a60 100644 (file)
@@ -13,7 +13,7 @@
 fn main() {
     let r: Result<int,_> =
         ::std::task::TaskBuilder::new().named("send name".into_cow())
-                                       .try(proc() {
+                                       .try(move|| {
             panic!("test");
             3i
         });
index 21c019e1a7422f00b3a701665427afc8153d75eb..f8dfe9245b4389345a491d62428d84d5e7852509 100644 (file)
@@ -12,7 +12,7 @@
 
 fn main() {
     let r: Result<int,_> =
-        ::std::task::TaskBuilder::new().named("static name").try(proc() {
+        ::std::task::TaskBuilder::new().named("static name").try(move|| {
             panic!("test");
         });
     assert!(r.is_ok());
index 1cfc6c36a6397f844bd5d29cc870f242d637b608..58de34e92a09d3b8885b28c2f818ee1c8de24dcf 100644 (file)
@@ -36,7 +36,7 @@ fn r(x:int) -> r {
 
 fn main() {
     error!("whatever");
-    task::spawn(proc() {
+    task::spawn(move|| {
       let _i = r(5);
     });
     panic!();
index 34d9cc48ffe20385f40a344e1ba85bf36b816b8a..d2fd5393834ebfbd32ae83308bc9af0902448528 100644 (file)
 #![crate_type="dylib"]
 
 use std::rt;
+use std::thunk::Thunk;
 
 #[no_mangle] // this needs to get called from C
 pub extern "C" fn foo(argc: int, argv: *const *const u8) -> int {
-    rt::start(argc, argv, proc() {
-        spawn(proc() {
+    rt::start(argc, argv, Thunk::new(move|| {
+        spawn(move|| {
             println!("hello");
         });
-    })
+    }))
 }
index 9918fbb1ab70186db32aa26ae06df8007c97650c..e2cca4d11f9a93c24858270773804786fbf6a442 100644 (file)
@@ -22,7 +22,7 @@ fn drop(&mut self) {
 }
 
 fn main() {
-    task::try(proc() {
+    task::try(move|| {
         let _a = A;
         lib::callback(|| panic!());
         1i
index fd40f0b4b800299111d457e953788160d00a8668..b4e366296517416d9be41076e3c208f8b47cd8dd 100644 (file)
@@ -8,17 +8,11 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-fn asSendfn(f: proc() -> uint) -> uint {
-   return f();
-}
-
 fn asBlock(f: || -> uint) -> uint {
    return f();
 }
 
 pub fn main() {
-   let x = asSendfn(proc() 22u);
-   assert_eq!(x, 22u);
    let x = asBlock(|| 22u);
    assert_eq!(x, 22u);
 }
index 4b81654a1d0a2195f54e43b12161ce2cbb0d07e2..d017a0dbf9a3bb65d5e4a262efb5ac3015f4b506 100644 (file)
@@ -8,14 +8,6 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-fn inty(fun: proc(int) -> int) -> int {
-    fun(100)
-}
-
-fn booly(fun: proc(bool) -> bool) -> bool {
-    fun(true)
-}
-
 // Check usage and precedence of block arguments in expressions:
 pub fn main() {
     let v = vec!(-1.0f64, 0.0, 1.0, 2.0, 3.0);
index 48ddf927722a37ff0346cba2c88c69d2249a6da1..a6b142bb12654afeb387b0cb92530f291433b187 100644 (file)
@@ -8,8 +8,11 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+#![feature(unboxed_closures)]
+
 pub fn main() {
     let bar = box 3;
-    let h: proc() -> int = proc() *bar;
+    let h = |:| -> int *bar;
     assert_eq!(h(), 3);
 }
+
index a6744585e47a3ef240d88abc5c45b3e25110edff..f2df5ef38c382025e99b05302095b45ed58259a3 100644 (file)
@@ -32,7 +32,7 @@ fn log(&mut self, record: &LogRecord) {
 fn main() {
     let (tx, rx) = channel();
     let (mut r, w) = (ChanReader::new(rx), ChanWriter::new(tx));
-    spawn(proc() {
+    spawn(move|| {
         set_logger(box MyWriter(w) as Box<Logger+Send>);
         debug!("debug");
         info!("info");
index 82855729fa882ac69f19344332b27cd7ac7d180a..bdd92919ef05bfb23466daddfe1b9bd7ae42279b 100644 (file)
@@ -15,5 +15,5 @@
 fn child2(_s: String) { }
 
 pub fn main() {
-    let _x = task::spawn(proc() child2("hi".to_string()));
+    let _x = task::spawn(move|| child2("hi".to_string()));
 }
index f676a6f09594ea1c10bb72992bac2c33d75ad166..d3c703b258f73e3ec2978178bb714ff08256dd2d 100644 (file)
@@ -18,10 +18,8 @@ struct Pair {
 pub fn main() {
     let z = box Pair { a : 10, b : 12};
 
-    let f: proc():Send = proc() {
+    spawn(move|| {
         assert_eq!(z.a, 10);
         assert_eq!(z.b, 12);
-    };
-
-    spawn(f);
+    });
 }
index 3c4b7236ad50fd61898b0fa7a275db9d11433214..cdcdad47ea49782a7c5ac98ef013c535409478fb 100644 (file)
@@ -8,15 +8,17 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+#![feature(unboxed_closures)]
+
 use std::comm;
 
-fn foo(blk: proc()) {
+fn foo<F:FnOnce()+Send>(blk: F) {
     blk();
 }
 
 pub fn main() {
     let (tx, rx) = channel();
-    foo(proc() {
+    foo(move || {
         tx.send(());
     });
     rx.recv();
index aa4d48e5ae0e1f90de4bbe8ff0884a2b82479448..03d9511b41c78c31f95a897b81c0816154e6c1a8 100644 (file)
 /* Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/ */
 
+#![feature(unboxed_closures)]
+
 use std::mem;
 use std::io::stdio::println;
 
-fn call_it(f: proc(String) -> String) {
+fn call_it<F>(f: F)
+    where F : FnOnce(String) -> String
+{
     println!("{}", f("Fred".to_string()))
 }
 
@@ -49,15 +53,15 @@ pub fn main() {
     // Procs
 
     let greeting = "Hello ".to_string();
-    call_it(proc(s) {
+    call_it(|s| {
         format!("{}{}", greeting, s)
     });
 
     let greeting = "Goodbye ".to_string();
-    call_it(proc(s) format!("{}{}", greeting, s));
+    call_it(|s| format!("{}{}", greeting, s));
 
     let greeting = "How's life, ".to_string();
-    call_it(proc(s: String) -> String {
+    call_it(|s: String| -> String {
         format!("{}{}", greeting, s)
     });
 
index 6716c3468d0f84b67635c4fe94609021ffa2eb38..4caa234ac7ae325688aba6005c35beaa612b7101 100644 (file)
 
 fn foo<T>() {}
 
-trait Bar1 {}
-impl Bar1 for proc():'static {}
-
-trait Bar2 {}
-impl Bar2 for proc():Send {}
-
 trait Bar3 {}
 impl<'b> Bar3 for <'a>|&'a int|: 'b + Send -> &'a int {}
 
-trait Bar4 {}
-impl Bar4 for proc<'a>(&'a int):'static -> &'a int {}
-
 struct Foo<'a> {
     a: ||: 'a,
     b: ||: 'static,
     c: <'b>||: 'a,
     d: ||: 'a + Sync,
     e: <'b>|int|: 'a + Sync -> &'b f32,
-    f: proc():'static,
-    g: proc():'static+Sync,
-    h: proc<'b>(int):'static+Sync -> &'b f32,
 }
 
 fn f<'a>(a: &'a int, f: <'b>|&'b int| -> &'b int) -> &'a int {
     f(a)
 }
 
-fn g<'a>(a: &'a int, f: proc<'b>(&'b int) -> &'b int) -> &'a int {
-    f(a)
+fn g<'a>(a: &'a int) -> &'a int {
+    a
 }
 
 struct A;
@@ -60,11 +48,6 @@ fn bar<'b>() {
     foo::<||:'b + Sync>();
     foo::<||:Sync>();
     foo::< <'a>|int, f32, &'a int|:'b + Sync -> &'a int>();
-    foo::<proc()>();
-    foo::<proc() -> ()>();
-    foo::<proc():'static>();
-    foo::<proc():Sync>();
-    foo::<proc<'a>(int, f32, &'a int):'static + Sync -> &'a int>();
 
     foo::<<'a>||>();
 
@@ -84,7 +67,6 @@ fn bar<'b>() {
 
     // issue #13490
     let _ = || -> ! loop {};
-    let _ = proc() -> ! loop {};
 
     // issue #17021
     let c = box |&:| {};
index 6dbc402e7852cca702d5add501386bd42d436ab9..5a1b401177e01707fc4e51041754347209ad605f 100644 (file)
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+#![feature(unboxed_closures)]
+
 fn id<T>(x: T) -> T {
     x
 }
@@ -24,24 +26,12 @@ pub fn main() {
     let f: |int| -> int = id;
     assert_eq!(f(5), 5);
 
-    let f: proc(int) -> int = id;
-    assert_eq!(f(5), 5);
-
     let f: |int| -> Foo<int> = Foo;
     assert_eq!(f(5), Foo(5));
 
-    let f: proc(int) -> Foo<int> = Foo;
-    assert_eq!(f(5), Foo(5));
-
     let f: |int| -> Bar<int> = Bar::Baz;
     assert_eq!(f(5), Bar::Baz(5));
 
-    let f: proc(int) -> Bar<int> = Bar::Baz;
-    assert_eq!(f(5), Bar::Baz(5));
-
     let f: |int| -> Option<int> = Some;
     assert_eq!(f(5), Some(5));
-
-    let f: proc(int) -> Option<int> = Some;
-    assert_eq!(f(5), Some(5));
 }
index 18cc92f335dff8099b57f996915cd2e86e7a72c2..edd4d5642b5bf9ac7e58d0fde35ad6c13f8ce593 100644 (file)
@@ -12,7 +12,7 @@
 
 pub fn main() {
     let (tx, rx) = channel();
-    let _t = task::spawn(proc() { child(&tx) });
+    let _t = task::spawn(move|| { child(&tx) });
     let y = rx.recv();
     println!("received");
     println!("{}", y);
index d8dfb433e6d4910f36384fd5c8f1ded4330c86d7..4e625ce1d1f96646d305a3d39177070eace1a753 100644 (file)
@@ -84,7 +84,7 @@ pub fn test_destroy_actually_kills(force: bool) {
     let (tx, rx1) = channel();
     let mut t = timer::Timer::new().unwrap();
     let rx2 = t.oneshot(Duration::milliseconds(1000));
-    spawn(proc() {
+    spawn(move|| {
         select! {
             () = rx2.recv() => unsafe { libc::exit(1) },
             () = rx1.recv() => {}
index 15f028e1716f081232e198ce1d2d61b909b9cc06..24915d84e7eb1970d61a4b976b9cde878c9d4cdf 100644 (file)
@@ -65,7 +65,7 @@ pub fn main() {
     assert_eq!(receiver.recv_opt().ok(), None);
 
     let (sender, receiver) = channel();
-    task::spawn(proc() {
+    task::spawn(move|| {
         let v = Foo::FailingVariant { on_drop: SendOnDrop { sender: sender } };
     });
     assert_eq!(receiver.recv(), Message::Dropped);
@@ -73,7 +73,7 @@ pub fn main() {
 
     let (sender, receiver) = channel();
     {
-        task::spawn(proc() {
+        task::spawn(move|| {
             let mut v = Foo::NestedVariant(box 42u, SendOnDrop {
                 sender: sender.clone()
             }, sender.clone());
index 3e22c8331839306de32446ae5827da8fb4910f27..2d4819231fad0a9fb7d1be6e065446e4bcff64a6 100644 (file)
@@ -14,8 +14,7 @@
 trait Trait {}
 
 fn main() {
-    // Closures - || / proc()
-    assert_eq!(size_of::<proc()>(), size_of::<Option<proc()>>());
+    // Closures - ||
     assert_eq!(size_of::<||>(), size_of::<Option<||>>());
 
     // Functions
index eeda299c71fa6105234824ee21325b7765a3408d..87f1adba8ddcf494e24eb01a865591e1970a0fb9 100644 (file)
@@ -8,14 +8,6 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-/**
- * A function that returns a hash of a value
- *
- * The hash should concentrate entropy in the lower bits.
- */
-type HashFn<K> = proc(K):'static -> uint;
-type EqFn<K> = proc(K, K):'static -> bool;
-
 struct LM { resize_at: uint, size: uint }
 
 impl Copy for LM {}
index bc5ccc30c527c5298c472a046419b371b645b100..aed1392c8b68b9d9739b3c42387b6e365b0c33cc 100644 (file)
@@ -40,7 +40,7 @@ fn count(n: libc::uintptr_t) -> libc::uintptr_t {
 pub fn main() {
     // Make sure we're on a task with small Rust stacks (main currently
     // has a large stack)
-    task::spawn(proc() {
+    task::spawn(move|| {
         let result = count(1000);
         println!("result = {}", result);
         assert_eq!(result, 1000);
index ae9430370d52077900fe61a82adb771bd7f591a8..3f5faabe595983755f3ef090f32c7240625b0585 100644 (file)
@@ -44,7 +44,7 @@ fn count(n: libc::uintptr_t) -> libc::uintptr_t {
 pub fn main() {
     // Make sure we're on a task with small Rust stacks (main currently
     // has a large stack)
-    task::spawn(proc() {
+    task::spawn(move|| {
         let result = count(12);
         println!("result = {}", result);
         assert_eq!(result, 2048);
index 87d96880e4bd340a07fa837b0c03315d1b4c7abe..8b080712b966191230376da7f5b3f80b3c0ef134 100644 (file)
@@ -42,7 +42,7 @@ fn count(n: libc::uintptr_t) -> libc::uintptr_t {
 
 pub fn main() {
     for _ in range(0u, 100) {
-        task::spawn(proc() {
+        task::spawn(move|| {
             assert_eq!(count(5), 16);
         });
     }
index 7fb68e9f8a03863e92a93e70034d3e387229a2ac..1c89d8ae1ce9d2934f977d794b269b76f3b28b5c 100644 (file)
@@ -39,7 +39,7 @@ fn count(n: libc::uintptr_t) -> libc::uintptr_t {
 
 pub fn main() {
     for _ in range(0, 10u) {
-        task::spawn(proc() {
+        task::spawn(move|| {
             let result = count(5);
             println!("result = {}", result);
             assert_eq!(result, 16);
index af36387f06c2c9fb46d32ace369c0518507529ad..3f659f1dbfbf7fb93584a2bba9155b61e9b627b0 100644 (file)
@@ -22,7 +22,7 @@ fn rust_dbg_call(cb: extern "C" fn(libc::uintptr_t),
 
 pub fn main() {
     unsafe {
-        Thread::start(proc() {
+        Thread::start(move|| {
             let i = &100i;
             rust_dbg_call(callback, mem::transmute(i));
         }).join();
index 8efd3af4bcedbd5b9ed51231fd3b0a62d4e0dfc8..a92b361dd3355cd95933f941f2aa5048d74e3194 100644 (file)
@@ -37,7 +37,7 @@ fn start_mappers(ctrl: Sender<ctrl_proto>, inputs: Vec<String>) {
         for i in inputs.iter() {
             let ctrl = ctrl.clone();
             let i = i.clone();
-            task::spawn(proc() map_task(ctrl.clone(), i.clone()) );
+            task::spawn(move|| map_task(ctrl.clone(), i.clone()) );
         }
     }
 
index 02d3bc120da8c84a7ca5184678c34fa702dc3034..53749f09f741e86207186f9d84b20e9ee03f541a 100644 (file)
@@ -43,7 +43,5 @@ fn foo23(t: for<'a> unsafe extern "C" fn(int) -> int) { }
 fn foo30(t: for<'a> |int| -> int) { }
 fn foo31(t: for<'a> unsafe |int| -> int) { }
 
-//fn foo40(t: for<'a> proc(int) -> int) { }
-
 fn main() {
 }
index f4de938c66e7d9b0ee2a4d042ad03d13fc402625..e4168ea145212aa9afc0f219171b68c0a959cbb9 100644 (file)
@@ -15,7 +15,7 @@
 // ignore-test
 
 fn loopy(n: int) {
-    if n > 0 { spawn(proc() { loopy(n - 1) }); spawn(proc() { loopy(n - 1) }); }
+    if n > 0 { spawn(move|| { loopy(n - 1) }); spawn(move|| { loopy(n - 1) }); }
     loop { }
 }
 
@@ -23,5 +23,5 @@ pub fn main() {
     // Commenting this out, as this will hang forever otherwise.
     // Even after seeing the comment above, I'm not sure what the
     // intention of this test is.
-    // spawn(proc() { loopy(5) });
+    // spawn(move|| { loopy(5) });
 }
index f2f8b17daa264215d3419ccd3232c1b4a5fae115..fd0ad1ef47ecbf9c782557081cc71c727aba6c0a 100644 (file)
 // Regression test for issue #10682
 // Nested `proc` usage can't use outer owned data
 
-
 fn work(_: Box<int>) {}
-fn foo(_: proc()) {}
+fn foo<F:FnOnce()>(_: F) {}
 
 pub fn main() {
   let a = box 1;
-  foo(proc() { foo(proc() { work(a) }) })
+  foo(move|| { foo(move|| { work(a) }) })
 }
index 34804eda287cd675128475aafceb5caf683105e9..71b4cbe933427fc9175e6c395d85585bf2da4a08 100644 (file)
@@ -8,11 +8,13 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-fn f(p: proc()) {
+#![feature(unboxed_closures)]
+
+fn f<F:FnOnce()>(p: F) {
     p();
 }
 
 pub fn main() {
-    let p = proc() ();
+    let p = |:| ();
     f(p);
 }
index 0567a5836abfae4bfd0a9b75db64462aa449dc3a..f9d79567932971a6569347f1f9dd91656ef4ebc8 100644 (file)
 // when this bug was opened. The cases where the compiler
 // panics before the fix have a comment.
 
-struct S {x:()}
+#![feature(default_type_params)]
+
+use std::thunk::Thunk;
 
+struct S {x:()}
 
-fn test(slot: &mut Option<proc() -> proc()>, _: proc()) -> () {
+fn test(slot: &mut Option<Thunk<(),Thunk>>) -> () {
   let a = slot.take();
   let _a = match a {
     // `{let .. a(); }` would break
-    Some(a) => { let _a = a(); },
+    Some(a) => { let _a = a.invoke(()); },
     None => (),
   };
 }
@@ -41,7 +44,7 @@ pub fn main() {
     let _r = {};
     let mut slot = None;
     // `{ test(...); }` would break
-    let _s : S  = S{ x: { test(&mut slot, proc() {}); } };
+    let _s : S  = S{ x: { test(&mut slot); } };
 
     let _b = not(true);
 }
index f4ed7c5d9c87174a20685561cb0ad4f8ab0950d7..13177880c5ab7da2d6c18498406ae2025351d2d1 100644 (file)
@@ -16,7 +16,9 @@
 // We shouldn't need to rebind a moved upvar as mut if it's already
 // marked as mut
 
+use std::thunk::Thunk;
+
 pub fn main() {
     let mut x = 1i;
-    proc() { x = 2; };
+    let _thunk = Thunk::new(move|| { x = 2; });
 }
index c3aba9e8dc954e6f4ac2b60a3aa816b3ff07b870..e24cf5a0f26707d30cd760de1c8a0f793583af3b 100644 (file)
@@ -11,7 +11,7 @@
 use std::time::Duration;
 
 fn main() {
-    std::task::spawn(proc() customtask());
+    std::task::spawn(move|| customtask());
 }
 
 fn customtask() {
index afebcb3cdfc7dae4a97b31ff6a34a0c97fd9d01d..46a81301dc3cf47926fb62f831006eb10fdc4aea 100644 (file)
@@ -10,7 +10,9 @@
 
 extern crate libc;
 
-fn foo(_: proc()) {}
+use std::thunk::Thunk;
+
+fn foo(_: Thunk) {}
 
 fn main() {
     foo(loop {
index 9fe41f7e0243e9796ce56e719f4518df081a9efb..be851ddefc6451e0e8c4426b3d6555697def0fc9 100644 (file)
@@ -19,7 +19,7 @@ fn helper(rx: Receiver<Sender<()>>) {
 
 fn main() {
     let (tx, rx) = channel();
-    spawn(proc() { helper(rx) });
+    spawn(move|| { helper(rx) });
     let (snd, rcv) = channel::<int>();
     for _ in range(1i, 100000i) {
         snd.send(1i);
index c017a9dad6446ac0e92de4d6c5e62f3c258db2d2..9a1cc8569a3a15b62e6d07f37499f30d97257881 100644 (file)
@@ -10,8 +10,8 @@
 
 fn main() {
     if true {
-        proc(_) {}
+        (move|&mut: _| {}) as Box<FnMut()>
     } else {
-        proc(_: &mut ()) {}
+        (move|&mut: _: &mut ()| {}) as Box<FnMut()>
     };
 }
index 0ef0fc83c94565ca23300abadb44e72cbf69e4a7..03d18cf8c9815ceff651701620f195976f5096f3 100644 (file)
@@ -45,7 +45,7 @@ fn match_on_binding() {
 
 fn match_on_upvar() {
     let mut foo = Some(box 8i);
-    (proc() {
+    let f = move|:| {
         match foo {
             None => {},
             Some(x) => {
@@ -53,7 +53,8 @@ fn match_on_upvar() {
             }
         }
         println!("'{}'", foo.unwrap());
-    })();
+    };
+    f();
 }
 
 fn main() {
index 77eba0245b1c34a294db639b01a1dedab1ba6e91..f329e7eed0d5d5f823046b9db08efa3763118db3 100644 (file)
@@ -19,7 +19,7 @@ fn main() {
     // Check that both closures are capturing by value
     assert_eq!(1, mem::size_of_val(&closure));
 
-    spawn(proc() {
+    spawn(move|| {
         let ok = closure;
     })
 }
index 20bf1b260de686ea8f85f7b09f7f20c817198c71..c695a9e8f9abc9bfb6eb2e8e48e0d12b1124a040 100644 (file)
@@ -20,7 +20,7 @@
 
 pub fn main() {
     let mut stdin = std::io::stdin();
-    spawn(proc() {
+    spawn(move|| {
         let _ = stdin.read_to_end();
     });
 }
index 4ff735708b5ab7753936e7408835ce30e9acfb39..3554f2e8f0c315253073189ac178cc88ad7de5b0 100644 (file)
@@ -9,19 +9,20 @@
 // except according to those terms.
 
 use std::task::TaskBuilder;
+use std::thunk::Thunk;
 
 static generations: uint = 1024+256+128+49;
 
-fn spawn(f: proc():Send) {
-    TaskBuilder::new().stack_size(32 * 1024).spawn(f)
+fn spawn(f: Thunk) {
+    TaskBuilder::new().stack_size(32 * 1024).spawn(move|| f.invoke(()))
 }
 
-fn child_no(x: uint) -> proc():Send {
-    proc() {
+fn child_no(x: uint) -> Thunk {
+    Thunk::new(move|| {
         if x < generations {
             spawn(child_no(x+1));
         }
-    }
+    })
 }
 
 pub fn main() {
index 81efacb9bcbadb876ce1d95cb02b84e42ea16800..651315ea6417347bbd1868d0104f64535b3409ab 100644 (file)
 
 // rustc --test ignores2.rs && ./ignores2
 
+#![feature(unboxed_closures)]
+
 use std::path::{Path};
 use std::path;
 use std::result;
+use std::thunk::Thunk;
 
-type rsrc_loader = proc(path: &Path):'static -> result::Result<String, String>;
+type rsrc_loader = Box<FnMut(&Path) -> (result::Result<String, String>) + 'static>;
 
 fn tester()
 {
-    let loader: rsrc_loader = proc(_path) {
+    let mut loader: rsrc_loader = box move|_path| {
         result::Result::Ok("more blah".to_string())
     };
 
     let path = path::Path::new("blah");
-    assert!(loader(&path).is_ok());
+    assert!(loader.call_mut((&path,)).is_ok());
 }
 
 pub fn main() {}
index be5387b23c29c3127f90df9b4146a5c7fda22f95..f17f9411d15e803ab345fdd07b0dea36aad3f89f 100644 (file)
@@ -8,10 +8,13 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+#![feature(default_type_params)]
+
 use std::task;
+use std::thunk::Invoke;
 
 type RingBuffer = Vec<f64> ;
-type SamplesFn = proc(samples: &RingBuffer):Send;
+type SamplesFn = Box<FnMut(&RingBuffer) + Send>;
 
 enum Msg
 {
@@ -19,13 +22,16 @@ enum Msg
 }
 
 fn foo(name: String, samples_chan: Sender<Msg>) {
-    task::spawn(proc() {
+    task::spawn(move|| {
         let mut samples_chan = samples_chan;
-        let callback: SamplesFn = proc(buffer) {
+
+        // `box() (...)` syntax is needed to make pretty printer converge in one try:
+        let callback: SamplesFn = box() (move |buffer| {
             for i in range(0u, buffer.len()) {
                 println!("{}: {}", i, buffer[i])
             }
-        };
+        });
+
         samples_chan.send(Msg::GetSamples(name.clone(), callback));
     });
 }
index 2266e62eb77cb6b0669da83c9c58efb96e61850c..daa80aec28c049ec2b668bea0ae90a3f6c04c4c6 100644 (file)
@@ -15,7 +15,7 @@ pub fn main() {
 
     tx.send("hello, world");
 
-    spawn(proc() {
+    spawn(move|| {
         println(rx.recv());
     });
 }
index dda90ef1a0fbd0b8bf7463a60ee5047fc7cd50c7..3ea968c416f454f4643a586e51ecf560cc01e96d 100644 (file)
@@ -13,7 +13,7 @@
 pub fn main() {
     let (tx, rx) = channel::<&'static str>();
 
-    task::spawn(proc() {
+    task::spawn(move|| {
         assert_eq!(rx.recv(), "hello, world");
     });
 
index 762152c92038ff213ba57c7a2c755f30337d2fe7..b9b365e3e660a3a648813b0c5c97e78b28986780 100644 (file)
 use std::task;
 
 fn main() {
-    assert!(task::try(proc() int::MIN / -1).is_err());
-    assert!(task::try(proc() i8::MIN / -1).is_err());
-    assert!(task::try(proc() i16::MIN / -1).is_err());
-    assert!(task::try(proc() i32::MIN / -1).is_err());
-    assert!(task::try(proc() i64::MIN / -1).is_err());
-    assert!(task::try(proc() 1i / 0).is_err());
-    assert!(task::try(proc() 1i8 / 0).is_err());
-    assert!(task::try(proc() 1i16 / 0).is_err());
-    assert!(task::try(proc() 1i32 / 0).is_err());
-    assert!(task::try(proc() 1i64 / 0).is_err());
-    assert!(task::try(proc() int::MIN % -1).is_err());
-    assert!(task::try(proc() i8::MIN % -1).is_err());
-    assert!(task::try(proc() i16::MIN % -1).is_err());
-    assert!(task::try(proc() i32::MIN % -1).is_err());
-    assert!(task::try(proc() i64::MIN % -1).is_err());
-    assert!(task::try(proc() 1i % 0).is_err());
-    assert!(task::try(proc() 1i8 % 0).is_err());
-    assert!(task::try(proc() 1i16 % 0).is_err());
-    assert!(task::try(proc() 1i32 % 0).is_err());
-    assert!(task::try(proc() 1i64 % 0).is_err());
+    assert!(task::try(move|| int::MIN / -1).is_err());
+    assert!(task::try(move|| i8::MIN / -1).is_err());
+    assert!(task::try(move|| i16::MIN / -1).is_err());
+    assert!(task::try(move|| i32::MIN / -1).is_err());
+    assert!(task::try(move|| i64::MIN / -1).is_err());
+    assert!(task::try(move|| 1i / 0).is_err());
+    assert!(task::try(move|| 1i8 / 0).is_err());
+    assert!(task::try(move|| 1i16 / 0).is_err());
+    assert!(task::try(move|| 1i32 / 0).is_err());
+    assert!(task::try(move|| 1i64 / 0).is_err());
+    assert!(task::try(move|| int::MIN % -1).is_err());
+    assert!(task::try(move|| i8::MIN % -1).is_err());
+    assert!(task::try(move|| i16::MIN % -1).is_err());
+    assert!(task::try(move|| i32::MIN % -1).is_err());
+    assert!(task::try(move|| i64::MIN % -1).is_err());
+    assert!(task::try(move|| 1i % 0).is_err());
+    assert!(task::try(move|| 1i8 % 0).is_err());
+    assert!(task::try(move|| 1i16 % 0).is_err());
+    assert!(task::try(move|| 1i32 % 0).is_err());
+    assert!(task::try(move|| 1i64 % 0).is_err());
 }
index 173414d1d41cbee80316fded42add44c27e34644..7397ad744950e5246e2402ea7576c61bef81b3df 100644 (file)
@@ -10,7 +10,7 @@
 
 fn periodical(n: int) -> Receiver<bool> {
     let (chan, port) = channel();
-    spawn(proc() {
+    spawn(move|| {
         loop {
             for _ in range(1, n) {
                 match chan.send_opt(false) {
@@ -29,7 +29,7 @@ fn periodical(n: int) -> Receiver<bool> {
 
 fn integers() -> Receiver<int> {
     let (chan, port) = channel();
-    spawn(proc() {
+    spawn(move|| {
         let mut i = 1;
         loop {
             match chan.send_opt(i) {
index c16319a16f2821e4b1dad17ae4a88cb8908b3b13..588e0c1cf16cf28408369c965ff80e508303cba0 100644 (file)
@@ -14,7 +14,7 @@
 
 pub fn main() {
     let (tx, rx) = channel();
-    spawn(proc (){
+    spawn(move||{
         let mut timer = Timer::new().unwrap();
         timer.sleep(Duration::milliseconds(10));
         tx.send(());
index 81ff6fd7adc9419b85724a7f4770e18760ca44d6..1f7edcf43b887f5f71cc3c679a4d2ccfb2c2ba5f 100644 (file)
@@ -18,7 +18,7 @@ fn producer(tx: &Sender<Vec<u8>>) {
 
 pub fn main() {
     let (tx, rx) = channel::<Vec<u8>>();
-    let _prod = task::spawn(proc() {
+    let _prod = task::spawn(move|| {
         producer(&tx)
     });
 
index 3f45e864da35af1251bf0631f67a453714f49aa0..d745226af44082ab3a271be09c60ed5c8116d799 100644 (file)
@@ -16,7 +16,7 @@ fn foo() {
     // Here, i is *copied* into the proc (heap closure).
     // Requires allocation.  The proc's copy is not mutable.
     let mut i = 0;
-    task::spawn(proc() {
+    task::spawn(move|| {
         user(i);
         println!("spawned {}", i)
     });
@@ -29,7 +29,7 @@ fn bar() {
     // mutable outside of the proc.
     let mut i = 0;
     while i < 10 {
-        task::spawn(proc() {
+        task::spawn(move|| {
             user(i);
         });
         i += 1;
@@ -40,7 +40,7 @@ fn car() {
     // Here, i must be shadowed in the proc to be mutable.
     let mut i = 0;
     while i < 10 {
-        task::spawn(proc() {
+        task::spawn(move|| {
             let mut i = i;
             i += 1;
             user(i);
index c1f7e569feb40d575ff2b4e55520531ade37b1ef..1e05c05cc0dd101b0f5afcfb7a00dbaad48220c0 100644 (file)
@@ -27,7 +27,7 @@ fn fmt(&self, _fmt: &mut fmt::Formatter) -> fmt::Result {
 
 pub fn main() {
     let (tx, rx) = channel();
-    spawn(proc() {
+    spawn(move|| {
         let mut f = Foo(Cell::new(0));
         println!("{}", f);
         let Foo(ref mut f) = f;
index f9b1b951cf03d24eaa86772d715e3fa563941f2f..8b59f26d86976ab94dd318a6b3c40b26de65d3ff 100644 (file)
@@ -14,7 +14,7 @@ macro_rules! expr (($e: expr) => { $e })
 
 macro_rules! spawn {
     ($($code: tt)*) => {
-        expr!(spawn(proc() {$($code)*}))
+        expr!(spawn(move|| {$($code)*}))
     }
 }
 
index 7fd37969e672116d3bba22b9c58aca682396ab53..e5694aefdf4c34b78ca8002d48543e22cc651f40 100644 (file)
@@ -12,7 +12,7 @@
 
 pub fn main() {
     let x = "Hello world!".to_string();
-    task::spawn(proc() {
+    task::spawn(move|| {
         println!("{}", x);
     });
 }
index f704545af3375c5888cdeb1e91cea437ecf9b022..d74f1349506c1de9fe96f80a5296ed8203519481 100644 (file)
@@ -11,7 +11,7 @@
 // Test that the lambda kind is inferred correctly as a return
 // expression
 
-fn unique() -> proc():'static { return proc() (); }
+fn unique() -> Box<FnMut()+'static> { return box || (); }
 
 pub fn main() {
 }
index 22e51ea9a75836935adb34b3920f0a8558fba071..43a6ac296e9dc366b3ff3e56180c3c6028689d14 100644 (file)
@@ -11,7 +11,7 @@
 // Test that the lambda kind is inferred correctly as a return
 // expression
 
-fn unique() -> proc():'static { proc() () }
+fn unique() -> Box<FnMut()+'static> { box || () }
 
 pub fn main() {
 }
index eda36fad215fed6fac17d19f747770c6209f2325..e8bf366df957db5f73803f9fe9ced4486a5fe521 100644 (file)
@@ -23,7 +23,7 @@ fn drop(&mut self) {
 }
 
 fn main() {
-    task::try::<()>(proc() {
+    task::try(move|| -> () {
         let _a = A;
         panic!();
     });
index e24e809ed018a9416ade45f491318d0c3c34cbeb..8fe57a655aa5334b3400e93bd0042ac74af28c67 100644 (file)
 
 use std::sync::Arc;
 
-fn foo(blk: proc()) {
+fn foo<F:FnOnce()>(blk: F) {
     blk();
 }
 
 pub fn main() {
     let x = Arc::new(true);
-    foo(proc() {
+    foo(move|| {
         assert!(*x);
         drop(x);
     });
index a896d2b06f7bddbf3de1e66e130252892db001d8..49396d800297a7af76abf24eb297dcbd2dffa9e1 100644 (file)
@@ -73,6 +73,7 @@ pub fn main() {
     assert_eq!(q.y, !(p.y));
 
     // Issue #1733
-    let result: proc(int) = proc(_)();
     result(p[true]);
 }
+
+fn result(i: int) { }
index 21847a486d949f574fb87f7781e84abd5adb78c4..419d9b5d824b14ad7406684b56afd988a2cba948 100644 (file)
@@ -37,7 +37,7 @@ fn main() {
     let args = args.as_slice();
     if args.len() > 1 && args[1].as_slice() == "recurse" {
         let (tx, rx) = channel();
-        spawn(proc() {
+        spawn(move|| {
             recurse();
             tx.send(());
         });
index 46924c74a8c46d71eabad6c0591152b1e08d18ba..39252d6b1426818522f7bcda9663d49b9534927c 100644 (file)
@@ -33,7 +33,7 @@ fn drop(&mut self) {
 }
 
 pub fn main() {
-    let ret = task::try(proc() {
+    let ret = task::try(move|| {
         let _a = A { b: B { foo: 3 } };
     });
     assert!(ret.is_err());
index 53d2a47863b9d226b6d65223f64edd0ca638e50f..bcfc39ee7e4e65c947d8247af0adf5eb6b0ce219 100644 (file)
@@ -26,7 +26,7 @@ pub fn main() {
     let (port, chan) = stream();
 
     println!("main started");
-    spawn(proc() {
+    spawn(move|| {
         starve_main(port);
     });
     let mut i: int = 0;
diff --git a/src/test/run-pass/regions-infer-region-in-fn-but-not-type.rs b/src/test/run-pass/regions-infer-region-in-fn-but-not-type.rs
new file mode 100644 (file)
index 0000000..9174b53
--- /dev/null
@@ -0,0 +1,22 @@
+// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+
+// check that the &int here does not cause us to think that `foo`
+// contains region pointers
+struct foo(Box<FnMut(&int)+'static>);
+
+fn take_foo<T:'static>(x: T) {}
+
+fn have_foo(f: foo) {
+    take_foo(f);
+}
+
+fn main() {}
index 823644ddfb51954bf79dab420014872869042e0c..cb45b8e131d284f2414a565beebebd28efa90d1a 100644 (file)
 // give `x` a very short lifetime).
 
 static i: uint = 3;
-fn foo(_: proc():'static) {}
+fn foo<F:FnOnce()+'static>(_: F) {}
 fn read(_: uint) { }
 pub fn main() {
     let x = &i;
-    foo(proc() {
+    foo(move|| {
         read(*x);
     });
 }
index 2709904fb4cac0c3bc2fd53c2dd3451f30e5caa7..b905ebf52fcb3da1ba9af5b270ca18ffdfa861a2 100644 (file)
@@ -23,8 +23,7 @@ fn surrounding() {
     return_works(10);
     return_works(20);
 
-
-    let return_works_proc = proc(n: int) {
+    let return_works_proc = |: n: int| {
         unsafe { calls += 1 }
 
         if n >= 0 { return; }
index 683f7038ead7ac237be7356fa904e8c7e8d67ce6..36b90a9168f7174eb36e4888e553f7d274c97c4a 100644 (file)
@@ -14,6 +14,7 @@
 use std::os;
 use std::str;
 use std::rt;
+use std::thunk::Thunk;
 
 use rustrt::unwind::try;
 
@@ -26,7 +27,7 @@ fn start(argc: int, argv: *const *const u8) -> int {
                 2 => println!("foo"),
                 3 => assert!(try(|| {}).is_ok()),
                 4 => assert!(try(|| panic!()).is_err()),
-                5 => assert!(try(|| spawn(proc() {})).is_err()),
+                5 => assert!(try(|| spawn(move|| {})).is_err()),
                 6 => assert!(Command::new("test").spawn().is_err()),
                 _ => panic!()
             }
@@ -34,7 +35,7 @@ fn start(argc: int, argv: *const *const u8) -> int {
         return 0
     }
 
-    rt::start(argc, argv, main)
+    rt::start(argc, argv, Thunk::new(main))
 }
 
 fn main() {
index 275a390d5d31799d7a8a2c030375e917d503d233..88d30318f2a99c52ea473a860ac9db2b7a0b46aa 100644 (file)
@@ -34,7 +34,7 @@ fn log(&mut self, record: &log::LogRecord) {
 pub fn main() {
     let (logger, rx) = ChannelLogger::new();
 
-    spawn(proc() {
+    spawn(move|| {
         log::set_logger(logger);
 
         // our regex is "f.o"
index e368116f26c3afcaf32a017478bcfff7c9ce4206..6001c360ab99f64e86255bd881c64668dfc1c695 100644 (file)
@@ -27,7 +27,7 @@ fn test(f: int) -> test {
 pub fn main() {
     let (tx, rx) = channel();
 
-    task::spawn(proc() {
+    task::spawn(move|| {
         let (tx2, rx2) = channel();
         tx.send(tx2);
 
index c03094d4f15815483e0f8c2ecfb8a4b44bea0f3c..838c627040dbcab0fbc543d52c044a61171ad57f 100644 (file)
 
 pub fn main() { test05(); }
 
-fn test05_start(f: proc(int)) {
+fn test05_start<F:FnOnce(int)>(f: F) {
     f(22);
 }
 
 fn test05() {
     let three = box 3;
-    let fn_to_send: proc(int):Send = proc(n) {
+    let fn_to_send = move|: n:int| {
         println!("{}", *three + n); // will copy x into the closure
         assert_eq!(*three, 3);
     };
-    task::spawn(proc() {
+    task::spawn(move|| {
         test05_start(fn_to_send);
     });
 }
index c2c7a48815cc04e3abb07bace9cd0145c3d689a8..ccebfa72384f971736a3e891ff51d81a2c5461a4 100644 (file)
@@ -34,5 +34,5 @@ pub fn g() {
 }
 
 fn main() {
-    std::task::try(proc() { ::b::g() }).unwrap_err();
+    std::task::try(move|| { ::b::g() }).unwrap_err();
 }
index b07cf59596852250647308a68278d173afe3e5f4..b66641affc9100bae6e0f4b1a311b01eebd99a43 100644 (file)
@@ -28,6 +28,6 @@ fn foo() {
 }
 
 fn main() {
-    let _ = task::try(proc() foo());
+    let _ = task::try(move|| foo());
     unsafe { assert!(DTOR_COUNT == 2); }
 }
index 0ac7a2001fc678472f7338d0f4bbd76fca8c08a9..f7e241554c1e8598bb39b23f902d3c0dad83ed3a 100644 (file)
@@ -32,6 +32,6 @@ fn foo() {
 }
 
 fn main() {
-    let _ = task::try(proc() foo());
+    let _ = task::try(move|| foo());
     unsafe { assert!(DTOR_COUNT == 2); }
 }
index dba3fe325fa7d3aece802ea0eafe1ee8d742b828..b632bc77c7582005488bee0b89847b1b43504caf 100644 (file)
@@ -16,9 +16,9 @@ fn x(s: String, n: int) {
 }
 
 pub fn main() {
-    task::spawn(proc() x("hello from first spawned fn".to_string(), 65) );
-    task::spawn(proc() x("hello from second spawned fn".to_string(), 66) );
-    task::spawn(proc() x("hello from third spawned fn".to_string(), 67) );
+    task::spawn(move|| x("hello from first spawned fn".to_string(), 65) );
+    task::spawn(move|| x("hello from second spawned fn".to_string(), 66) );
+    task::spawn(move|| x("hello from third spawned fn".to_string(), 67) );
     let mut i: int = 30;
     while i > 0 {
         i = i - 1;
index 1418ab86174f3f7c2f6b598b8c1b477987fd93ff..9b533c69f32091b1b16a2a72cfde8e3d9612fd5e 100644 (file)
@@ -24,5 +24,5 @@ fn iotask(_tx: &ctx, ip: String) {
 
 pub fn main() {
     let (tx, _rx) = channel::<int>();
-    task::spawn(proc() iotask(&tx, "localhost".to_string()) );
+    task::spawn(move|| iotask(&tx, "localhost".to_string()) );
 }
index 741e20d42db8dc0eab007f8d8c49537c38c3ca95..cfc1967ae24f1f2000c5c140f1944f350f188899 100644 (file)
@@ -11,7 +11,7 @@
 use std::task;
 
 pub fn main() {
-    task::spawn(proc() child(10) );
+    task::spawn(move|| child(10) );
 }
 
 fn child(i: int) { println!("{}", i); assert!((i == 10)); }
index 6bac7f2a06e76264659f6ecfa3c80d68d490480f..72db4de2c8d409283af57419f8c17504cfbb1c7c 100644 (file)
@@ -10,7 +10,7 @@
 
 use std::task;
 
-pub fn main() { task::spawn(proc() child((10, 20, 30, 40, 50, 60, 70, 80, 90)) ); }
+pub fn main() { task::spawn(move|| child((10, 20, 30, 40, 50, 60, 70, 80, 90)) ); }
 
 fn child(args: (int, int, int, int, int, int, int, int, int)) {
     let (i1, i2, i3, i4, i5, i6, i7, i8, i9) = args;
index 264662d7d8bb2b387d35fa67bf8b9b06a6eddd96..0f12827e60ef4b955fc7d38074180f93af514b7c 100644 (file)
@@ -17,5 +17,5 @@
 
 pub fn main() {
     let mut t = TaskBuilder::new();
-    t.spawn(proc() ());
+    t.spawn(move|| ());
 }
index 06092200a1456e63fbd22a1a913bc3593a7df108..b25b350aa4b72320ae95ae8a75be596b0cbf4056 100644 (file)
@@ -18,7 +18,7 @@ pub fn main() {
             name: TestName::DynTestName("test".to_string()),
             should_fail: false
         },
-        testfn: TestFn::DynTestFn(proc() ()),
+        testfn: TestFn::DynTestFn(22),
     };
     do_swap(&mut test);
 }
@@ -34,8 +34,8 @@ pub enum TestName {
 }
 
 pub enum TestFn {
-    DynTestFn(proc():'static),
-    DynBenchFn(proc(&mut int):'static)
+    DynTestFn(int),
+    DynBenchFn(int),
 }
 
 pub struct TestDesc {
index 469c1b868db91e6417382efa99e6059fc51f93e0..9e3511ba6034f7ddc0592834b0f20074c56ad532 100644 (file)
@@ -24,7 +24,7 @@ fn test05_start(tx : &Sender<int>) {
 
 fn test05() {
     let (tx, rx) = channel();
-    task::spawn(proc() { test05_start(&tx) });
+    task::spawn(move|| { test05_start(&tx) });
     let mut value: int = rx.recv();
     println!("{}", value);
     value = rx.recv();
index 8eaa7f2e31d95a0f3d5f2b8ac45af4c83ced6d94..4117f201547b136b662c08292e9f96d1addf1d07 100644 (file)
@@ -15,6 +15,6 @@
 fn start() { println!("Started / Finished task."); }
 
 fn test00() {
-    task::try(proc() start() );
+    task::try(move|| start() );
     println!("Completing.");
 }
index 8054fb0f43b91d40db1ed368db7ab41ab7810898..dd3c90991f627a5ac9ef887c5da21f04cc0e4a24 100644 (file)
@@ -27,7 +27,7 @@ fn start(tx: &Sender<Sender<String>>) {
 
 pub fn main() {
     let (tx, rx) = channel();
-    let _child = task::spawn(proc() { start(&tx) });
+    let _child = task::spawn(move|| { start(&tx) });
 
     let mut c = rx.recv();
     c.send("A".to_string());
index 719d8e8120e7c0d056a519ca56da01bfc8cc636e..aefc91df4e780281c7bddad238a7a5d5f8d97406 100644 (file)
@@ -18,7 +18,7 @@ fn start(tx: &Sender<Sender<int>>) {
 
 pub fn main() {
     let (tx, rx) = channel();
-    let _child = task::spawn(proc() {
+    let _child = task::spawn(move|| {
         start(&tx)
     });
     let _tx = rx.recv();
index f72c0ef8d7b3c28cead566c80d3a54ffc26ee368..d950eb8aec45048ed27ba15bffb5515a1c674c83 100644 (file)
@@ -16,7 +16,7 @@
 
 fn test00() {
     let i: int = 0;
-    let mut result = task::try_future(proc() {
+    let mut result = task::try_future(move|| {
         start(i)
     });
 
index 3f3d6742971176eb81c2161cff8f6984e7dccdbf..c6c0691b74989874c75f73201a6bdc1b763d9d41 100644 (file)
@@ -19,6 +19,6 @@ fn start(tx: &Sender<int>, start: int, number_of_messages: int) {
 pub fn main() {
     println!("Check that we don't deadlock.");
     let (tx, rx) = channel();
-    task::try(proc() { start(&tx, 0, 10) });
+    task::try(move|| { start(&tx, 0, 10) });
     println!("Joined task");
 }
index 3f20495f6525e37c67ee4fd52921088f0effe97d..0e48381366555fd626dd596be065f39e2e0211a9 100644 (file)
@@ -19,7 +19,7 @@ pub fn main() {
     while (i > 0) {
         println!("{}", i);
         let tx = tx.clone();
-        task::spawn({let i = i; proc() { child(i, &tx) }});
+        task::spawn({let i = i; move|| { child(i, &tx) }});
         i = i - 1;
     }
 
index fe4c233224d45f82584b806cd426e1299f2a9eab..3095c2098ff339a1cb1760564c65aeb657906be0 100644 (file)
@@ -25,7 +25,7 @@ pub fn main() {
     // the child's point of view the receiver may die. We should
     // drop messages on the floor in this case, and not crash!
     let (tx, rx) = channel();
-    task::spawn(proc() {
+    task::spawn(move|| {
         start(&tx, 10)
     });
     rx.recv();
index 4f4d365901e7903cd48969cf48cb42473bcfb0c3..3a591d12864af124381c6bad381c03666dedd5d8 100644 (file)
@@ -18,5 +18,5 @@ fn f() {
 }
 
 pub fn main() {
-    task::spawn(proc() f() );
+    task::spawn(move|| f() );
 }
index 583840ede5f3e4281f26412da91fc1f8bebba39c..2908ec1e561159aada05cc0c686a7027c13b03aa 100644 (file)
@@ -41,7 +41,7 @@ fn test00() {
         let tx = tx.clone();
         results.push(task::try_future({
             let i = i;
-            proc() {
+            move|| {
                 test00_start(&tx, i, number_of_messages)
             }
         }));
index 170e1e8597bfcd25aa70e2f3862d4cf0c151a11c..9d8caa426269b9248989cc0baf4493bff27012cf 100644 (file)
@@ -28,19 +28,19 @@ fn test00() {
     let number_of_messages: int = 10;
 
     let tx2 = tx.clone();
-    task::spawn(proc() {
+    task::spawn(move|| {
         test00_start(&tx2, number_of_messages * 0, number_of_messages);
     });
     let tx2 = tx.clone();
-    task::spawn(proc() {
+    task::spawn(move|| {
         test00_start(&tx2, number_of_messages * 1, number_of_messages);
     });
     let tx2 = tx.clone();
-    task::spawn(proc() {
+    task::spawn(move|| {
         test00_start(&tx2, number_of_messages * 2, number_of_messages);
     });
     let tx2 = tx.clone();
-    task::spawn(proc() {
+    task::spawn(move|| {
         test00_start(&tx2, number_of_messages * 3, number_of_messages);
     });
 
index cc71ccdfa1960762e295e19bd7ca7f911643a140..1c197e823f2a4620387ff50ba5d60f59deaa1c90 100644 (file)
@@ -23,7 +23,7 @@ fn test00() {
     let (tx, rx) = channel();
     let number_of_messages: int = 10;
 
-    let result = task::try_future(proc() {
+    let result = task::try_future(move|| {
         test00_start(&tx, number_of_messages);
     });
 
index 5e0d184683129ba8a4065cb9c642fde8a8f9cdce..5c73f44f2d66abe61a10d0646a3c5ea868d7601e 100644 (file)
@@ -11,7 +11,7 @@
 use std::task;
 
 pub fn main() {
-    task::spawn(proc() child("Hello".to_string()) );
+    task::spawn(move|| child("Hello".to_string()) );
 }
 
 fn child(_s: String) {
index fafb9412c01e5b279eff37900022012ea4df6d15..8d6b6005a63bad6eb40f551d15a681e2a48469fa 100644 (file)
@@ -16,7 +16,7 @@ pub fn main() {
     let x = box 1;
     let x_in_parent = &(*x) as *const int as uint;
 
-    task::spawn(proc() {
+    task::spawn(move || {
         let x_in_child = &(*x) as *const int as uint;
         tx.send(x_in_child);
     });
index 0dbe74d722bca34605bb8bec4021f7971097ee06..72cf7599f89f97a0013c1f3fe0aae05c0c58a7ad 100644 (file)
@@ -16,7 +16,7 @@ fn main() {
     let mut reader = ChanReader::new(rx);
     let stderr = ChanWriter::new(tx);
 
-    let res = TaskBuilder::new().stderr(box stderr as Box<Writer + Send>).try(proc() -> () {
+    let res = TaskBuilder::new().stderr(box stderr as Box<Writer + Send>).try(move|| -> () {
         panic!("Hello, world!")
     });
     assert!(res.is_err());
index 1ed2efa4b320372b94448b4d8a3be9bab5a3438c..780cf23446639b414fb2550af3008825520e17e4 100644 (file)
@@ -35,7 +35,7 @@ fn test() {
         let a = a.clone();
         let cnt = cnt.clone();
         let srv_tx = srv_tx.clone();
-        spawn(proc() {
+        spawn(move|| {
             let mut a = a;
             loop {
                 match a.accept() {
@@ -54,7 +54,7 @@ fn test() {
 
     for _ in range(0, N) {
         let cli_tx = cli_tx.clone();
-        spawn(proc() {
+        spawn(move|| {
             for _ in range(0, M) {
                 let _s = TcpStream::connect(addr).unwrap();
             }
index 7dcbccdb17af0bd8b7bc5506e38ed4b52bfe727f..2e4b9da691e3941dd37d28b11fc8d0fc5677a871 100644 (file)
@@ -34,7 +34,7 @@ fn eventual_timeout() {
 
     let (tx1, rx1) = channel();
     let (_tx2, rx2) = channel::<()>();
-    std::task::spawn(proc() {
+    std::task::spawn(move|| {
         let _l = TcpListener::bind(addr).unwrap().listen();
         tx1.send(());
         let _ = rx2.recv_opt();
index 34fbe1c9a956b97bab1d365df27a16be220f9e35..4d691dd252656aab3657fde8f74757c99b261747 100644 (file)
@@ -24,7 +24,7 @@
 
 fn main() {
     // This test has a chance to time out, try to not let it time out
-    spawn(proc() {
+    spawn(move|| {
         use std::io::timer;
         timer::sleep(Duration::milliseconds(30 * 1000));
         println!("timed out!");
@@ -32,7 +32,7 @@ fn main() {
     });
 
     let (tx, rx) = channel();
-    spawn(proc() {
+    spawn(move|| {
         let mut listener = TcpListener::bind("127.0.0.1:0").unwrap();
         tx.send(listener.socket_name().unwrap());
         let mut acceptor = listener.listen();
@@ -53,7 +53,7 @@ fn main() {
     let (tx, rx) = channel();
     for _ in range(0u, 1000) {
         let tx = tx.clone();
-        TaskBuilder::new().stack_size(64 * 1024).spawn(proc() {
+        TaskBuilder::new().stack_size(64 * 1024).spawn(move|| {
             match TcpStream::connect(addr) {
                 Ok(stream) => {
                     let mut stream = stream;
index 7400c52a73b4abf4d7d61bf074a63f398b3aa2b0..a866f497b8615ec0e523144bd005ce5b32b544d1 100644 (file)
@@ -36,7 +36,7 @@ fn test_tempdir() {
 
 fn test_rm_tempdir() {
     let (tx, rx) = channel();
-    let f: proc():Send = proc() {
+    let f = move|:| -> () {
         let tmp = TempDir::new("test_rm_tempdir").unwrap();
         tx.send(tmp.path().clone());
         panic!("panic to unwind past `tmp`");
@@ -47,7 +47,7 @@ fn test_rm_tempdir() {
 
     let tmp = TempDir::new("test_rm_tempdir").unwrap();
     let path = tmp.path().clone();
-    let f: proc():Send = proc() {
+    let f = move|:| -> () {
         let _tmp = tmp;
         panic!("panic to unwind past `tmp`");
     };
@@ -56,7 +56,7 @@ fn test_rm_tempdir() {
 
     let path;
     {
-        let f = proc() {
+        let f = move|:| {
             TempDir::new("test_rm_tempdir").unwrap()
         };
         let tmp = task::try(f).ok().expect("test_rm_tmdir");
@@ -77,7 +77,7 @@ fn test_rm_tempdir() {
 
 fn test_rm_tempdir_close() {
     let (tx, rx) = channel();
-    let f: proc():Send = proc() {
+    let f = move|:| -> () {
         let tmp = TempDir::new("test_rm_tempdir").unwrap();
         tx.send(tmp.path().clone());
         tmp.close();
@@ -89,7 +89,7 @@ fn test_rm_tempdir_close() {
 
     let tmp = TempDir::new("test_rm_tempdir").unwrap();
     let path = tmp.path().clone();
-    let f: proc():Send = proc() {
+    let f = move|:| -> () {
         let tmp = tmp;
         tmp.close();
         panic!("panic when unwinding past `tmp`");
@@ -99,7 +99,7 @@ fn test_rm_tempdir_close() {
 
     let path;
     {
-        let f = proc() {
+        let f = move|:| {
             TempDir::new("test_rm_tempdir").unwrap()
         };
         let tmp = task::try(f).ok().expect("test_rm_tmdir");
@@ -176,7 +176,7 @@ pub fn test_rmdir_recursive_ok() {
 }
 
 pub fn dont_double_panic() {
-    let r: Result<(), _> = task::try(proc() {
+    let r: Result<(), _> = task::try(move|| {
         let tmpdir = TempDir::new("test").unwrap();
         // Remove the temporary directory so that TempDir sees
         // an error on drop
index 2a71148216d6407452a4b49c8043fa15dc178f98..28bbac1d0871c09feb92b307c8308accf564b0d2 100644 (file)
 
 fn test_panic() {
     fn f() { let _x: Box<int> = panic!(); }
-    task::try(proc() f() );
+    task::try(move|| f() );
 }
 
 fn test_panic_indirect() {
     fn f() -> ! { panic!(); }
     fn g() { let _x: Box<int> = f(); }
-    task::try(proc() g() );
+    task::try(move|| g() );
 }
 
 pub fn main() {
index dc862f201c244850214a508c7358a04072539238..71adf16c0511a0c480654f17b1019ec8ce3d6ec6 100644 (file)
@@ -12,7 +12,7 @@
 
 pub fn main() {
     let mut i = 10;
-    while i > 0 { task::spawn({let i = i; proc() child(i)}); i = i - 1; }
+    while i > 0 { task::spawn({let i = i; move|| child(i)}); i = i - 1; }
     println!("main thread exiting");
 }
 
index 50d3531b632f4589ed5fb0ea2ae6d81c872bda5f..d2c1461d65d0b0b86a925af15e925366e66c5200 100644 (file)
@@ -77,13 +77,13 @@ pub fn main() {
                             box dogge2 as Box<Pet+Sync+Send>));
     let (tx1, rx1) = channel();
     let arc1 = arc.clone();
-    task::spawn(proc() { check_legs(arc1); tx1.send(()); });
+    task::spawn(move|| { check_legs(arc1); tx1.send(()); });
     let (tx2, rx2) = channel();
     let arc2 = arc.clone();
-    task::spawn(proc() { check_names(arc2); tx2.send(()); });
+    task::spawn(move|| { check_names(arc2); tx2.send(()); });
     let (tx3, rx3) = channel();
     let arc3 = arc.clone();
-    task::spawn(proc() { check_pedigree(arc3); tx3.send(()); });
+    task::spawn(move|| { check_pedigree(arc3); tx3.send(()); });
     rx1.recv();
     rx2.recv();
     rx3.recv();
index 432a0527adaaed2db9da9471df5d6db8b2e31c36..672cd2d00e8bd4eb97fa3939174724ae3e62d90c 100644 (file)
@@ -20,7 +20,7 @@ pub fn main() {
     let mut expected = 0u;
     for i in range(0u, n) {
         let tx = tx.clone();
-        task::spawn(proc() {
+        task::spawn(move|| {
             child(&tx, i)
         });
         expected += i;
index c12303b009f46c588d128582ce1627d0502cd6fe..e3cd694c0de6b910ac0c0076ef60bff7adf5703c 100644 (file)
@@ -22,7 +22,7 @@ fn drop(&mut self) {
 }
 
 pub fn main() {
-    let x = task::try(proc() {
+    let x = task::try(move|| {
         let _b = Foo;
     });
 
index 60f07663bef0e38ee714fcef07e0213c4d577542..9789deef636490e9425ffe98689d8b856642640f 100644 (file)
@@ -37,7 +37,7 @@ fn f(tx: Sender<bool>) {
 
 pub fn main() {
     let (tx, rx) = channel();
-    task::spawn(proc() f(tx.clone()));
+    task::spawn(move|| f(tx.clone()));
     println!("hiiiiiiiii");
     assert!(rx.recv());
 }
index ce9cc68bd3654f5ba18820e26c3e852739d3535a..c969e66957ccb752d4aa4f2a1c39b2aaa8bfe991 100644 (file)
@@ -77,7 +77,7 @@ pub fn main() {
 
                 let v = main.clone();
 
-                let _ = task::try(proc() {
+                let _ = task::try(move|| {
                         let mut v = v;
                         let mut panic_countdown = panic_countdown;
                         v.as_mut_slice().sort_by(|a, b| {
index d44e25550ef810c744c0b08cad2066eb1919fd87..87226eedfdcbfc2376af564b72634e8f9a56fa0b 100644 (file)
@@ -15,7 +15,7 @@
 use std::task;
 
 fn main() {
-    let _ = task::try(proc() {
+    let _ = task::try(move|| {
         other::foo()
     });
 }