diff options
| author | Niko Matsakis <niko@alum.mit.edu> | 2014-11-26 08:12:18 -0500 |
|---|---|---|
| committer | Niko Matsakis <niko@alum.mit.edu> | 2014-12-14 04:21:56 -0500 |
| commit | 5c3d3989192f88b16f39d554c3844700c91b6c8e (patch) | |
| tree | 59c77544a06d3f4c2d363b5afe37c91a444e78d6 | |
| parent | 394f6846b80240480f8d7ce4b3d5d4c42ba85201 (diff) | |
| download | rust-5c3d3989192f88b16f39d554c3844700c91b6c8e.tar.gz rust-5c3d3989192f88b16f39d554c3844700c91b6c8e.zip | |
Mostly rote conversion of `proc()` to `move||` (and occasionally `Thunk::new`)
207 files changed, 692 insertions, 693 deletions
diff --git a/src/compiletest/compiletest.rs b/src/compiletest/compiletest.rs index 47ab675aff9..196c38215f4 100644 --- a/src/compiletest/compiletest.rs +++ b/src/compiletest/compiletest.rs @@ -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::os; 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) }) } diff --git a/src/compiletest/runtest.rs b/src/compiletest/runtest.rs index 5c3e5e12adb..ea6f180ec39 100644 --- a/src/compiletest/runtest.rs +++ b/src/compiletest/runtest.rs @@ -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() { diff --git a/src/doc/guide-tasks.md b/src/doc/guide-tasks.md index c2309ba479e..1938d3e3878 100644 --- a/src/doc/guide-tasks.md +++ b/src/doc/guide-tasks.md @@ -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 { diff --git a/src/doc/rustdoc.md b/src/doc/rustdoc.md index 05475c605ea..054552559db 100644 --- a/src/doc/rustdoc.md +++ b/src/doc/rustdoc.md @@ -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) diff --git a/src/liballoc/arc.rs b/src/liballoc/arc.rs index 1d2157b7e2f..1f1909fd33c 100644 --- a/src/liballoc/arc.rs +++ b/src/liballoc/arc.rs @@ -46,7 +46,7 @@ use heap::deallocate; /// 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 @@ mod tests { let (tx, rx) = channel(); - task::spawn(proc() { + task::spawn(move || { let arc_v: Arc<Vec<int>> = rx.recv(); assert_eq!((*arc_v)[3], 4); }); diff --git a/src/libcollections/dlist.rs b/src/libcollections/dlist.rs index f49a0c037de..df86ac96424 100644 --- a/src/libcollections/dlist.rs +++ b/src/libcollections/dlist.rs @@ -1133,7 +1133,7 @@ mod tests { #[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>>()); diff --git a/src/libflate/lib.rs b/src/libflate/lib.rs index cc36c2eef45..2c8e5638e49 100644 --- a/src/libflate/lib.rs +++ b/src/libflate/lib.rs @@ -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 } diff --git a/src/liblog/lib.rs b/src/liblog/lib.rs index 8b79078eac6..8731f7084ed 100644 --- a/src/liblog/lib.rs +++ b/src/liblog/lib.rs @@ -165,7 +165,7 @@ 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); diff --git a/src/librustc_driver/lib.rs b/src/librustc_driver/lib.rs index d655b704053..b0f8b3bdbe7 100644 --- a/src/librustc_driver/lib.rs +++ b/src/librustc_driver/lib.rs @@ -71,7 +71,7 @@ pub mod driver; 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(); diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index fccd6605df7..37147eb8a87 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -136,7 +136,7 @@ mod callee; /// closures defined within the function. For example: /// /// fn foo() { -/// bar(proc() { ... }) +/// bar(move|| { ... }) /// } /// /// Here, the function `foo()` and the closure passed to diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs index d3a76628580..78117c9cb06 100644 --- a/src/librustdoc/lib.rs +++ b/src/librustdoc/lib.rs @@ -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(); diff --git a/src/librustdoc/test.rs b/src/librustdoc/test.rs index 5759adf3244..0c64a0d29df 100644 --- a/src/librustdoc/test.rs +++ b/src/librustdoc/test.rs @@ -15,6 +15,7 @@ use std::io; 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 @@ impl Collector { 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 @@ impl Collector { should_fail, no_run, as_test_harness); - }), + })) }); } diff --git a/src/librustrt/c_str.rs b/src/librustrt/c_str.rs index 865c1af1d14..bba81383f7b 100644 --- a/src/librustrt/c_str.rs +++ b/src/librustrt/c_str.rs @@ -639,7 +639,7 @@ mod tests { #[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] diff --git a/src/librustrt/exclusive.rs b/src/librustrt/exclusive.rs index d40f149a2a1..9adcc0a844d 100644 --- a/src/librustrt/exclusive.rs +++ b/src/librustrt/exclusive.rs @@ -99,7 +99,7 @@ mod tests { let (tx, rx) = channel(); futures.push(rx); - task::spawn(proc() { + task::spawn(move || { for _ in range(0u, count) { **total.lock() += 1; } diff --git a/src/librustrt/local.rs b/src/librustrt/local.rs index b1d387a9cc3..df733d7ee22 100644 --- a/src/librustrt/local.rs +++ b/src/librustrt/local.rs @@ -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 @@ mod 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 @@ mod test { #[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 @@ mod 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 @@ mod test { #[test] fn try_take() { - Thread::start(proc() { + Thread::start(move|| { let task = box Task::new(None, None); Local::put(task); diff --git a/src/librustrt/mutex.rs b/src/librustrt/mutex.rs index 5b58ec8fd3a..cbfb86a6ac7 100644 --- a/src/librustrt/mutex.rs +++ b/src/librustrt/mutex.rs @@ -680,7 +680,7 @@ mod test { 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 @@ mod test { 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(); diff --git a/src/libstd/c_vec.rs b/src/libstd/c_vec.rs index f89876f7245..44e7291150e 100644 --- a/src/libstd/c_vec.rs +++ b/src/libstd/c_vec.rs @@ -37,19 +37,20 @@ 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 @@ impl<T> 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 @@ mod tests { 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 @@ mod tests { #[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); } diff --git a/src/libstd/comm/mod.rs b/src/libstd/comm/mod.rs index 6cff5a3dd23..0a5b3e5771b 100644 --- a/src/libstd/comm/mod.rs +++ b/src/libstd/comm/mod.rs @@ -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); //! }) //! } @@ -112,7 +112,7 @@ //! //! ``` //! 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 @@ impl<T> UnsafeFlavor<T> for Receiver<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 @@ mod test { 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 @@ mod test { test!(fn port_gone_concurrent() { let (tx, rx) = channel::<int>(); - spawn(proc() { + spawn(move|| { rx.recv(); }); loop { tx.send(1) } @@ -1102,7 +1102,7 @@ mod test { 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 @@ mod test { test!(fn chan_gone_concurrent() { let (tx, rx) = channel::<int>(); - spawn(proc() { + spawn(move|| { tx.send(1); tx.send(1); }); @@ -1136,7 +1136,7 @@ mod test { 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 @@ mod test { 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 @@ mod test { 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 @@ mod test { 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 @@ mod test { tx3.send(()); }); rx1.recv(); - spawn(proc() { + spawn(move|| { for _ in range(0i, 40) { tx2.send(1); } @@ -1199,7 +1199,7 @@ mod test { 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 @@ mod test { 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 @@ mod test { 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 @@ mod test { 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 @@ mod test { 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 @@ mod test { 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 @@ mod test { 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 @@ mod test { 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 @@ mod test { 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 @@ mod test { 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 @@ mod test { 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 @@ mod test { let total = stress_factor() + 100; for _ in range(0, total) { let tx = tx.clone(); - spawn(proc() { + spawn(move|| { tx.send(()); }); } @@ -1434,7 +1434,7 @@ mod test { 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 @@ mod test { 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 @@ mod test { 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 @@ mod test { 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 @@ mod test { 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 @@ mod test { 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 @@ mod sync_tests { 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 @@ mod sync_tests { 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 @@ mod sync_tests { 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 @@ mod sync_tests { 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 @@ mod sync_tests { 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 @@ mod sync_tests { 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 @@ mod sync_tests { 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 @@ mod sync_tests { 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 @@ mod sync_tests { 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 @@ mod sync_tests { 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 @@ mod sync_tests { 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 @@ mod sync_tests { 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 @@ mod sync_tests { 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 @@ mod sync_tests { 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 @@ mod sync_tests { 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 @@ mod sync_tests { 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 @@ mod sync_tests { let total = stress_factor() + 100; for _ in range(0, total) { let tx = tx.clone(); - spawn(proc() { + spawn(move|| { tx.send(()); }); } @@ -1899,7 +1899,7 @@ mod sync_tests { 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 @@ mod sync_tests { 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 @@ mod sync_tests { 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 @@ mod sync_tests { 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 @@ mod sync_tests { 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 @@ mod sync_tests { 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 @@ mod sync_tests { 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 @@ mod sync_tests { 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 @@ mod sync_tests { let (tx1, rx1) = sync_channel::<()>(3); let (tx2, rx2) = sync_channel::<()>(3); - spawn(proc() { + spawn(move|| { rx1.recv(); tx2.try_send(()).unwrap(); }); diff --git a/src/libstd/comm/mpsc_queue.rs b/src/libstd/comm/mpsc_queue.rs index d4249abc3dd..db4e3eac449 100644 --- a/src/libstd/comm/mpsc_queue.rs +++ b/src/libstd/comm/mpsc_queue.rs @@ -178,7 +178,7 @@ mod tests { 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); } diff --git a/src/libstd/comm/select.rs b/src/libstd/comm/select.rs index 3191519815a..e145b0df7f3 100644 --- a/src/libstd/comm/select.rs +++ b/src/libstd/comm/select.rs @@ -403,7 +403,7 @@ mod test { 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 @@ mod test { 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 @@ mod test { 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 @@ mod test { 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 @@ mod test { 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 @@ mod test { 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 @@ mod test { test!(fn oneshot_data_waiting() { let (tx1, rx1) = channel(); let (tx2, rx2) = channel(); - spawn(proc() { + spawn(move|| { select! { () = rx1.recv() => {} } @@ -643,7 +643,7 @@ mod test { tx1.send(()); rx1.recv(); rx1.recv(); - spawn(proc() { + spawn(move|| { select! { () = rx1.recv() => {} } @@ -661,7 +661,7 @@ mod test { drop(tx1.clone()); tx1.send(()); rx1.recv(); - spawn(proc() { + spawn(move|| { select! { () = rx1.recv() => {} } @@ -683,7 +683,7 @@ mod test { 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 @@ mod test { 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); diff --git a/src/libstd/comm/spsc_queue.rs b/src/libstd/comm/spsc_queue.rs index a6b4ab71bac..db8fff772a4 100644 --- a/src/libstd/comm/spsc_queue.rs +++ b/src/libstd/comm/spsc_queue.rs @@ -316,7 +316,7 @@ mod test { let (tx, rx) = channel(); let q2 = q.clone(); - spawn(proc() { + spawn(move|| { for _ in range(0u, 100000) { loop { match q2.pop() { diff --git a/src/libstd/io/comm_adapters.rs b/src/libstd/io/comm_adapters.rs index 4ec1a3764db..308dc094101 100644 --- a/src/libstd/io/comm_adapters.rs +++ b/src/libstd/io/comm_adapters.rs @@ -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 @@ mod test { #[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 @@ mod test { 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!(), }; diff --git a/src/libstd/io/mod.rs b/src/libstd/io/mod.rs index bad86258bb8..d21e0f57b07 100644 --- a/src/libstd/io/mod.rs +++ b/src/libstd/io/mod.rs @@ -119,7 +119,7 @@ //! for stream in acceptor.incoming() { //! match stream { //! Err(e) => { /* connection failed */ } -//! Ok(stream) => spawn(proc() { +//! Ok(stream) => spawn(move|| { //! // connection succeeded //! handle_client(stream) //! }) diff --git a/src/libstd/io/net/pipe.rs b/src/libstd/io/net/pipe.rs index ec997b71986..9f2f41c0021 100644 --- a/src/libstd/io/net/pipe.rs +++ b/src/libstd/io/net/pipe.rs @@ -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 @@ mod tests { #[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 @@ mod tests { #[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 @@ mod tests { } } } - }, proc(_client) { + }, move|_client| { // drop the client }) } @@ -374,7 +377,7 @@ mod tests { 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 @@ mod tests { 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 @@ mod tests { 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 @@ mod tests { 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 @@ mod tests { 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 @@ mod tests { 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 @@ mod tests { 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 @@ mod tests { // 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 @@ mod tests { // 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 @@ mod tests { 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 @@ mod tests { 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 @@ mod tests { 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 @@ mod tests { 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 @@ mod tests { 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 @@ mod tests { 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 @@ mod tests { 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 @@ mod tests { 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 @@ mod tests { 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 @@ mod tests { 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 @@ mod tests { let mut a2 = a.clone(); let (tx, rx) = channel(); - spawn(proc() { + spawn(move|| { let mut a = a; tx.send(a.accept()); }); diff --git a/src/libstd/io/net/tcp.rs b/src/libstd/io/net/tcp.rs index a7b1b077eff..3c38e23183f 100644 --- a/src/libstd/io/net/tcp.rs +++ b/src/libstd/io/net/tcp.rs @@ -140,7 +140,7 @@ impl TcpStream { /// 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 @@ impl sys_common::AsInner<TcpStreamImp> for TcpStream { /// 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 @@ mod test { 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 @@ mod test { 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 @@ mod test { 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 @@ mod test { 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 @@ mod test { 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 @@ mod test { 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 @@ mod test { 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 @@ mod test { 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 @@ mod test { 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 @@ mod test { 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 @@ mod test { 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 @@ mod test { 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 @@ mod test { 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 @@ mod test { 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 @@ mod test { 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 @@ mod test { 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 @@ mod test { 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 @@ mod test { 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 @@ mod test { 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 @@ mod test { 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 @@ mod test { 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 @@ mod test { 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 @@ mod test { 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 @@ mod test { 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 @@ mod test { 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 @@ mod test { 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 @@ mod test { 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 @@ mod test { 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 @@ mod test { 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 @@ mod test { 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 @@ mod test { 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 @@ mod test { 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 @@ mod test { // 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 @@ mod test { // 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 @@ mod test { 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 @@ mod test { 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 @@ mod test { 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 @@ mod test { 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 @@ mod test { 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 @@ mod test { 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 @@ mod test { 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 @@ mod test { 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 @@ mod test { 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 @@ mod test { 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 @@ mod test { 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 @@ mod test { 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 @@ mod test { let mut a2 = a.clone(); let (tx, rx) = channel(); - spawn(proc() { + spawn(move|| { let mut a = a; tx.send(a.accept()); }); diff --git a/src/libstd/io/net/udp.rs b/src/libstd/io/net/udp.rs index b23921ba359..78951b8dae2 100644 --- a/src/libstd/io/net/udp.rs +++ b/src/libstd/io/net/udp.rs @@ -272,7 +272,7 @@ mod test { 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 @@ mod test { 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 @@ mod test { 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 @@ mod test { 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 @@ mod test { 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 @@ mod test { 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 @@ mod test { 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 @@ mod test { 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 @@ mod test { 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 @@ mod test { 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 @@ mod test { 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(())); diff --git a/src/libstd/io/pipe.rs b/src/libstd/io/pipe.rs index 41676cdf6e9..73a893c4f2d 100644 --- a/src/libstd/io/pipe.rs +++ b/src/libstd/io/pipe.rs @@ -123,7 +123,7 @@ mod test { 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 diff --git a/src/libstd/io/process.rs b/src/libstd/io/process.rs index c46a6e82e44..9ba6381c8c3 100644 --- a/src/libstd/io/process.rs +++ b/src/libstd/io/process.rs @@ -693,7 +693,7 @@ impl Process { 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 @@ mod tests { 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); diff --git a/src/libstd/io/stdio.rs b/src/libstd/io/stdio.rs index 8438c9fb441..344012a09a0 100644 --- a/src/libstd/io/stdio.rs +++ b/src/libstd/io/stdio.rs @@ -528,7 +528,7 @@ mod tests { 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 @@ mod tests { 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"); }); diff --git a/src/libstd/io/timer.rs b/src/libstd/io/timer.rs index ad02b534d04..79048c37ab5 100644 --- a/src/libstd/io/timer.rs +++ b/src/libstd/io/timer.rs @@ -357,7 +357,7 @@ mod test { 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 @@ mod test { 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 @@ mod test { let mut timer = Timer::new().unwrap(); let timer_rx = timer.periodic(Duration::milliseconds(1000)); - spawn(proc() { + spawn(move|| { let _ = timer_rx.recv_opt(); }); diff --git a/src/libstd/macros.rs b/src/libstd/macros.rs index 76419bee41c..900c223c70b 100644 --- a/src/libstd/macros.rs +++ b/src/libstd/macros.rs @@ -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"), diff --git a/src/libstd/path/posix.rs b/src/libstd/path/posix.rs index 3daba53cd86..4041a6f60d7 100644 --- a/src/libstd/path/posix.rs +++ b/src/libstd/path/posix.rs @@ -515,17 +515,17 @@ mod tests { #[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()); diff --git a/src/libstd/path/windows.rs b/src/libstd/path/windows.rs index e1b0d9b1395..3983e365ae1 100644 --- a/src/libstd/path/windows.rs +++ b/src/libstd/path/windows.rs @@ -1299,17 +1299,17 @@ mod tests { #[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()); diff --git a/src/libstd/rand/os.rs b/src/libstd/rand/os.rs index 37628b65388..5405892535c 100644 --- a/src/libstd/rand/os.rs +++ b/src/libstd/rand/os.rs @@ -355,7 +355,7 @@ mod test { 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(); diff --git a/src/libstd/sync/atomic.rs b/src/libstd/sync/atomic.rs index 2bb55188113..fe5b962fa4b 100644 --- a/src/libstd/sync/atomic.rs +++ b/src/libstd/sync/atomic.rs @@ -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"); diff --git a/src/libstd/sync/barrier.rs b/src/libstd/sync/barrier.rs index 5e6dc6ec650..1b8574604a0 100644 --- a/src/libstd/sync/barrier.rs +++ b/src/libstd/sync/barrier.rs @@ -21,7 +21,7 @@ use sync::{Mutex, Condvar}; /// 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 @@ mod tests { for _ in range(0u, 9) { let c = barrier.clone(); let tx = tx.clone(); - spawn(proc() { + spawn(move|| { c.wait(); tx.send(true); }); diff --git a/src/libstd/sync/condvar.rs b/src/libstd/sync/condvar.rs index 0fdd57b2792..3bdab261e19 100644 --- a/src/libstd/sync/condvar.rs +++ b/src/libstd/sync/condvar.rs @@ -41,7 +41,7 @@ use time::Duration; /// 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 @@ mod tests { static M: StaticMutex = MUTEX_INIT; let g = M.lock(); - spawn(proc() { + spawn(move|| { let _g = M.lock(); C.notify_one(); }); @@ -300,7 +300,7 @@ mod tests { 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 @@ mod tests { 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 @@ mod tests { static C: StaticCondvar = CONDVAR_INIT; let g = M1.lock(); - spawn(proc() { + spawn(move|| { let _g = M1.lock(); C.notify_one(); }); diff --git a/src/libstd/sync/mutex.rs b/src/libstd/sync/mutex.rs index 4e07d54c57e..33f8d254c71 100644 --- a/src/libstd/sync/mutex.rs +++ b/src/libstd/sync/mutex.rs @@ -47,7 +47,7 @@ use sys_common::mutex as sys; /// 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 @@ mod test { 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 @@ mod test { 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 @@ mod test { 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 @@ mod test { 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 @@ mod test { 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 @@ mod test { 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>>, } diff --git a/src/libstd/sync/once.rs b/src/libstd/sync/once.rs index 1bcdc760fc6..263937c5cbe 100644 --- a/src/libstd/sync/once.rs +++ b/src/libstd/sync/once.rs @@ -142,7 +142,7 @@ mod test { 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(|| { diff --git a/src/libstd/sync/rwlock.rs b/src/libstd/sync/rwlock.rs index a4f8b1df6af..b6d6aa989c5 100644 --- a/src/libstd/sync/rwlock.rs +++ b/src/libstd/sync/rwlock.rs @@ -387,7 +387,7 @@ mod tests { 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 @@ mod tests { 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 @@ mod tests { 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 @@ mod tests { 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 @@ mod tests { 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 @@ mod tests { 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 @@ mod tests { 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 @@ mod tests { 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>>, } diff --git a/src/libstd/sync/semaphore.rs b/src/libstd/sync/semaphore.rs index 03fb84c38d4..574b0f22bee 100644 --- a/src/libstd/sync/semaphore.rs +++ b/src/libstd/sync/semaphore.rs @@ -127,7 +127,7 @@ mod tests { 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 @@ mod tests { 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 @@ mod tests { 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 @@ mod tests { 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 @@ mod tests { let (tx, rx) = channel(); { let _g = s.access(); - spawn(proc() { + spawn(move|| { tx.send(()); drop(s2.access()); tx.send(()); diff --git a/src/libstd/sync/task_pool.rs b/src/libstd/sync/task_pool.rs index a684c6502ae..fa5b62a202b 100644 --- a/src/libstd/sync/task_pool.rs +++ b/src/libstd/sync/task_pool.rs @@ -12,17 +12,18 @@ 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 @@ impl<'a> Drop for Sentinel<'a> { /// 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 @@ mod test { 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 @@ mod test { // 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 @@ mod test { // 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!(); }); diff --git a/src/libstd/sys/common/helper_thread.rs b/src/libstd/sys/common/helper_thread.rs index 6c5fc3005ed..96b4accd4bd 100644 --- a/src/libstd/sys/common/helper_thread.rs +++ b/src/libstd/sys/common/helper_thread.rs @@ -83,7 +83,7 @@ impl<M: Send> Helper<M> { *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 @@ impl<M: Send> Helper<M> { self.cond.notify_one() }); - rustrt::at_exit(proc() { self.shutdown() }); + rustrt::at_exit(move|:| { self.shutdown() }); *self.initialized.get() = true; } } diff --git a/src/libstd/sys/unix/process.rs b/src/libstd/sys/unix/process.rs index f71b34304ab..4ef1757cc3a 100644 --- a/src/libstd/sys/unix/process.rs +++ b/src/libstd/sys/unix/process.rs @@ -94,8 +94,8 @@ impl Process { 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 diff --git a/src/libstd/sys/windows/thread_local.rs b/src/libstd/sys/windows/thread_local.rs index b841f6d3a2b..969b322af99 100644 --- a/src/libstd/sys/windows/thread_local.rs +++ b/src/libstd/sys/windows/thread_local.rs @@ -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 _; }); diff --git a/src/libstd/thread_local/mod.rs b/src/libstd/thread_local/mod.rs index b85b6eccb77..2d5766c2393 100644 --- a/src/libstd/thread_local/mod.rs +++ b/src/libstd/thread_local/mod.rs @@ -77,7 +77,7 @@ pub mod scoped; /// }); /// /// // 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 @@ mod tests { *f.get() = 2; }); let (tx, rx) = channel(); - spawn(proc() { + spawn(move|| { FOO.with(|f| unsafe { assert_eq!(*f.get(), 1); }); @@ -491,7 +491,7 @@ mod tests { }) 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 @@ mod tests { } } - Thread::start(proc() { + Thread::start(move|| { drop(S1); }).join(); } @@ -557,7 +557,7 @@ mod tests { } } - Thread::start(proc() unsafe { + Thread::start(move|| unsafe { K1.with(|s| *s.get() = Some(S1)); }).join(); } @@ -584,7 +584,7 @@ mod tests { } 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()))); }); diff --git a/src/libtest/lib.rs b/src/libtest/lib.rs index 7436a8af307..211c5906f45 100644 --- a/src/libtest/lib.rs +++ b/src/libtest/lib.rs @@ -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::str::FromStr; 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 @@ pub fn run_test(opts: &TestOpts, 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 @@ pub fn run_test(opts: &TestOpts, } 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 @@ pub fn run_test(opts: &TestOpts, } 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 @@ mod 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 @@ mod 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); @@ -1511,7 +1513,7 @@ mod tests { 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 @@ mod tests { 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 @@ mod tests { 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 @@ mod tests { 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 @@ mod tests { ignore: true, should_fail: ShouldFail::No, }, - testfn: DynTestFn(proc() {}), + testfn: DynTestFn(Thunk::new(move|| {})), }, TestDescAndFn { desc: TestDesc { @@ -1616,7 +1618,7 @@ mod tests { ignore: false, should_fail: ShouldFail::No, }, - testfn: DynTestFn(proc() {}), + testfn: DynTestFn(Thunk::new(move|| {})), }); let filtered = filter_tests(&opts, tests); @@ -1652,7 +1654,7 @@ mod tests { ignore: false, should_fail: ShouldFail::No, }, - testfn: DynTestFn(testfn), + testfn: DynTestFn(Thunk::new(testfn)), }; tests.push(test); } @@ -1693,7 +1695,7 @@ mod tests { ignore: false, should_fail: ShouldFail::No, }, - testfn: DynTestFn(test_fn) + testfn: DynTestFn(Thunk::new(test_fn)) } }).collect(); let filtered = filter_tests(&opts, tests); diff --git a/src/test/auxiliary/cci_capture_clause.rs b/src/test/auxiliary/cci_capture_clause.rs index 88692cf3f5e..1cccb0f7ccb 100644 --- a/src/test/auxiliary/cci_capture_clause.rs +++ b/src/test/auxiliary/cci_capture_clause.rs @@ -12,7 +12,7 @@ use std::task; 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 diff --git a/src/test/bench/msgsend-pipes-shared.rs b/src/test/bench/msgsend-pipes-shared.rs index cea03f13a4b..f20fb8d0cd7 100644 --- a/src/test/bench/msgsend-pipes-shared.rs +++ b/src/test/bench/msgsend-pipes-shared.rs @@ -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); }); diff --git a/src/test/bench/msgsend-pipes.rs b/src/test/bench/msgsend-pipes.rs index 476e7d42d45..179011be8bf 100644 --- a/src/test/bench/msgsend-pipes.rs +++ b/src/test/bench/msgsend-pipes.rs @@ -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); }); diff --git a/src/test/bench/msgsend-ring-mutex-arcs.rs b/src/test/bench/msgsend-ring-mutex-arcs.rs index 863c3c879a7..49f53bf9d38 100644 --- a/src/test/bench/msgsend-ring-mutex-arcs.rs +++ b/src/test/bench/msgsend-ring-mutex-arcs.rs @@ -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); diff --git a/src/test/bench/rt-messaging-ping-pong.rs b/src/test/bench/rt-messaging-ping-pong.rs index b00adf4bdb1..73d54372b27 100644 --- a/src/test/bench/rt-messaging-ping-pong.rs +++ b/src/test/bench/rt-messaging-ping-pong.rs @@ -34,7 +34,7 @@ fn ping_pong_bench(n: uint, m: 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 ping_pong_bench(n: uint, m: uint) { } }); - spawn(proc() { + spawn(move|| { let (tx, rx) = (btx, arx); for _ in range(0, n) { rx.recv(); diff --git a/src/test/bench/rt-parfib.rs b/src/test/bench/rt-parfib.rs index 4072dc0064a..bdf22cd7395 100644 --- a/src/test/bench/rt-parfib.rs +++ b/src/test/bench/rt-parfib.rs @@ -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); diff --git a/src/test/bench/shootout-binarytrees.rs b/src/test/bench/shootout-binarytrees.rs index 509cb37b2e6..0b16e8011e8 100644 --- a/src/test/bench/shootout-binarytrees.rs +++ b/src/test/bench/shootout-binarytrees.rs @@ -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(); diff --git a/src/test/bench/shootout-chameneos-redux.rs b/src/test/bench/shootout-chameneos-redux.rs index e954d0fed5e..dcdb90a11c8 100644 --- a/src/test/bench/shootout-chameneos-redux.rs +++ b/src/test/bench/shootout-chameneos-redux.rs @@ -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, diff --git a/src/test/bench/shootout-fannkuch-redux.rs b/src/test/bench/shootout-fannkuch-redux.rs index 4b890bbd8d3..4849421a3f0 100644 --- a/src/test/bench/shootout-fannkuch-redux.rs +++ b/src/test/bench/shootout-fannkuch-redux.rs @@ -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) })) } diff --git a/src/test/bench/shootout-k-nucleotide-pipes.rs b/src/test/bench/shootout-k-nucleotide-pipes.rs index 45d2cbea8fa..8c11c3673d5 100644 --- a/src/test/bench/shootout-k-nucleotide-pipes.rs +++ b/src/test/bench/shootout-k-nucleotide-pipes.rs @@ -168,7 +168,7 @@ fn main() { let (to_child, from_parent) = channel(); - spawn(proc() { + spawn(move|| { make_sequence_processor(sz, &from_parent, &to_parent_); }); diff --git a/src/test/bench/shootout-k-nucleotide.rs b/src/test/bench/shootout-k-nucleotide.rs index 847ae2c1c88..d112fe60674 100644 --- a/src/test/bench/shootout-k-nucleotide.rs +++ b/src/test/bench/shootout-k-nucleotide.rs @@ -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() { diff --git a/src/test/bench/shootout-mandelbrot.rs b/src/test/bench/shootout-mandelbrot.rs index 454b445dea0..bb0e09370d8 100644 --- a/src/test/bench/shootout-mandelbrot.rs +++ b/src/test/bench/shootout-mandelbrot.rs @@ -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(); diff --git a/src/test/bench/shootout-meteor.rs b/src/test/bench/shootout-meteor.rs index ca749d47b63..9a3b6953062 100644 --- a/src/test/bench/shootout-meteor.rs +++ b/src/test/bench/shootout-meteor.rs @@ -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); diff --git a/src/test/bench/shootout-pfib.rs b/src/test/bench/shootout-pfib.rs index 15a5cb0c9bf..fae6d2cc3aa 100644 --- a/src/test/bench/shootout-pfib.rs +++ b/src/test/bench/shootout-pfib.rs @@ -34,15 +34,15 @@ fn fib(n: int) -> 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); })); } diff --git a/src/test/bench/shootout-regex-dna.rs b/src/test/bench/shootout-regex-dna.rs index 81de7a12690..9b8fd51c1c5 100644 --- a/src/test/bench/shootout-regex-dna.rs +++ b/src/test/bench/shootout-regex-dna.rs @@ -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) })); } diff --git a/src/test/bench/shootout-reverse-complement.rs b/src/test/bench/shootout-reverse-complement.rs index ffe5739e0bb..312ee2dd27e 100644 --- a/src/test/bench/shootout-reverse-complement.rs +++ b/src/test/bench/shootout-reverse-complement.rs @@ -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) diff --git a/src/test/bench/shootout-spectralnorm.rs b/src/test/bench/shootout-spectralnorm.rs index f76391b596b..647c47b00a0 100644 --- a/src/test/bench/shootout-spectralnorm.rs +++ b/src/test/bench/shootout-spectralnorm.rs @@ -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) diff --git a/src/test/bench/shootout-threadring.rs b/src/test/bench/shootout-threadring.rs index cda0feb8b55..111a92b083a 100644 --- a/src/test/bench/shootout-threadring.rs +++ b/src/test/bench/shootout-threadring.rs @@ -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>) { diff --git a/src/test/bench/spawnone.rs b/src/test/bench/spawnone.rs index b55f471bdb2..ca36d99014c 100644 --- a/src/test/bench/spawnone.rs +++ b/src/test/bench/spawnone.rs @@ -10,5 +10,5 @@ // Useful for checking syscall usage of baseline scheduler usage fn main() { - spawn(proc() {}); + spawn(move|| {}); } diff --git a/src/test/bench/task-perf-alloc-unwind.rs b/src/test/bench/task-perf-alloc-unwind.rs index 77078b2c68d..8bcf30b4859 100644 --- a/src/test/bench/task-perf-alloc-unwind.rs +++ b/src/test/bench/task-perf-alloc-unwind.rs @@ -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) }); }); diff --git a/src/test/bench/task-perf-jargon-metal-smoke.rs b/src/test/bench/task-perf-jargon-metal-smoke.rs index 3d2822e1459..789ccb6142a 100644 --- a/src/test/bench/task-perf-jargon-metal-smoke.rs +++ b/src/test/bench/task-perf-jargon-metal-smoke.rs @@ -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 } diff --git a/src/test/bench/task-perf-one-million.rs b/src/test/bench/task-perf-one-million.rs index 0f903be3922..e3b51cb6b5b 100644 --- a/src/test/bench/task-perf-one-million.rs +++ b/src/test/bench/task-perf-one-million.rs @@ -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); }); diff --git a/src/test/bench/task-perf-spawnalot.rs b/src/test/bench/task-perf-spawnalot.rs index 533005b1fb3..a6852d396d9 100644 --- a/src/test/bench/task-perf-spawnalot.rs +++ b/src/test/bench/task-perf-spawnalot.rs @@ -15,7 +15,7 @@ use std::uint; 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; } } diff --git a/src/test/compile-fail/borrowck-loan-blocks-move-cc.rs b/src/test/compile-fail/borrowck-loan-blocks-move-cc.rs index b6ecb50fac8..cecb8a09c66 100644 --- a/src/test/compile-fail/borrowck-loan-blocks-move-cc.rs +++ b/src/test/compile-fail/borrowck-loan-blocks-move-cc.rs @@ -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 }); diff --git a/src/test/compile-fail/borrowck-move-by-capture.rs b/src/test/compile-fail/borrowck-move-by-capture.rs index c52924ebdb7..aae661e5c53 100644 --- a/src/test/compile-fail/borrowck-move-by-capture.rs +++ b/src/test/compile-fail/borrowck-move-by-capture.rs @@ -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 }; } diff --git a/src/test/compile-fail/borrowck-move-moved-value-into-closure.rs b/src/test/compile-fail/borrowck-move-moved-value-into-closure.rs index b385305d74a..ca484738cb6 100644 --- a/src/test/compile-fail/borrowck-move-moved-value-into-closure.rs +++ b/src/test/compile-fail/borrowck-move-moved-value-into-closure.rs @@ -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 } diff --git a/src/test/compile-fail/borrowck-multiple-captures.rs b/src/test/compile-fail/borrowck-multiple-captures.rs index 6faa634ad00..a9c368fb052 100644 --- a/src/test/compile-fail/borrowck-multiple-captures.rs +++ b/src/test/compile-fail/borrowck-multiple-captures.rs @@ -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` }); diff --git a/src/test/compile-fail/cannot-mutate-captured-non-mut-var.rs b/src/test/compile-fail/cannot-mutate-captured-non-mut-var.rs index daad1afedaa..143e78e5d9f 100644 --- a/src/test/compile-fail/cannot-mutate-captured-non-mut-var.rs +++ b/src/test/compile-fail/cannot-mutate-captured-non-mut-var.rs @@ -10,10 +10,10 @@ 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 } diff --git a/src/test/compile-fail/coerce-bare-fn-to-closure-and-proc.rs b/src/test/compile-fail/coerce-bare-fn-to-closure-and-proc.rs index 9f258aee746..27e339180a6 100644 --- a/src/test/compile-fail/coerce-bare-fn-to-closure-and-proc.rs +++ b/src/test/compile-fail/coerce-bare-fn-to-closure-and-proc.rs @@ -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 } diff --git a/src/test/compile-fail/issue-10398.rs b/src/test/compile-fail/issue-10398.rs index 9141ab669bb..c90f064bf90 100644 --- a/src/test/compile-fail/issue-10398.rs +++ b/src/test/compile-fail/issue-10398.rs @@ -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` diff --git a/src/test/compile-fail/issue-11515.rs b/src/test/compile-fail/issue-11515.rs index 82cd38ad5b0..46fcb2ec340 100644 --- a/src/test/compile-fail/issue-11515.rs +++ b/src/test/compile-fail/issue-11515.rs @@ -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 } diff --git a/src/test/compile-fail/issue-11925.rs b/src/test/compile-fail/issue-11925.rs index 5d62c25ea17..c561f0a696a 100644 --- a/src/test/compile-fail/issue-11925.rs +++ b/src/test/compile-fail/issue-11925.rs @@ -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() }; diff --git a/src/test/compile-fail/issue-12041.rs b/src/test/compile-fail/issue-12041.rs index f824a06aed1..1878b5f5dea 100644 --- a/src/test/compile-fail/issue-12041.rs +++ b/src/test/compile-fail/issue-12041.rs @@ -10,7 +10,7 @@ fn main() { let (tx, rx) = channel(); - spawn(proc() { + spawn(move|| { loop { let tx = tx; //~^ ERROR: use of moved value: `tx` diff --git a/src/test/compile-fail/issue-12127.rs b/src/test/compile-fail/issue-12127.rs index 78892425770..5f2837d2875 100644 --- a/src/test/compile-fail/issue-12127.rs +++ b/src/test/compile-fail/issue-12127.rs @@ -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` diff --git a/src/test/compile-fail/kindck-nonsendable-1.rs b/src/test/compile-fail/kindck-nonsendable-1.rs index d694fd2c795..c96054afc2f 100644 --- a/src/test/compile-fail/kindck-nonsendable-1.rs +++ b/src/test/compile-fail/kindck-nonsendable-1.rs @@ -13,14 +13,10 @@ use std::rc::Rc; 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() { } diff --git a/src/test/compile-fail/kindck-send-object.rs b/src/test/compile-fail/kindck-send-object.rs index 4fbb3eab8c4..3b67e98f42c 100644 --- a/src/test/compile-fail/kindck-send-object.rs +++ b/src/test/compile-fail/kindck-send-object.rs @@ -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>; } diff --git a/src/test/compile-fail/kindck-send-object1.rs b/src/test/compile-fail/kindck-send-object1.rs index 35e928d417c..d83a8031c45 100644 --- a/src/test/compile-fail/kindck-send-object1.rs +++ b/src/test/compile-fail/kindck-send-object1.rs @@ -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 diff --git a/src/test/compile-fail/moves-based-on-type-capture-clause-bad.rs b/src/test/compile-fail/moves-based-on-type-capture-clause-bad.rs index 97287c147d7..458e2aaf451 100644 --- a/src/test/compile-fail/moves-based-on-type-capture-clause-bad.rs +++ b/src/test/compile-fail/moves-based-on-type-capture-clause-bad.rs @@ -12,7 +12,7 @@ use std::task; fn main() { let x = "Hello world!".to_string(); - task::spawn(proc() { + task::spawn(move|| { println!("{}", x); }); println!("{}", x); //~ ERROR use of moved value diff --git a/src/test/compile-fail/moves-sru-moved-field.rs b/src/test/compile-fail/moves-sru-moved-field.rs index 74e5e6b1202..2cf7618d92d 100644 --- a/src/test/compile-fail/moves-sru-moved-field.rs +++ b/src/test/compile-fail/moves-sru-moved-field.rs @@ -9,7 +9,7 @@ // except according to those terms. -type Noncopyable = proc():'static; +type Noncopyable = Box<int>; struct Foo { copied: int, diff --git a/src/test/compile-fail/no-capture-arc.rs b/src/test/compile-fail/no-capture-arc.rs index a07317176e4..affe979268d 100644 --- a/src/test/compile-fail/no-capture-arc.rs +++ b/src/test/compile-fail/no-capture-arc.rs @@ -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); }); diff --git a/src/test/compile-fail/no-reuse-move-arc.rs b/src/test/compile-fail/no-reuse-move-arc.rs index 9f33f35838e..60982a84b79 100644 --- a/src/test/compile-fail/no-reuse-move-arc.rs +++ b/src/test/compile-fail/no-reuse-move-arc.rs @@ -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); }); diff --git a/src/test/compile-fail/no-send-res-ports.rs b/src/test/compile-fail/no-send-res-ports.rs index 83dbd9ac1bf..e1ba36de7c0 100644 --- a/src/test/compile-fail/no-send-res-ports.rs +++ b/src/test/compile-fail/no-send-res-ports.rs @@ -35,9 +35,9 @@ fn main() { 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); }); } diff --git a/src/test/compile-fail/once-cant-call-twice-on-heap.rs b/src/test/compile-fail/once-cant-call-twice-on-heap.rs index 68687773f27..6441f308f29 100644 --- a/src/test/compile-fail/once-cant-call-twice-on-heap.rs +++ b/src/test/compile-fail/once-cant-call-twice-on-heap.rs @@ -14,14 +14,14 @@ #![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); }); diff --git a/src/test/compile-fail/regions-bounded-by-send.rs b/src/test/compile-fail/regions-bounded-by-send.rs index ec679a7dda1..67655f323f0 100644 --- a/src/test/compile-fail/regions-bounded-by-send.rs +++ b/src/test/compile-fail/regions-bounded-by-send.rs @@ -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 diff --git a/src/test/compile-fail/regions-infer-proc-static-upvar.rs b/src/test/compile-fail/regions-infer-proc-static-upvar.rs index 7fe85290da0..8b2fdfe7cdd 100644 --- a/src/test/compile-fail/regions-infer-proc-static-upvar.rs +++ b/src/test/compile-fail/regions-infer-proc-static-upvar.rs @@ -11,14 +11,14 @@ // 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-proc-bound-capture.rs b/src/test/compile-fail/regions-proc-bound-capture.rs index e32ef275256..0841c1852f8 100644 --- a/src/test/compile-fail/regions-proc-bound-capture.rs +++ b/src/test/compile-fail/regions-proc-bound-capture.rs @@ -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() { } diff --git a/src/test/compile-fail/spawn-non-nil-fn.rs b/src/test/compile-fail/spawn-non-nil-fn.rs index 3a35d9cc309..6cc45090b90 100644 --- a/src/test/compile-fail/spawn-non-nil-fn.rs +++ b/src/test/compile-fail/spawn-non-nil-fn.rs @@ -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 index 00000000000..9bb8037e2c3 --- /dev/null +++ b/src/test/compile-fail/unboxed-closure-feature-gate.rs @@ -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)>; +} diff --git a/src/test/compile-fail/unboxed-closures-static-call-wrong-trait.rs b/src/test/compile-fail/unboxed-closures-static-call-wrong-trait.rs index 4fa72b38306..ddd2649a3fe 100644 --- a/src/test/compile-fail/unboxed-closures-static-call-wrong-trait.rs +++ b/src/test/compile-fail/unboxed-closures-static-call-wrong-trait.rs @@ -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` } diff --git a/src/test/compile-fail/unused-mut-warning-captured-var.rs b/src/test/compile-fail/unused-mut-warning-captured-var.rs index a3db84b0ac6..2c000e03ce4 100644 --- a/src/test/compile-fail/unused-mut-warning-captured-var.rs +++ b/src/test/compile-fail/unused-mut-warning-captured-var.rs @@ -13,5 +13,5 @@ fn main() { let mut x = 1i; //~^ ERROR: variable does not need to be mutable - proc() { println!("{}", x); }; + move|:| { println!("{}", x); }; } diff --git a/src/test/debuginfo/lexical-scope-in-unique-closure.rs b/src/test/debuginfo/lexical-scope-in-unique-closure.rs index 6ed6a273125..fa7822495d5 100644 --- a/src/test/debuginfo/lexical-scope-in-unique-closure.rs +++ b/src/test/debuginfo/lexical-scope-in-unique-closure.rs @@ -77,7 +77,7 @@ fn main() { zzz(); // #break sentinel(); - let unique_closure: proc(int) = proc(x) { + let unique_closure = |: x:int| { zzz(); // #break sentinel(); diff --git a/src/test/debuginfo/type-names.rs b/src/test/debuginfo/type-names.rs index e7664d1029b..d72b080409e 100644 --- a/src/test/debuginfo/type-names.rs +++ b/src/test/debuginfo/type-names.rs @@ -167,9 +167,6 @@ // 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); diff --git a/src/test/pretty/closure-reform-pretty.rs b/src/test/pretty/closure-reform-pretty.rs index eb20a09477d..328d4245eb6 100644 --- a/src/test/pretty/closure-reform-pretty.rs +++ b/src/test/pretty/closure-reform-pretty.rs @@ -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) { } diff --git a/src/test/pretty/fn-types.rs b/src/test/pretty/fn-types.rs index ffa6f03909b..1313af2df3d 100644 --- a/src/test/pretty/fn-types.rs +++ b/src/test/pretty/fn-types.rs @@ -12,5 +12,4 @@ fn from_foreign_fn(_x: fn()) { } fn from_stack_closure(_x: ||) { } -fn from_unique_closure(_x: proc()) { } fn main() { } diff --git a/src/test/run-fail/extern-panic.rs b/src/test/run-fail/extern-panic.rs index 21a332a46cb..e7c6dcc2df7 100644 --- a/src/test/run-fail/extern-panic.rs +++ b/src/test/run-fail/extern-panic.rs @@ -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!(); diff --git a/src/test/run-fail/panic-task-name-none.rs b/src/test/run-fail/panic-task-name-none.rs index 3f8abc41ff7..b3638385932 100644 --- a/src/test/run-fail/panic-task-name-none.rs +++ b/src/test/run-fail/panic-task-name-none.rs @@ -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 }); diff --git a/src/test/run-fail/panic-task-name-owned.rs b/src/test/run-fail/panic-task-name-owned.rs index 0a303475a29..3c442861a44 100644 --- a/src/test/run-fail/panic-task-name-owned.rs +++ b/src/test/run-fail/panic-task-name-owned.rs @@ -14,7 +14,7 @@ use std::task::TaskBuilder; fn main() { let r: Result<int,_> = TaskBuilder::new().named("owned name".to_string()) - .try(proc() { + .try(move|| { panic!("test"); 1i }); diff --git a/src/test/run-fail/panic-task-name-send-str.rs b/src/test/run-fail/panic-task-name-send-str.rs index fb4fb5c2f70..92ebb3b4587 100644 --- a/src/test/run-fail/panic-task-name-send-str.rs +++ b/src/test/run-fail/panic-task-name-send-str.rs @@ -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 }); diff --git a/src/test/run-fail/panic-task-name-static.rs b/src/test/run-fail/panic-task-name-static.rs index 21c019e1a74..f8dfe9245b4 100644 --- a/src/test/run-fail/panic-task-name-static.rs +++ b/src/test/run-fail/panic-task-name-static.rs @@ -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()); diff --git a/src/test/run-fail/rt-set-exit-status-panic2.rs b/src/test/run-fail/rt-set-exit-status-panic2.rs index 1cfc6c36a63..58de34e92a0 100644 --- a/src/test/run-fail/rt-set-exit-status-panic2.rs +++ b/src/test/run-fail/rt-set-exit-status-panic2.rs @@ -36,7 +36,7 @@ fn r(x:int) -> r { fn main() { error!("whatever"); - task::spawn(proc() { + task::spawn(move|| { let _i = r(5); }); panic!(); diff --git a/src/test/run-make/bootstrap-from-c-with-native/lib.rs b/src/test/run-make/bootstrap-from-c-with-native/lib.rs index 34d9cc48ffe..d2fd5393834 100644 --- a/src/test/run-make/bootstrap-from-c-with-native/lib.rs +++ b/src/test/run-make/bootstrap-from-c-with-native/lib.rs @@ -12,12 +12,13 @@ #![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"); }); - }) + })) } diff --git a/src/test/run-make/static-unwinding/main.rs b/src/test/run-make/static-unwinding/main.rs index 9918fbb1ab7..e2cca4d11f9 100644 --- a/src/test/run-make/static-unwinding/main.rs +++ b/src/test/run-make/static-unwinding/main.rs @@ -22,7 +22,7 @@ impl Drop for A { } fn main() { - task::try(proc() { + task::try(move|| { let _a = A; lib::callback(|| panic!()); 1i diff --git a/src/test/run-pass/block-arg-call-as.rs b/src/test/run-pass/block-arg-call-as.rs index fd40f0b4b80..b4e36629651 100644 --- a/src/test/run-pass/block-arg-call-as.rs +++ b/src/test/run-pass/block-arg-call-as.rs @@ -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); } diff --git a/src/test/run-pass/block-arg.rs b/src/test/run-pass/block-arg.rs index 4b81654a1d0..d017a0dbf9a 100644 --- a/src/test/run-pass/block-arg.rs +++ b/src/test/run-pass/block-arg.rs @@ -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); diff --git a/src/test/run-pass/borrowck-move-by-capture-ok.rs b/src/test/run-pass/borrowck-move-by-capture-ok.rs index 48ddf927722..a6b142bb126 100644 --- a/src/test/run-pass/borrowck-move-by-capture-ok.rs +++ b/src/test/run-pass/borrowck-move-by-capture-ok.rs @@ -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); } + diff --git a/src/test/run-pass/capturing-logging.rs b/src/test/run-pass/capturing-logging.rs index a6744585e47..f2df5ef38c3 100644 --- a/src/test/run-pass/capturing-logging.rs +++ b/src/test/run-pass/capturing-logging.rs @@ -32,7 +32,7 @@ impl Logger for MyWriter { 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"); diff --git a/src/test/run-pass/child-outlives-parent.rs b/src/test/run-pass/child-outlives-parent.rs index 82855729fa8..bdd92919ef0 100644 --- a/src/test/run-pass/child-outlives-parent.rs +++ b/src/test/run-pass/child-outlives-parent.rs @@ -15,5 +15,5 @@ use std::task; 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())); } diff --git a/src/test/run-pass/clone-with-exterior.rs b/src/test/run-pass/clone-with-exterior.rs index f676a6f0959..d3c703b258f 100644 --- a/src/test/run-pass/clone-with-exterior.rs +++ b/src/test/run-pass/clone-with-exterior.rs @@ -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); + }); } diff --git a/src/test/run-pass/closure-bounds-can-capture-chan.rs b/src/test/run-pass/closure-bounds-can-capture-chan.rs index 3c4b7236ad5..cdcdad47ea4 100644 --- a/src/test/run-pass/closure-bounds-can-capture-chan.rs +++ b/src/test/run-pass/closure-bounds-can-capture-chan.rs @@ -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(); diff --git a/src/test/run-pass/closure-reform.rs b/src/test/run-pass/closure-reform.rs index aa4d48e5ae0..03d9511b41c 100644 --- a/src/test/run-pass/closure-reform.rs +++ b/src/test/run-pass/closure-reform.rs @@ -11,10 +11,14 @@ /* 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) }); diff --git a/src/test/run-pass/closure-syntax.rs b/src/test/run-pass/closure-syntax.rs index 6716c3468d0..4caa234ac7a 100644 --- a/src/test/run-pass/closure-syntax.rs +++ b/src/test/run-pass/closure-syntax.rs @@ -15,35 +15,23 @@ 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 |&:| {}; diff --git a/src/test/run-pass/coerce-to-closure-and-proc.rs b/src/test/run-pass/coerce-to-closure-and-proc.rs index 6dbc402e785..5a1b401177e 100644 --- a/src/test/run-pass/coerce-to-closure-and-proc.rs +++ b/src/test/run-pass/coerce-to-closure-and-proc.rs @@ -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)); } diff --git a/src/test/run-pass/comm.rs b/src/test/run-pass/comm.rs index 18cc92f335d..edd4d5642b5 100644 --- a/src/test/run-pass/comm.rs +++ b/src/test/run-pass/comm.rs @@ -12,7 +12,7 @@ use std::task; 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); diff --git a/src/test/run-pass/core-run-destroy.rs b/src/test/run-pass/core-run-destroy.rs index d8dfb433e6d..4e625ce1d1f 100644 --- a/src/test/run-pass/core-run-destroy.rs +++ b/src/test/run-pass/core-run-destroy.rs @@ -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() => {} diff --git a/src/test/run-pass/drop-trait-enum.rs b/src/test/run-pass/drop-trait-enum.rs index 15f028e1716..24915d84e7e 100644 --- a/src/test/run-pass/drop-trait-enum.rs +++ b/src/test/run-pass/drop-trait-enum.rs @@ -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()); diff --git a/src/test/run-pass/enum-null-pointer-opt.rs b/src/test/run-pass/enum-null-pointer-opt.rs index 3e22c833183..2d4819231fa 100644 --- a/src/test/run-pass/enum-null-pointer-opt.rs +++ b/src/test/run-pass/enum-null-pointer-opt.rs @@ -14,8 +14,7 @@ use std::mem::size_of; trait Trait {} fn main() { - // Closures - || / proc() - assert_eq!(size_of::<proc()>(), size_of::<Option<proc()>>()); + // Closures - || assert_eq!(size_of::<||>(), size_of::<Option<||>>()); // Functions diff --git a/src/test/run-pass/explicit-self-generic.rs b/src/test/run-pass/explicit-self-generic.rs index eeda299c71f..87f1adba8dd 100644 --- a/src/test/run-pass/explicit-self-generic.rs +++ b/src/test/run-pass/explicit-self-generic.rs @@ -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 {} diff --git a/src/test/run-pass/extern-call-deep2.rs b/src/test/run-pass/extern-call-deep2.rs index bc5ccc30c52..aed1392c8b6 100644 --- a/src/test/run-pass/extern-call-deep2.rs +++ b/src/test/run-pass/extern-call-deep2.rs @@ -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); diff --git a/src/test/run-pass/extern-call-scrub.rs b/src/test/run-pass/extern-call-scrub.rs index ae9430370d5..3f5faabe595 100644 --- a/src/test/run-pass/extern-call-scrub.rs +++ b/src/test/run-pass/extern-call-scrub.rs @@ -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); diff --git a/src/test/run-pass/extern-stress.rs b/src/test/run-pass/extern-stress.rs index 87d96880e4b..8b080712b96 100644 --- a/src/test/run-pass/extern-stress.rs +++ b/src/test/run-pass/extern-stress.rs @@ -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); }); } diff --git a/src/test/run-pass/extern-yield.rs b/src/test/run-pass/extern-yield.rs index 7fb68e9f8a0..1c89d8ae1ce 100644 --- a/src/test/run-pass/extern-yield.rs +++ b/src/test/run-pass/extern-yield.rs @@ -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); diff --git a/src/test/run-pass/foreign-call-no-runtime.rs b/src/test/run-pass/foreign-call-no-runtime.rs index af36387f06c..3f659f1dbfb 100644 --- a/src/test/run-pass/foreign-call-no-runtime.rs +++ b/src/test/run-pass/foreign-call-no-runtime.rs @@ -22,7 +22,7 @@ extern { pub fn main() { unsafe { - Thread::start(proc() { + Thread::start(move|| { let i = &100i; rust_dbg_call(callback, mem::transmute(i)); }).join(); diff --git a/src/test/run-pass/hashmap-memory.rs b/src/test/run-pass/hashmap-memory.rs index 8efd3af4bce..a92b361dd33 100644 --- a/src/test/run-pass/hashmap-memory.rs +++ b/src/test/run-pass/hashmap-memory.rs @@ -37,7 +37,7 @@ mod map_reduce { 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()) ); } } diff --git a/src/test/run-pass/hrtb-parse.rs b/src/test/run-pass/hrtb-parse.rs index 02d3bc120da..53749f09f74 100644 --- a/src/test/run-pass/hrtb-parse.rs +++ b/src/test/run-pass/hrtb-parse.rs @@ -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() { } diff --git a/src/test/run-pass/infinite-loops.rs b/src/test/run-pass/infinite-loops.rs index f4de938c66e..e4168ea1452 100644 --- a/src/test/run-pass/infinite-loops.rs +++ b/src/test/run-pass/infinite-loops.rs @@ -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) }); } diff --git a/src/test/run-pass/issue-10682.rs b/src/test/run-pass/issue-10682.rs index f2f8b17daa2..fd0ad1ef47e 100644 --- a/src/test/run-pass/issue-10682.rs +++ b/src/test/run-pass/issue-10682.rs @@ -11,11 +11,10 @@ // 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) }) }) } diff --git a/src/test/run-pass/issue-10718.rs b/src/test/run-pass/issue-10718.rs index 34804eda287..71b4cbe9334 100644 --- a/src/test/run-pass/issue-10718.rs +++ b/src/test/run-pass/issue-10718.rs @@ -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); } diff --git a/src/test/run-pass/issue-11709.rs b/src/test/run-pass/issue-11709.rs index 0567a5836ab..f9d79567932 100644 --- a/src/test/run-pass/issue-11709.rs +++ b/src/test/run-pass/issue-11709.rs @@ -15,14 +15,17 @@ // 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); } diff --git a/src/test/run-pass/issue-11958.rs b/src/test/run-pass/issue-11958.rs index f4ed7c5d9c8..13177880c5a 100644 --- a/src/test/run-pass/issue-11958.rs +++ b/src/test/run-pass/issue-11958.rs @@ -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; }); } diff --git a/src/test/run-pass/issue-12684.rs b/src/test/run-pass/issue-12684.rs index c3aba9e8dc9..e24cf5a0f26 100644 --- a/src/test/run-pass/issue-12684.rs +++ b/src/test/run-pass/issue-12684.rs @@ -11,7 +11,7 @@ use std::time::Duration; fn main() { - std::task::spawn(proc() customtask()); + std::task::spawn(move|| customtask()); } fn customtask() { diff --git a/src/test/run-pass/issue-13352.rs b/src/test/run-pass/issue-13352.rs index afebcb3cdfc..46a81301dc3 100644 --- a/src/test/run-pass/issue-13352.rs +++ b/src/test/run-pass/issue-13352.rs @@ -10,7 +10,9 @@ extern crate libc; -fn foo(_: proc()) {} +use std::thunk::Thunk; + +fn foo(_: Thunk) {} fn main() { foo(loop { diff --git a/src/test/run-pass/issue-13494.rs b/src/test/run-pass/issue-13494.rs index 9fe41f7e024..be851ddefc6 100644 --- a/src/test/run-pass/issue-13494.rs +++ b/src/test/run-pass/issue-13494.rs @@ -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); diff --git a/src/test/run-pass/issue-14039.rs b/src/test/run-pass/issue-14039.rs index c017a9dad64..9a1cc8569a3 100644 --- a/src/test/run-pass/issue-14039.rs +++ b/src/test/run-pass/issue-14039.rs @@ -10,8 +10,8 @@ fn main() { if true { - proc(_) {} + (move|&mut: _| {}) as Box<FnMut()> } else { - proc(_: &mut ()) {} + (move|&mut: _: &mut ()| {}) as Box<FnMut()> }; } diff --git a/src/test/run-pass/issue-15571.rs b/src/test/run-pass/issue-15571.rs index 0ef0fc83c94..03d18cf8c98 100644 --- a/src/test/run-pass/issue-15571.rs +++ b/src/test/run-pass/issue-15571.rs @@ -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() { diff --git a/src/test/run-pass/issue-16560.rs b/src/test/run-pass/issue-16560.rs index 77eba0245b1..f329e7eed0d 100644 --- a/src/test/run-pass/issue-16560.rs +++ b/src/test/run-pass/issue-16560.rs @@ -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; }) } diff --git a/src/test/run-pass/issue-16671.rs b/src/test/run-pass/issue-16671.rs index 20bf1b260de..c695a9e8f9a 100644 --- a/src/test/run-pass/issue-16671.rs +++ b/src/test/run-pass/issue-16671.rs @@ -20,7 +20,7 @@ pub fn main() { let mut stdin = std::io::stdin(); - spawn(proc() { + spawn(move|| { let _ = stdin.read_to_end(); }); } diff --git a/src/test/run-pass/issue-2190-1.rs b/src/test/run-pass/issue-2190-1.rs index 4ff735708b5..3554f2e8f0c 100644 --- a/src/test/run-pass/issue-2190-1.rs +++ b/src/test/run-pass/issue-2190-1.rs @@ -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() { diff --git a/src/test/run-pass/issue-3424.rs b/src/test/run-pass/issue-3424.rs index 81efacb9bcb..651315ea641 100644 --- a/src/test/run-pass/issue-3424.rs +++ b/src/test/run-pass/issue-3424.rs @@ -11,20 +11,23 @@ // 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() {} diff --git a/src/test/run-pass/issue-3609.rs b/src/test/run-pass/issue-3609.rs index be5387b23c2..f17f9411d15 100644 --- a/src/test/run-pass/issue-3609.rs +++ b/src/test/run-pass/issue-3609.rs @@ -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)); }); } diff --git a/src/test/run-pass/issue-4446.rs b/src/test/run-pass/issue-4446.rs index 2266e62eb77..daa80aec28c 100644 --- a/src/test/run-pass/issue-4446.rs +++ b/src/test/run-pass/issue-4446.rs @@ -15,7 +15,7 @@ pub fn main() { tx.send("hello, world"); - spawn(proc() { + spawn(move|| { println(rx.recv()); }); } diff --git a/src/test/run-pass/issue-4448.rs b/src/test/run-pass/issue-4448.rs index dda90ef1a0f..3ea968c416f 100644 --- a/src/test/run-pass/issue-4448.rs +++ b/src/test/run-pass/issue-4448.rs @@ -13,7 +13,7 @@ use std::task; pub fn main() { let (tx, rx) = channel::<&'static str>(); - task::spawn(proc() { + task::spawn(move|| { assert_eq!(rx.recv(), "hello, world"); }); diff --git a/src/test/run-pass/issue-8460.rs b/src/test/run-pass/issue-8460.rs index 762152c9203..b9b365e3e66 100644 --- a/src/test/run-pass/issue-8460.rs +++ b/src/test/run-pass/issue-8460.rs @@ -12,24 +12,24 @@ use std::{int, i8, i16, i32, i64}; 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()); } diff --git a/src/test/run-pass/issue-8827.rs b/src/test/run-pass/issue-8827.rs index 173414d1d41..7397ad74495 100644 --- a/src/test/run-pass/issue-8827.rs +++ b/src/test/run-pass/issue-8827.rs @@ -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) { diff --git a/src/test/run-pass/issue-9396.rs b/src/test/run-pass/issue-9396.rs index c16319a16f2..588e0c1cf16 100644 --- a/src/test/run-pass/issue-9396.rs +++ b/src/test/run-pass/issue-9396.rs @@ -14,7 +14,7 @@ use std::time::Duration; pub fn main() { let (tx, rx) = channel(); - spawn(proc (){ + spawn(move||{ let mut timer = Timer::new().unwrap(); timer.sleep(Duration::milliseconds(10)); tx.send(()); diff --git a/src/test/run-pass/ivec-tag.rs b/src/test/run-pass/ivec-tag.rs index 81ff6fd7adc..1f7edcf43b8 100644 --- a/src/test/run-pass/ivec-tag.rs +++ b/src/test/run-pass/ivec-tag.rs @@ -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) }); diff --git a/src/test/run-pass/kindck-implicit-close-over-mut-var.rs b/src/test/run-pass/kindck-implicit-close-over-mut-var.rs index 3f45e864da3..d745226af44 100644 --- a/src/test/run-pass/kindck-implicit-close-over-mut-var.rs +++ b/src/test/run-pass/kindck-implicit-close-over-mut-var.rs @@ -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); diff --git a/src/test/run-pass/logging-only-prints-once.rs b/src/test/run-pass/logging-only-prints-once.rs index c1f7e569feb..1e05c05cc0d 100644 --- a/src/test/run-pass/logging-only-prints-once.rs +++ b/src/test/run-pass/logging-only-prints-once.rs @@ -27,7 +27,7 @@ impl fmt::Show for Foo { 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; diff --git a/src/test/run-pass/macro-with-braces-in-expr-position.rs b/src/test/run-pass/macro-with-braces-in-expr-position.rs index f9b1b951cf0..8b59f26d869 100644 --- a/src/test/run-pass/macro-with-braces-in-expr-position.rs +++ b/src/test/run-pass/macro-with-braces-in-expr-position.rs @@ -14,7 +14,7 @@ macro_rules! expr (($e: expr) => { $e }) macro_rules! spawn { ($($code: tt)*) => { - expr!(spawn(proc() {$($code)*})) + expr!(spawn(move|| {$($code)*})) } } diff --git a/src/test/run-pass/moves-based-on-type-capture-clause.rs b/src/test/run-pass/moves-based-on-type-capture-clause.rs index 7fd37969e67..e5694aefdf4 100644 --- a/src/test/run-pass/moves-based-on-type-capture-clause.rs +++ b/src/test/run-pass/moves-based-on-type-capture-clause.rs @@ -12,7 +12,7 @@ use std::task; pub fn main() { let x = "Hello world!".to_string(); - task::spawn(proc() { + task::spawn(move|| { println!("{}", x); }); } diff --git a/src/test/run-pass/newlambdas-ret-infer.rs b/src/test/run-pass/newlambdas-ret-infer.rs index f704545af33..d74f1349506 100644 --- a/src/test/run-pass/newlambdas-ret-infer.rs +++ b/src/test/run-pass/newlambdas-ret-infer.rs @@ -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() { } diff --git a/src/test/run-pass/newlambdas-ret-infer2.rs b/src/test/run-pass/newlambdas-ret-infer2.rs index 22e51ea9a75..43a6ac296e9 100644 --- a/src/test/run-pass/newlambdas-ret-infer2.rs +++ b/src/test/run-pass/newlambdas-ret-infer2.rs @@ -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() { } diff --git a/src/test/run-pass/no-landing-pads.rs b/src/test/run-pass/no-landing-pads.rs index eda36fad215..e8bf366df95 100644 --- a/src/test/run-pass/no-landing-pads.rs +++ b/src/test/run-pass/no-landing-pads.rs @@ -23,7 +23,7 @@ impl Drop for A { } fn main() { - task::try::<()>(proc() { + task::try(move|| -> () { let _a = A; panic!(); }); diff --git a/src/test/run-pass/once-move-out-on-heap.rs b/src/test/run-pass/once-move-out-on-heap.rs index e24e809ed01..8fe57a655aa 100644 --- a/src/test/run-pass/once-move-out-on-heap.rs +++ b/src/test/run-pass/once-move-out-on-heap.rs @@ -13,13 +13,13 @@ 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); }); diff --git a/src/test/run-pass/operator-overloading.rs b/src/test/run-pass/operator-overloading.rs index a896d2b06f7..49396d80029 100644 --- a/src/test/run-pass/operator-overloading.rs +++ b/src/test/run-pass/operator-overloading.rs @@ -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) { } diff --git a/src/test/run-pass/out-of-stack-new-thread-no-split.rs b/src/test/run-pass/out-of-stack-new-thread-no-split.rs index 21847a486d9..419d9b5d824 100644 --- a/src/test/run-pass/out-of-stack-new-thread-no-split.rs +++ b/src/test/run-pass/out-of-stack-new-thread-no-split.rs @@ -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(()); }); diff --git a/src/test/run-pass/panic-in-dtor-drops-fields.rs b/src/test/run-pass/panic-in-dtor-drops-fields.rs index 46924c74a8c..39252d6b142 100644 --- a/src/test/run-pass/panic-in-dtor-drops-fields.rs +++ b/src/test/run-pass/panic-in-dtor-drops-fields.rs @@ -33,7 +33,7 @@ impl Drop for B { } pub fn main() { - let ret = task::try(proc() { + let ret = task::try(move|| { let _a = A { b: B { foo: 3 } }; }); assert!(ret.is_err()); diff --git a/src/test/run-pass/preempt.rs b/src/test/run-pass/preempt.rs index 53d2a47863b..bcfc39ee7e4 100644 --- a/src/test/run-pass/preempt.rs +++ b/src/test/run-pass/preempt.rs @@ -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/compile-fail/regions-infer-region-in-fn-but-not-type.rs b/src/test/run-pass/regions-infer-region-in-fn-but-not-type.rs index 0fa4969b54c..9174b53be86 100644 --- a/src/test/compile-fail/regions-infer-region-in-fn-but-not-type.rs +++ b/src/test/run-pass/regions-infer-region-in-fn-but-not-type.rs @@ -11,9 +11,12 @@ // check that the &int here does not cause us to think that `foo` // contains region pointers -struct foo(proc(x: &int):'static); +struct foo(Box<FnMut(&int)+'static>); -fn take_foo(x: foo<'static>) {} //~ ERROR wrong number of lifetime parameters +fn take_foo<T:'static>(x: T) {} -fn main() { +fn have_foo(f: foo) { + take_foo(f); } + +fn main() {} diff --git a/src/test/run-pass/regions-infer-static-from-proc.rs b/src/test/run-pass/regions-infer-static-from-proc.rs index 823644ddfb5..cb45b8e131d 100644 --- a/src/test/run-pass/regions-infer-static-from-proc.rs +++ b/src/test/run-pass/regions-infer-static-from-proc.rs @@ -13,11 +13,11 @@ // 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); }); } diff --git a/src/test/run-pass/return-from-closure.rs b/src/test/run-pass/return-from-closure.rs index 2709904fb4c..b905ebf52fc 100644 --- a/src/test/run-pass/return-from-closure.rs +++ b/src/test/run-pass/return-from-closure.rs @@ -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; } diff --git a/src/test/run-pass/running-with-no-runtime.rs b/src/test/run-pass/running-with-no-runtime.rs index 683f7038ead..36b90a9168f 100644 --- a/src/test/run-pass/running-with-no-runtime.rs +++ b/src/test/run-pass/running-with-no-runtime.rs @@ -14,6 +14,7 @@ use std::io::process::{Command, ProcessOutput}; 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() { diff --git a/src/test/run-pass/rust-log-filter.rs b/src/test/run-pass/rust-log-filter.rs index 275a390d5d3..88d30318f2a 100644 --- a/src/test/run-pass/rust-log-filter.rs +++ b/src/test/run-pass/rust-log-filter.rs @@ -34,7 +34,7 @@ impl log::Logger for ChannelLogger { pub fn main() { let (logger, rx) = ChannelLogger::new(); - spawn(proc() { + spawn(move|| { log::set_logger(logger); // our regex is "f.o" diff --git a/src/test/run-pass/send-resource.rs b/src/test/run-pass/send-resource.rs index e368116f26c..6001c360ab9 100644 --- a/src/test/run-pass/send-resource.rs +++ b/src/test/run-pass/send-resource.rs @@ -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); diff --git a/src/test/run-pass/sendfn-spawn-with-fn-arg.rs b/src/test/run-pass/sendfn-spawn-with-fn-arg.rs index c03094d4f15..838c627040d 100644 --- a/src/test/run-pass/sendfn-spawn-with-fn-arg.rs +++ b/src/test/run-pass/sendfn-spawn-with-fn-arg.rs @@ -12,17 +12,17 @@ use std::task; 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); }); } diff --git a/src/test/run-pass/sepcomp-unwind.rs b/src/test/run-pass/sepcomp-unwind.rs index c2c7a48815c..ccebfa72384 100644 --- a/src/test/run-pass/sepcomp-unwind.rs +++ b/src/test/run-pass/sepcomp-unwind.rs @@ -34,5 +34,5 @@ mod b { } fn main() { - std::task::try(proc() { ::b::g() }).unwrap_err(); + std::task::try(move|| { ::b::g() }).unwrap_err(); } diff --git a/src/test/run-pass/slice-panic-1.rs b/src/test/run-pass/slice-panic-1.rs index b07cf595968..b66641affc9 100644 --- a/src/test/run-pass/slice-panic-1.rs +++ b/src/test/run-pass/slice-panic-1.rs @@ -28,6 +28,6 @@ fn foo() { } fn main() { - let _ = task::try(proc() foo()); + let _ = task::try(move|| foo()); unsafe { assert!(DTOR_COUNT == 2); } } diff --git a/src/test/run-pass/slice-panic-2.rs b/src/test/run-pass/slice-panic-2.rs index 0ac7a2001fc..f7e241554c1 100644 --- a/src/test/run-pass/slice-panic-2.rs +++ b/src/test/run-pass/slice-panic-2.rs @@ -32,6 +32,6 @@ fn foo() { } fn main() { - let _ = task::try(proc() foo()); + let _ = task::try(move|| foo()); unsafe { assert!(DTOR_COUNT == 2); } } diff --git a/src/test/run-pass/spawn-fn.rs b/src/test/run-pass/spawn-fn.rs index dba3fe325fa..b632bc77c75 100644 --- a/src/test/run-pass/spawn-fn.rs +++ b/src/test/run-pass/spawn-fn.rs @@ -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; diff --git a/src/test/run-pass/spawn-types.rs b/src/test/run-pass/spawn-types.rs index 1418ab86174..9b533c69f32 100644 --- a/src/test/run-pass/spawn-types.rs +++ b/src/test/run-pass/spawn-types.rs @@ -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()) ); } diff --git a/src/test/run-pass/spawn.rs b/src/test/run-pass/spawn.rs index 741e20d42db..cfc1967ae24 100644 --- a/src/test/run-pass/spawn.rs +++ b/src/test/run-pass/spawn.rs @@ -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)); } diff --git a/src/test/run-pass/spawn2.rs b/src/test/run-pass/spawn2.rs index 6bac7f2a06e..72db4de2c8d 100644 --- a/src/test/run-pass/spawn2.rs +++ b/src/test/run-pass/spawn2.rs @@ -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; diff --git a/src/test/run-pass/spawning-with-debug.rs b/src/test/run-pass/spawning-with-debug.rs index 264662d7d8b..0f12827e60e 100644 --- a/src/test/run-pass/spawning-with-debug.rs +++ b/src/test/run-pass/spawning-with-debug.rs @@ -17,5 +17,5 @@ use std::task::TaskBuilder; pub fn main() { let mut t = TaskBuilder::new(); - t.spawn(proc() ()); + t.spawn(move|| ()); } diff --git a/src/test/run-pass/swap-overlapping.rs b/src/test/run-pass/swap-overlapping.rs index 06092200a14..b25b350aa4b 100644 --- a/src/test/run-pass/swap-overlapping.rs +++ b/src/test/run-pass/swap-overlapping.rs @@ -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 { diff --git a/src/test/run-pass/task-comm-0.rs b/src/test/run-pass/task-comm-0.rs index 469c1b868db..9e3511ba603 100644 --- a/src/test/run-pass/task-comm-0.rs +++ b/src/test/run-pass/task-comm-0.rs @@ -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(); diff --git a/src/test/run-pass/task-comm-1.rs b/src/test/run-pass/task-comm-1.rs index 8eaa7f2e31d..4117f201547 100644 --- a/src/test/run-pass/task-comm-1.rs +++ b/src/test/run-pass/task-comm-1.rs @@ -15,6 +15,6 @@ pub fn main() { test00(); } fn start() { println!("Started / Finished task."); } fn test00() { - task::try(proc() start() ); + task::try(move|| start() ); println!("Completing."); } diff --git a/src/test/run-pass/task-comm-10.rs b/src/test/run-pass/task-comm-10.rs index 8054fb0f43b..dd3c90991f6 100644 --- a/src/test/run-pass/task-comm-10.rs +++ b/src/test/run-pass/task-comm-10.rs @@ -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()); diff --git a/src/test/run-pass/task-comm-11.rs b/src/test/run-pass/task-comm-11.rs index 719d8e8120e..aefc91df4e7 100644 --- a/src/test/run-pass/task-comm-11.rs +++ b/src/test/run-pass/task-comm-11.rs @@ -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(); diff --git a/src/test/run-pass/task-comm-12.rs b/src/test/run-pass/task-comm-12.rs index f72c0ef8d7b..d950eb8aec4 100644 --- a/src/test/run-pass/task-comm-12.rs +++ b/src/test/run-pass/task-comm-12.rs @@ -16,7 +16,7 @@ fn start(_task_number: int) { println!("Started / Finished task."); } fn test00() { let i: int = 0; - let mut result = task::try_future(proc() { + let mut result = task::try_future(move|| { start(i) }); diff --git a/src/test/run-pass/task-comm-13.rs b/src/test/run-pass/task-comm-13.rs index 3f3d6742971..c6c0691b749 100644 --- a/src/test/run-pass/task-comm-13.rs +++ b/src/test/run-pass/task-comm-13.rs @@ -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"); } diff --git a/src/test/run-pass/task-comm-14.rs b/src/test/run-pass/task-comm-14.rs index 3f20495f652..0e483813665 100644 --- a/src/test/run-pass/task-comm-14.rs +++ b/src/test/run-pass/task-comm-14.rs @@ -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; } diff --git a/src/test/run-pass/task-comm-15.rs b/src/test/run-pass/task-comm-15.rs index fe4c233224d..3095c2098ff 100644 --- a/src/test/run-pass/task-comm-15.rs +++ b/src/test/run-pass/task-comm-15.rs @@ -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(); diff --git a/src/test/run-pass/task-comm-17.rs b/src/test/run-pass/task-comm-17.rs index 4f4d365901e..3a591d12864 100644 --- a/src/test/run-pass/task-comm-17.rs +++ b/src/test/run-pass/task-comm-17.rs @@ -18,5 +18,5 @@ fn f() { } pub fn main() { - task::spawn(proc() f() ); + task::spawn(move|| f() ); } diff --git a/src/test/run-pass/task-comm-3.rs b/src/test/run-pass/task-comm-3.rs index 583840ede5f..2908ec1e561 100644 --- a/src/test/run-pass/task-comm-3.rs +++ b/src/test/run-pass/task-comm-3.rs @@ -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) } })); diff --git a/src/test/run-pass/task-comm-7.rs b/src/test/run-pass/task-comm-7.rs index 170e1e8597b..9d8caa42626 100644 --- a/src/test/run-pass/task-comm-7.rs +++ b/src/test/run-pass/task-comm-7.rs @@ -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); }); diff --git a/src/test/run-pass/task-comm-9.rs b/src/test/run-pass/task-comm-9.rs index cc71ccdfa19..1c197e823f2 100644 --- a/src/test/run-pass/task-comm-9.rs +++ b/src/test/run-pass/task-comm-9.rs @@ -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); }); diff --git a/src/test/run-pass/task-life-0.rs b/src/test/run-pass/task-life-0.rs index 5e0d1846831..5c73f44f2d6 100644 --- a/src/test/run-pass/task-life-0.rs +++ b/src/test/run-pass/task-life-0.rs @@ -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) { diff --git a/src/test/run-pass/task-spawn-move-and-copy.rs b/src/test/run-pass/task-spawn-move-and-copy.rs index fafb9412c01..8d6b6005a63 100644 --- a/src/test/run-pass/task-spawn-move-and-copy.rs +++ b/src/test/run-pass/task-spawn-move-and-copy.rs @@ -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); }); diff --git a/src/test/run-pass/task-stderr.rs b/src/test/run-pass/task-stderr.rs index 0dbe74d722b..72cf7599f89 100644 --- a/src/test/run-pass/task-stderr.rs +++ b/src/test/run-pass/task-stderr.rs @@ -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()); diff --git a/src/test/run-pass/tcp-accept-stress.rs b/src/test/run-pass/tcp-accept-stress.rs index 1ed2efa4b32..780cf234466 100644 --- a/src/test/run-pass/tcp-accept-stress.rs +++ b/src/test/run-pass/tcp-accept-stress.rs @@ -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(); } diff --git a/src/test/run-pass/tcp-connect-timeouts.rs b/src/test/run-pass/tcp-connect-timeouts.rs index 7dcbccdb17a..2e4b9da691e 100644 --- a/src/test/run-pass/tcp-connect-timeouts.rs +++ b/src/test/run-pass/tcp-connect-timeouts.rs @@ -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(); diff --git a/src/test/run-pass/tcp-stress.rs b/src/test/run-pass/tcp-stress.rs index 34fbe1c9a95..4d691dd2526 100644 --- a/src/test/run-pass/tcp-stress.rs +++ b/src/test/run-pass/tcp-stress.rs @@ -24,7 +24,7 @@ use std::time::Duration; 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; diff --git a/src/test/run-pass/tempfile.rs b/src/test/run-pass/tempfile.rs index 7400c52a73b..a866f497b86 100644 --- a/src/test/run-pass/tempfile.rs +++ b/src/test/run-pass/tempfile.rs @@ -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 diff --git a/src/test/run-pass/terminate-in-initializer.rs b/src/test/run-pass/terminate-in-initializer.rs index 2a71148216d..28bbac1d087 100644 --- a/src/test/run-pass/terminate-in-initializer.rs +++ b/src/test/run-pass/terminate-in-initializer.rs @@ -22,13 +22,13 @@ fn test_ret() { let _x: Box<int> = return; } 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() { diff --git a/src/test/run-pass/threads.rs b/src/test/run-pass/threads.rs index dc862f201c2..71adf16c051 100644 --- a/src/test/run-pass/threads.rs +++ b/src/test/run-pass/threads.rs @@ -12,7 +12,7 @@ use std::task; 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"); } diff --git a/src/test/run-pass/trait-bounds-in-arc.rs b/src/test/run-pass/trait-bounds-in-arc.rs index 50d3531b632..d2c1461d65d 100644 --- a/src/test/run-pass/trait-bounds-in-arc.rs +++ b/src/test/run-pass/trait-bounds-in-arc.rs @@ -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(); diff --git a/src/test/run-pass/unique-send-2.rs b/src/test/run-pass/unique-send-2.rs index 432a0527ada..672cd2d00e8 100644 --- a/src/test/run-pass/unique-send-2.rs +++ b/src/test/run-pass/unique-send-2.rs @@ -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; diff --git a/src/test/run-pass/unit-like-struct-drop-run.rs b/src/test/run-pass/unit-like-struct-drop-run.rs index c12303b009f..e3cd694c0de 100644 --- a/src/test/run-pass/unit-like-struct-drop-run.rs +++ b/src/test/run-pass/unit-like-struct-drop-run.rs @@ -22,7 +22,7 @@ impl Drop for Foo { } pub fn main() { - let x = task::try(proc() { + let x = task::try(move|| { let _b = Foo; }); diff --git a/src/test/run-pass/unwind-resource.rs b/src/test/run-pass/unwind-resource.rs index 60f07663bef..9789deef636 100644 --- a/src/test/run-pass/unwind-resource.rs +++ b/src/test/run-pass/unwind-resource.rs @@ -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()); } diff --git a/src/test/run-pass/vector-sort-panic-safe.rs b/src/test/run-pass/vector-sort-panic-safe.rs index ce9cc68bd36..c969e66957c 100644 --- a/src/test/run-pass/vector-sort-panic-safe.rs +++ b/src/test/run-pass/vector-sort-panic-safe.rs @@ -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| { diff --git a/src/test/run-pass/weak-lang-item.rs b/src/test/run-pass/weak-lang-item.rs index d44e25550ef..87226eedfdc 100644 --- a/src/test/run-pass/weak-lang-item.rs +++ b/src/test/run-pass/weak-lang-item.rs @@ -15,7 +15,7 @@ extern crate "weak-lang-items" as other; use std::task; fn main() { - let _ = task::try(proc() { + let _ = task::try(move|| { other::foo() }); } |
