]> git.lizzy.rs Git - rust.git/commitdiff
librustc: Make `||` lambdas not infer to `proc`s
authorPatrick Walton <pcwalton@mimiga.net>
Fri, 22 Nov 2013 07:36:52 +0000 (23:36 -0800)
committerPatrick Walton <pcwalton@mimiga.net>
Tue, 26 Nov 2013 16:25:27 +0000 (08:25 -0800)
64 files changed:
doc/tutorial-tasks.md
src/compiletest/compiletest.rs
src/libextra/future.rs
src/libextra/task_pool.rs
src/libextra/test.rs
src/librustc/lib.rs
src/librustc/middle/typeck/check/mod.rs
src/librustpkg/lib.rs
src/librustpkg/package_source.rs
src/librustuv/net.rs
src/libstd/io/net/unix.rs
src/libstd/rt/local.rs
src/libstd/rt/mod.rs
src/libstd/rt/sched.rs
src/libstd/rt/task.rs
src/libstd/rt/test.rs
src/libstd/task/mod.rs
src/libstd/task/spawn.rs
src/test/bench/shootout-pfib.rs
src/test/bench/task-perf-spawnalot.rs
src/test/compile-fail/borrowck-loan-blocks-move-cc.rs
src/test/compile-fail/borrowck-move-by-capture.rs
src/test/compile-fail/borrowck-move-moved-value-into-closure.rs
src/test/compile-fail/kindck-nonsendable-1.rs
src/test/run-fail/unwind-box-fn-unique.rs
src/test/run-pass/block-arg-call-as.rs
src/test/run-pass/borrowck-move-by-capture-ok.rs
src/test/run-pass/cap-clause-move.rs
src/test/run-pass/child-outlives-parent.rs
src/test/run-pass/cleanup-copy-mode.rs
src/test/run-pass/clone-with-exterior.rs
src/test/run-pass/comm.rs
src/test/run-pass/hashmap-memory.rs
src/test/run-pass/issue-3424.rs
src/test/run-pass/issue-3609.rs
src/test/run-pass/ivec-tag.rs
src/test/run-pass/newlambdas-ret-infer.rs
src/test/run-pass/newlambdas-ret-infer2.rs
src/test/run-pass/operator-overloading.rs
src/test/run-pass/sendfn-spawn-with-fn-arg.rs
src/test/run-pass/spawn-fn.rs
src/test/run-pass/spawn-types.rs
src/test/run-pass/spawn.rs
src/test/run-pass/spawn2.rs
src/test/run-pass/spawning-with-debug.rs
src/test/run-pass/swap-overlapping.rs
src/test/run-pass/task-comm-0.rs
src/test/run-pass/task-comm-1.rs
src/test/run-pass/task-comm-10.rs
src/test/run-pass/task-comm-11.rs
src/test/run-pass/task-comm-13.rs
src/test/run-pass/task-comm-14.rs
src/test/run-pass/task-comm-15.rs
src/test/run-pass/task-comm-17.rs
src/test/run-pass/task-comm-3.rs
src/test/run-pass/task-life-0.rs
src/test/run-pass/task-spawn-move-and-copy.rs
src/test/run-pass/tempfile.rs
src/test/run-pass/terminate-in-initializer.rs
src/test/run-pass/threads.rs
src/test/run-pass/uniq-cc-generic.rs
src/test/run-pass/uniq-cc.rs
src/test/run-pass/unique-send-2.rs
src/test/run-pass/unwind-resource.rs

index 3017bc8b7ea01ce139ebcb5996415ef00c57dd8f..41cd796325c32b71d375a3f3027524d424553537 100644 (file)
@@ -76,7 +76,7 @@ fn print_message() { println("I am running in a different task!"); }
 spawn(print_message);
 
 // Print something more profound in a different task using a lambda expression
-spawn( || println("I am also running in a different task!") );
+spawn(proc() println("I am also running in a different task!") );
 
 // The canonical way to spawn is using `do` notation
 do spawn {
@@ -278,7 +278,7 @@ fn fib(n: u64) -> u64 {
     12586269025
 }
 
-let mut delayed_fib = extra::future::Future::spawn (|| fib(50) );
+let mut delayed_fib = extra::future::Future::spawn(proc() fib(50));
 make_a_sandwich();
 println!("fib(50) = {:?}", delayed_fib.get())
 ~~~
index 65f733cf1dec3d9f08c1cf298ffd2d0d5f7d14f6..0f39b29c60a9e80d96b45e767a81ef3289b3c84e 100644 (file)
@@ -333,7 +333,7 @@ pub fn make_test_closure(config: &config, testfile: &Path) -> test::TestFn {
     let config = Cell::new((*config).clone());
     // FIXME (#9639): This needs to handle non-utf8 paths
     let testfile = Cell::new(testfile.as_str().unwrap().to_owned());
-    test::DynTestFn(|| { runtest::run(config.take(), testfile.take()) })
+    test::DynTestFn(proc() { runtest::run(config.take(), testfile.take()) })
 }
 
 pub fn make_metrics_test_closure(config: &config, testfile: &Path) -> test::TestFn {
@@ -341,5 +341,7 @@ pub fn make_metrics_test_closure(config: &config, testfile: &Path) -> test::Test
     let config = Cell::new((*config).clone());
     // FIXME (#9639): This needs to handle non-utf8 paths
     let testfile = Cell::new(testfile.as_str().unwrap().to_owned());
-    test::DynMetricFn(|mm| { runtest::run_metrics(config.take(), testfile.take(), mm) })
+    test::DynMetricFn(proc(mm) {
+        runtest::run_metrics(config.take(), testfile.take(), mm)
+    })
 }
index 8d365c5a5204c4c6f2399069f476afe8e7a67553..5fd720c501801ed1b27ed8f9c0b3f018cf7bb2c9 100644 (file)
@@ -161,7 +161,7 @@ fn test_from_port() {
 
     #[test]
     fn test_from_fn() {
-        let mut f = Future::from_fn(|| ~"brail");
+        let mut f = Future::from_fn(proc() ~"brail");
         assert_eq!(f.get(), ~"brail");
     }
 
@@ -185,14 +185,14 @@ fn test_get_ref_method() {
 
     #[test]
     fn test_spawn() {
-        let mut f = Future::spawn(|| ~"bale");
+        let mut f = Future::spawn(proc() ~"bale");
         assert_eq!(f.get(), ~"bale");
     }
 
     #[test]
     #[should_fail]
     fn test_futurefail() {
-        let mut f = Future::spawn(|| fail!());
+        let mut f = Future::spawn(proc() fail!());
         let _x: ~str = f.get();
     }
 
index d6eed24ef8d44a53c8780393fd37929263d14714..bda6935643f04ad514f111d4d437dde64ed559c8 100644 (file)
@@ -57,7 +57,7 @@ pub fn new(n_tasks: uint,
             let (port, chan) = comm::stream::<Msg<T>>();
             let init_fn = init_fn_factory();
 
-            let task_body: proc() = || {
+            let task_body: proc() = proc() {
                 let local_data = init_fn(i);
                 loop {
                     match port.recv() {
@@ -98,11 +98,11 @@ pub fn execute(&mut self, f: proc(&T)) {
 #[test]
 fn test_task_pool() {
     let f: || -> proc(uint) -> uint = || {
-        let g: proc(uint) -> uint = |i| i;
+        let g: proc(uint) -> uint = proc(i) i;
         g
     };
     let mut pool = TaskPool::new(4, Some(SingleThreaded), f);
     8.times(|| {
-        pool.execute(|i| println!("Hello from thread {}!", *i));
+        pool.execute(proc(i) println!("Hello from thread {}!", *i));
     })
 }
index c94cb196bea6be1ea9901eb1941ac49b64430157..16e9ea8ece48cdcb31233369e9e3e709fec46b88 100644 (file)
@@ -912,7 +912,7 @@ fn run_test_inner(desc: TestDesc,
             return;
         }
         DynTestFn(f) => run_test_inner(desc, monitor_ch, f),
-        StaticTestFn(f) => run_test_inner(desc, monitor_ch, || f())
+        StaticTestFn(f) => run_test_inner(desc, monitor_ch, proc() f())
     }
 }
 
@@ -1209,7 +1209,7 @@ pub fn do_not_run_ignored_tests() {
                 ignore: true,
                 should_fail: false
             },
-            testfn: DynTestFn(|| f()),
+            testfn: DynTestFn(proc() f()),
         };
         let (p, ch) = stream();
         let ch = SharedChan::new(ch);
@@ -1227,7 +1227,7 @@ fn f() { }
                 ignore: true,
                 should_fail: false
             },
-            testfn: DynTestFn(|| f()),
+            testfn: DynTestFn(proc() f()),
         };
         let (p, ch) = stream();
         let ch = SharedChan::new(ch);
@@ -1245,7 +1245,7 @@ fn test_should_fail() {
                 ignore: false,
                 should_fail: true
             },
-            testfn: DynTestFn(|| f()),
+            testfn: DynTestFn(proc() f()),
         };
         let (p, ch) = stream();
         let ch = SharedChan::new(ch);
@@ -1263,7 +1263,7 @@ fn f() { }
                 ignore: false,
                 should_fail: true
             },
-            testfn: DynTestFn(|| f()),
+            testfn: DynTestFn(proc() f()),
         };
         let (p, ch) = stream();
         let ch = SharedChan::new(ch);
@@ -1318,7 +1318,7 @@ fn dummy() {}
                     ignore: true,
                     should_fail: false,
                 },
-                testfn: DynTestFn(|| {}),
+                testfn: DynTestFn(proc() {}),
             },
             TestDescAndFn {
                 desc: TestDesc {
@@ -1326,7 +1326,7 @@ fn dummy() {}
                     ignore: false,
                     should_fail: false
                 },
-                testfn: DynTestFn(|| {}),
+                testfn: DynTestFn(proc() {}),
             },
         ];
         let filtered = filter_tests(&opts, tests);
index b82bc38fbd9645284d79c020130c1f03d875a526..dc1aa1f41cbfb4708a2b238fa804ed8aad14a861 100644 (file)
@@ -345,7 +345,7 @@ pub fn monitor(f: proc(@diagnostic::Emitter)) {
         task_builder.opts.stack_size = Some(STACK_SIZE);
     }
 
-    match task_builder.try(|| {
+    match task_builder.try(proc() {
         let ch = ch_capture.clone();
         // The 'diagnostics emitter'. Every error, warning, etc. should
         // go through this function.
@@ -403,6 +403,6 @@ pub fn main() {
 
 pub fn main_args(args: &[~str]) -> int {
     let owned_args = args.to_owned();
-    monitor(|demitter| run_compiler(owned_args, demitter));
+    monitor(proc(demitter) run_compiler(owned_args, demitter));
     0
 }
index b9d6744e53b193314654f04fe57ac14d119debd0..6bd8226258bd68e377e9e91ea620fcca1e92e3f9 100644 (file)
@@ -2905,8 +2905,13 @@ fn check_struct_enum_variant(fcx: @mut FnCtxt,
         _match::check_match(fcx, expr, discrim, *arms);
       }
       ast::ExprFnBlock(ref decl, ref body) => {
-        check_expr_fn(fcx, expr, None,
-                      decl, body, Vanilla, expected);
+        check_expr_fn(fcx,
+                      expr,
+                      Some(ast::BorrowedSigil),
+                      decl,
+                      body,
+                      Vanilla,
+                      expected);
       }
       ast::ExprProc(ref decl, ref body) => {
         check_expr_fn(fcx,
index f40238364f3f5f8ee67b9a9c57b17b426992064e..2308f314b14a120c23eaa4a2d6beb691ad1493e9 100644 (file)
@@ -474,7 +474,7 @@ fn build(&self, pkg_src: &mut PkgSrc, what_to_build: &WhatToBuild) {
                     let psp = package_script_path.clone();
                     let ws = workspace.clone();
                     let pid = pkgid.clone();
-                    prep.exec(|exec| {
+                    prep.exec(proc(exec) {
                         let mut pscript = PkgScript::parse(subsysroot.clone(),
                                                            psp.clone(),
                                                            &ws,
@@ -636,7 +636,7 @@ fn install_no_build(&self,
             let sub_target_ex = target_exec.clone();
             let sub_target_lib = target_lib.clone();
             let sub_build_inputs = build_inputs.to_owned();
-            prep.exec(|exe_thing| {
+            prep.exec(proc(exe_thing) {
                 let mut outputs = ~[];
                 // Declare all the *inputs* to the declared input too, as inputs
                 for executable in subex.iter() {
index 9d0812efe28d0466efdbb2b706f6b925441f1555..b93199e2c61793343910cc44f46effe0d69ea034 100644 (file)
@@ -412,7 +412,7 @@ fn build_crates(&self,
                 let sub_deps = deps.clone();
                 let inputs = inputs_to_discover.map(|&(ref k, ref p)|
                                                     (k.clone(), p.as_str().unwrap().to_owned()));
-                prep.exec(|exec| {
+                prep.exec(proc(exec) {
                     for &(ref kind, ref p) in inputs.iter() {
                         let pth = Path::new(p.clone());
                         exec.discover_input(*kind, *p, if *kind == ~"file" {
index cad1ac6709f7b29f72639144789858ee38d45b78..8372127c6714649da768296e80019aba503f17db 100644 (file)
@@ -1092,7 +1092,7 @@ fn test_simple_homed_udp_io_bind_then_move_task_then_home_and_close() {
             let handle2 = Cell::new(sched2.make_handle());
             let tasksFriendHandle = Cell::new(sched2.make_handle());
 
-            let on_exit: proc(UnwindResult) = |exit_status| {
+            let on_exit: proc(UnwindResult) = proc(exit_status) {
                 handle1.take().send(Shutdown);
                 handle2.take().send(Shutdown);
                 assert!(exit_status.is_success());
@@ -1106,7 +1106,7 @@ unsafe fn local_io() -> &'static mut IoFactory {
                 })
             }
 
-            let test_function: proc() = || {
+            let test_function: proc() = proc() {
                 let io = unsafe { local_io() };
                 let addr = next_test_ip4();
                 let maybe_socket = io.udp_bind(addr);
index 809473d64c68eecbbea2b0190cc61e6171b9897d..6d2deccaa4cfe738bab906d8d5c17957f040f512 100644 (file)
@@ -214,29 +214,29 @@ fn connect_error() {
 
     #[test]
     fn smoke() {
-        smalltest(|mut server| {
+        smalltest(proc(mut server) {
             let mut buf = [0];
             server.read(buf);
             assert!(buf[0] == 99);
-        }, |mut client| {
+        }, proc(mut client) {
             client.write([99]);
         })
     }
 
     #[test]
     fn read_eof() {
-        smalltest(|mut server| {
+        smalltest(proc(mut server) {
             let mut buf = [0];
             assert!(server.read(buf).is_none());
             assert!(server.read(buf).is_none());
-        }, |_client| {
+        }, proc(_client) {
             // drop the client
         })
     }
 
     #[test]
     fn write_begone() {
-        smalltest(|mut server| {
+        smalltest(proc(mut server) {
             let buf = [0];
             let mut stop = false;
             while !stop{
@@ -248,7 +248,7 @@ fn write_begone() {
                     server.write(buf);
                 })
             }
-        }, |_client| {
+        }, proc(_client) {
             // drop the client
         })
     }
index d5b0e384ca2914273447b1b42cdf8553908c78e3..3e4072e617a4e1656ea31cb7052bf1e0a526d351 100644 (file)
@@ -134,7 +134,7 @@ fn thread_local_task_smoke_test() {
         do run_in_bare_thread {
             local_ptr::init_tls_key();
             let mut sched = ~new_test_uv_sched();
-            let task = ~Task::new_root(&mut sched.stack_pool, None, || {});
+            let task = ~Task::new_root(&mut sched.stack_pool, None, proc(){});
             Local::put(task);
             let task: ~Task = Local::take();
             cleanup_task(task);
@@ -146,11 +146,11 @@ fn thread_local_task_two_instances() {
         do run_in_bare_thread {
             local_ptr::init_tls_key();
             let mut sched = ~new_test_uv_sched();
-            let task = ~Task::new_root(&mut sched.stack_pool, None, || {});
+            let task = ~Task::new_root(&mut sched.stack_pool, None, proc(){});
             Local::put(task);
             let task: ~Task = Local::take();
             cleanup_task(task);
-            let task = ~Task::new_root(&mut sched.stack_pool, None, || {});
+            let task = ~Task::new_root(&mut sched.stack_pool, None, proc(){});
             Local::put(task);
             let task: ~Task = Local::take();
             cleanup_task(task);
@@ -163,7 +163,7 @@ fn borrow_smoke_test() {
         do run_in_bare_thread {
             local_ptr::init_tls_key();
             let mut sched = ~new_test_uv_sched();
-            let task = ~Task::new_root(&mut sched.stack_pool, None, || {});
+            let task = ~Task::new_root(&mut sched.stack_pool, None, proc(){});
             Local::put(task);
 
             unsafe {
@@ -179,7 +179,7 @@ fn borrow_with_return() {
         do run_in_bare_thread {
             local_ptr::init_tls_key();
             let mut sched = ~new_test_uv_sched();
-            let task = ~Task::new_root(&mut sched.stack_pool, None, || {});
+            let task = ~Task::new_root(&mut sched.stack_pool, None, proc(){});
             Local::put(task);
 
             let res = Local::borrow(|_task: &mut Task| {
index ad5c69e9a0c2bf2b6a187481d41e31e20614a187..a8b510cbed7885fe67cd3379af131d3befed2333 100644 (file)
@@ -340,14 +340,14 @@ fn run_(main: proc(), use_main_sched: bool) -> int {
 
     // When the main task exits, after all the tasks in the main
     // task tree, shut down the schedulers and set the exit code.
-    let handles = Cell::new(handles);
-    let on_exit: proc(UnwindResult) = |exit_success| {
+    let handles = handles;
+    let on_exit: proc(UnwindResult) = proc(exit_success) {
         unsafe {
             assert!(!(*exited_already.get()).swap(true, SeqCst),
                     "the runtime already exited");
         }
 
-        let mut handles = handles.take();
+        let mut handles = handles;
         for handle in handles.mut_iter() {
             handle.send(Shutdown);
         }
index ccc786242e6ebb07c69a4be5b88e630da66bfa02..9a48fc51329994773d0a923bfe7c08a8398060ab 100644 (file)
@@ -979,7 +979,7 @@ fn test_home_sched() {
                 assert!(Task::on_appropriate_sched());
             };
 
-            let on_exit: proc(UnwindResult) = |exit_status| {
+            let on_exit: proc(UnwindResult) = proc(exit_status) {
                 rtassert!(exit_status.is_success())
             };
             task.death.on_exit = Some(on_exit);
@@ -1193,12 +1193,15 @@ fn no_missed_messages() {
 
                 let thread = do Thread::start {
                     let mut sched = sched.take();
-                    let bootstrap_task = ~Task::new_root(&mut sched.stack_pool, None, ||());
+                    let bootstrap_task =
+                        ~Task::new_root(&mut sched.stack_pool,
+                                        None,
+                                        proc()());
                     sched.bootstrap(bootstrap_task);
                 };
 
                 let mut stack_pool = StackPool::new();
-                let task = ~Task::new_root(&mut stack_pool, None, ||());
+                let task = ~Task::new_root(&mut stack_pool, None, proc()());
                 handle.send(TaskFromFriend(task));
 
                 handle.send(Shutdown);
index 569d96ae388d3588895fd213680b6c58e4f3b621..68164eb93459a321c6b21b74bf72c479db8786d0 100644 (file)
@@ -425,7 +425,7 @@ pub fn empty() -> Coroutine {
 
     fn build_start_wrapper(start: proc()) -> proc() {
         let start_cell = Cell::new(start);
-        let wrapper: proc() = || {
+        let wrapper: proc() = proc() {
             // First code after swap to this new context. Run our
             // cleanup job.
             unsafe {
@@ -712,10 +712,10 @@ fn tls() {
     #[test]
     fn unwind() {
         do run_in_newsched_task() {
-            let result = spawntask_try(||());
+            let result = spawntask_try(proc()());
             rtdebug!("trying first assert");
             assert!(result.is_ok());
-            let result = spawntask_try(|| fail!());
+            let result = spawntask_try(proc() fail!());
             rtdebug!("trying second assert");
             assert!(result.is_err());
         }
index d87eb56a6500e603cff303040605b33e5adcf299..867d997e98d15a357f31048ae8d59da9402321e5 100644 (file)
@@ -83,10 +83,11 @@ pub fn run_in_uv_task_core(f: proc()) {
     use rt::sched::Shutdown;
 
     let mut sched = ~new_test_uv_sched();
-    let exit_handle = Cell::new(sched.make_handle());
+    let exit_handle = sched.make_handle();
 
-    let on_exit: proc(UnwindResult) = |exit_status| {
-        exit_handle.take().send(Shutdown);
+    let on_exit: proc(UnwindResult) = proc(exit_status: UnwindResult) {
+        let mut exit_handle = exit_handle;
+        exit_handle.send(Shutdown);
         rtassert!(exit_status.is_success());
     };
     let mut task = ~Task::new_root(&mut sched.stack_pool, None, f);
@@ -99,10 +100,11 @@ pub fn run_in_newsched_task_core(f: proc()) {
     use rt::sched::Shutdown;
 
     let mut sched = ~new_test_sched();
-    let exit_handle = Cell::new(sched.make_handle());
+    let exit_handle = sched.make_handle();
 
-    let on_exit: proc(UnwindResult) = |exit_status| {
-        exit_handle.take().send(Shutdown);
+    let on_exit: proc(UnwindResult) = proc(exit_status: UnwindResult) {
+        let mut exit_handle = exit_handle;
+        exit_handle.send(Shutdown);
         rtassert!(exit_status.is_success());
     };
     let mut task = ~Task::new_root(&mut sched.stack_pool, None, f);
@@ -244,10 +246,10 @@ pub fn run_in_mt_newsched_task(f: proc()) {
             scheds.push(sched);
         }
 
-        let handles = Cell::new(handles);
-        let on_exit: proc(UnwindResult) = |exit_status| {
-            let mut handles = handles.take();
+        let handles = handles;  // Work around not being able to capture mut
+        let on_exit: proc(UnwindResult) = proc(exit_status: UnwindResult) {
             // Tell schedulers to exit
+            let mut handles = handles;
             for handle in handles.mut_iter() {
                 handle.send(Shutdown);
             }
@@ -319,8 +321,9 @@ pub fn spawntask_random(f: proc()) {
 pub fn spawntask_try(f: proc()) -> Result<(),()> {
 
     let (port, chan) = oneshot();
-    let chan = Cell::new(chan);
-    let on_exit: proc(UnwindResult) = |exit_status| chan.take().send(exit_status);
+    let on_exit: proc(UnwindResult) = proc(exit_status) {
+        chan.send(exit_status)
+    };
 
     let mut new_task = Task::build_root(None, f);
     new_task.death.on_exit = Some(on_exit);
@@ -348,7 +351,9 @@ pub fn spawntask_thread(f: proc()) -> Thread {
 pub fn with_test_task(blk: proc(~Task) -> ~Task) {
     do run_in_bare_thread {
         let mut sched = ~new_test_sched();
-        let task = blk(~Task::new_root(&mut sched.stack_pool, None, ||{}));
+        let task = blk(~Task::new_root(&mut sched.stack_pool,
+                                       None,
+                                       proc() {}));
         cleanup_task(task);
     }
 }
index 189f1436d42d7beb2098f952464c73c68dcb119e..a587515bb16269211906ea583ddbb89a5804b07b 100644 (file)
@@ -280,13 +280,13 @@ pub fn add_wrapper(&mut self, wrapper: proc(v: proc()) -> proc()) {
         let prev_gen_body = match prev_gen_body {
             Some(gen) => gen,
             None => {
-                let f: proc(proc()) -> proc() = |body| body;
+                let f: proc(proc()) -> proc() = proc(body) body;
                 f
             }
         };
         let prev_gen_body = Cell::new(prev_gen_body);
         let next_gen_body = {
-            let f: proc(proc()) -> proc() = |body| {
+            let f: proc(proc()) -> proc() = proc(body) {
                 let prev_gen_body = prev_gen_body.take();
                 wrapper(prev_gen_body(body))
             };
@@ -551,7 +551,7 @@ fn test_add_wrapper() {
     let ch = Cell::new(ch);
     do b0.add_wrapper |body| {
         let ch = Cell::new(ch.take());
-        let result: proc() = || {
+        let result: proc() = proc() {
             let ch = ch.take();
             body();
             ch.send(());
@@ -765,7 +765,7 @@ fn test_child_doesnt_ref_parent() {
     // valgrind-friendly. try this at home, instead..!)
     static generations: uint = 16;
     fn child_no(x: uint) -> proc() {
-        return || {
+        return proc() {
             if x < generations {
                 let mut t = task();
                 t.unwatched();
@@ -783,7 +783,7 @@ fn test_simple_newsched_spawn() {
     use rt::test::run_in_uv_task;
 
     do run_in_uv_task {
-        spawn(||())
+        spawn(proc()())
     }
 }
 
index 578839d4542ff119eab23f2fe55d1979bd81325a..6c1c28c980559dd8f725bd07e69d52dd32d9dc88 100644 (file)
@@ -180,7 +180,7 @@ pub fn spawn_raw(mut opts: TaskOpts, f: proc()) {
     if opts.notify_chan.is_some() {
         let notify_chan = opts.notify_chan.take_unwrap();
         let notify_chan = Cell::new(notify_chan);
-        let on_exit: proc(UnwindResult) = |task_result| {
+        let on_exit: proc(UnwindResult) = proc(task_result) {
             notify_chan.take().send(task_result)
         };
         task.death.on_exit = Some(on_exit);
index 84426edf3bf55d16502a21afb05ba772492c0bdf..07e1b149932a06755c98e436db5eb76c879f5540 100644 (file)
@@ -46,7 +46,7 @@ fn pfib(c: &SharedChan<int>, n: int) {
 
     let (p, ch) = stream();
     let ch = SharedChan::new(ch);
-    let _t = task::spawn(|| pfib(&ch, n) );
+    let _t = task::spawn(proc() pfib(&ch, n) );
     p.recv()
 }
 
index 80217da60f98ec739e906d7609e26abddc421bed..ef749960eb924acdcc71cec09817ba871b5bc0eb 100644 (file)
@@ -33,5 +33,5 @@ fn main() {
     };
     let n = from_str::<uint>(args[1]).unwrap();
     let mut i = 0u;
-    while i < n { task::spawn(|| f(n) ); i += 1u; }
+    while i < n { task::spawn(proc() f(n) ); i += 1u; }
 }
index 7a226b8b67c0b797c806653de11285f9e1b3daa2..c935c9deeac1ce3de65c51107473cf519dfbbcbb 100644 (file)
@@ -24,7 +24,7 @@ fn box_imm() {
 
     let v = ~3;
     let _w = &v;
-    task::spawn(|| {
+    task::spawn(proc() {
         info!("v={}", *v);
         //~^ ERROR cannot move
     });
index aa50f9ac3fee0df2d85c9e3c20eea2604e1508a5..ac565e9bfd694241ddf24ecb9278945177256b7c 100644 (file)
@@ -3,6 +3,6 @@ pub fn main() {
     // you get two error reports here.
     let bar = ~3;
     let _g = || { //~ ERROR capture of moved value
-        let _h: proc() -> int = || *bar; //~ ERROR capture of moved value
+        let _h: proc() -> int = proc() *bar; //~ ERROR capture of moved value
     };
 }
index b6ad3ed95a4b4745eca0d9c1aa4d2b9ef0f8fc39..6e6a779840e761dbe352bf1159a628bacbde8d04 100644 (file)
@@ -5,6 +5,6 @@ fn call_f(f: proc() -> int) -> int {
 fn main() {
     let t = ~3;
 
-    call_f(|| { *t + 1 });
-    call_f(|| { *t + 1 }); //~ ERROR capture of moved value
+    call_f(proc() { *t + 1 });
+    call_f(proc() { *t + 1 }); //~ ERROR capture of moved value
 }
index 308eb637cd0b98f9de12cd30f0d46ed282ed5589..02c58ba5ee3676ee467f77b2934079b9d724f35e 100644 (file)
@@ -14,7 +14,7 @@ fn foo(_x: @uint) {}
 
 fn main() {
     let x = @3u;
-    let _: proc() = || foo(x); //~ ERROR does not fulfill `Send`
-    let _: proc() = || foo(x); //~ ERROR does not fulfill `Send`
-    let _: proc() = || foo(x); //~ ERROR does not fulfill `Send`
+    let _: proc() = proc() foo(x); //~ ERROR does not fulfill `Send`
+    let _: proc() = proc() foo(x); //~ ERROR does not fulfill `Send`
+    let _: proc() = proc() foo(x); //~ ERROR does not fulfill `Send`
 }
index b28a2a6f1f0323eb822a9096f52b16823e63fc93..190d3f17543b416d399887bb224ed5346a9ff60c 100644 (file)
@@ -18,7 +18,7 @@ fn failfn() {
 
 fn main() {
     let y = ~0;
-    let x: @proc() = @(|| {
+    let x: @proc() = @(proc() {
         error!("{:?}", y.clone());
     });
     failfn();
index 70307e1ff0465424f4b5f99d785c3747d7738445..5d5a5843a646f13b2acf55cc02239a089303c56a 100644 (file)
@@ -19,7 +19,7 @@ fn asBlock(f: || -> uint) -> uint {
 }
 
 pub fn main() {
-   let x = asSendfn(|| 22u);
+   let x = asSendfn(proc() 22u);
    assert_eq!(x, 22u);
    let x = asBlock(|| 22u);
    assert_eq!(x, 22u);
index 2f186cc3fba304503d00fd249f62e18c501bae4e..5e8a92cd1c236cdf86579968c81ecd4391f8780b 100644 (file)
@@ -1,5 +1,5 @@
 pub fn main() {
     let bar = ~3;
-    let h: proc() -> int = || *bar;
+    let h: proc() -> int = proc() *bar;
     assert_eq!(h(), 3);
 }
index c6227fdcc5effe196ac79f056ff4b0b09e85d468..1fa78628d8ae2f67610489704d9936e2966a3af8 100644 (file)
 pub fn main() {
     let x = ~3;
     let y = ptr::to_unsafe_ptr(&(*x)) as uint;
-    let snd_move: proc() -> uint = || ptr::to_unsafe_ptr(&(*x)) as uint;
+    let snd_move: proc() -> uint = proc() ptr::to_unsafe_ptr(&(*x)) as uint;
     assert_eq!(snd_move(), y);
 
     let x = ~4;
     let y = ptr::to_unsafe_ptr(&(*x)) as uint;
-    let lam_move: proc() -> uint = || ptr::to_unsafe_ptr(&(*x)) as uint;
+    let lam_move: proc() -> uint = proc() ptr::to_unsafe_ptr(&(*x)) as uint;
     assert_eq!(lam_move(), y);
 }
index 233a43188468ffc13f310c728c9c2090b092990b..a97b81a4e8b9aa3a4d359ee6d432d083f32bb583 100644 (file)
@@ -15,5 +15,5 @@
 fn child2(_s: ~str) { }
 
 pub fn main() {
-    let _x = task::spawn(|| child2(~"hi"));
+    let _x = task::spawn(proc() child2(~"hi"));
 }
index 3b1ccf50544d15bdbcc6ba6cedc169e6ca5f86fe..738878527bf8e9efc4bda18ee90de6a51bb96337 100644 (file)
@@ -15,7 +15,7 @@
 fn adder(x: @int, y: @int) -> int { return *x + *y; }
 fn failer() -> @int { fail!(); }
 pub fn main() {
-    assert!(task::try(|| {
+    assert!(task::try(proc() {
         adder(@2, failer()); ()
     }).is_err());
 }
index cceb0f353fb3a60cee3e9e23b075883929a3f2de..6fab709543a0aff7c3aa8c5bcbc5bad07e7e5576 100644 (file)
@@ -19,7 +19,7 @@ struct Pair {
 pub fn main() {
     let z = ~Pair { a : 10, b : 12};
 
-    let f: proc() = || {
+    let f: proc() = proc() {
         assert_eq!(z.a, 10);
         assert_eq!(z.b, 12);
     };
index 18c6050095f7b65cb0477505ef1d8208115752e1..5eb3e247d672c2358eedb37923ac8138cdf5da1b 100644 (file)
@@ -12,7 +12,7 @@
 
 pub fn main() {
     let (p, ch) = stream();
-    let _t = task::spawn(|| child(&ch) );
+    let _t = task::spawn(proc() child(&ch));
     let y = p.recv();
     error!("received");
     error!("{:?}", y);
index 1716f882dd86e6fcc3b913fcd895fd401490065b..682ab844a47f1a57cdc9c2bae1f6a57988bced0c 100644 (file)
@@ -34,7 +34,7 @@ fn start_mappers(ctrl: SharedChan<ctrl_proto>, inputs: ~[~str]) {
         for i in inputs.iter() {
             let ctrl = ctrl.clone();
             let i = i.clone();
-            task::spawn(|| map_task(ctrl.clone(), i.clone()) );
+            task::spawn(proc() map_task(ctrl.clone(), i.clone()) );
         }
     }
 
index 0b8fcdfbd84946ac675406176ba16e37c6cff70b..02aaee1d01fdab554555e9f3f3206438a5a2844c 100644 (file)
@@ -21,7 +21,7 @@
 
 fn tester()
 {
-    let loader: rsrc_loader = |_path| {result::Ok(~"more blah")};
+    let loader: rsrc_loader = proc(_path) {result::Ok(~"more blah")};
 
     let path = path::Path::new("blah");
     assert!(loader(&path).is_ok());
index b283ba67d59bd13604d451493e2d5f96e40405e9..ab641e51960d3caafb224d7579aac939c2b79a32 100644 (file)
@@ -14,13 +14,11 @@ enum Msg
 fn foo(name: ~str, samples_chan: Chan<Msg>) {
     do task::spawn
     {
-        let callback: SamplesFn =
-            |buffer|
-            {
-                for i in range(0u, buffer.len()) {
-                    error!("{}: {}", i, buffer[i])
-                }
-            };
+        let callback: SamplesFn = proc(buffer) {
+            for i in range(0u, buffer.len()) {
+                error!("{}: {}", i, buffer[i])
+            }
+        };
         samples_chan.send(GetSamples(name.clone(), callback));
     };
 }
index 4b76f2f3214d4cb0bee1513fe88d38db49fe44a6..c7d5a2f77dae1a9a62f5f93fc7a331a8ec23bb40 100644 (file)
@@ -8,7 +8,7 @@ fn producer(c: &Chan<~[u8]>) {
 
 pub fn main() {
     let (p, ch) = stream::<~[u8]>();
-    let _prod = task::spawn(|| producer(&ch) );
+    let _prod = task::spawn(proc() producer(&ch) );
 
     let _data: ~[u8] = p.recv();
 }
index e5844785a50f96c41729b988cec46ad227fa350f..84d49820239d28e77730bed5b1a80e733b9f8376 100644 (file)
@@ -11,7 +11,7 @@
 // Test that the lambda kind is inferred correctly as a return
 // expression
 
-fn unique() -> proc() { return || (); }
+fn unique() -> proc() { return proc() (); }
 
 pub fn main() {
 }
index ccf1997498be11e9ee9491d6ffd5806086bed5fe..86ad53c0228e8ca6bc31f35c707e3675fb38ba45 100644 (file)
@@ -11,7 +11,7 @@
 // Test that the lambda kind is inferred correctly as a return
 // expression
 
-fn unique() -> proc() { || () }
+fn unique() -> proc() { proc() () }
 
 pub fn main() {
 }
index 5dd8ea96d3738a405a35221774aaad7ecff4c0e5..b27da3912d399e9b398e4381f2514fa2b6ac5c10 100644 (file)
@@ -69,6 +69,6 @@ pub fn main() {
     assert_eq!(q.y, !(p.y));
 
     // Issue #1733
-    let result: proc(int) = |_|();
+    let result: proc(int) = proc(_)();
     result(p[true]);
 }
index 91bc8345845d96a0f258626dd2d9072dadd22924..963f62a20a048f314f9bf02e624c9f5856ec7595 100644 (file)
@@ -19,12 +19,12 @@ fn test05_start(f: proc(int)) {
 
 fn test05() {
     let three = ~3;
-    let fn_to_send: proc(int) = |n| {
+    let fn_to_send: proc(int) = proc(n) {
         error!("{}", *three + n); // will copy x into the closure
         assert_eq!(*three, 3);
     };
     let fn_to_send = Cell::new(fn_to_send);
-    task::spawn(|| {
+    task::spawn(proc() {
         test05_start(fn_to_send.take());
     });
 }
index c56991e541f2aa7f3333094579d55d78a123a6b2..8c9de64687e2738bdcfa93867a41d83046b49553 100644 (file)
@@ -16,9 +16,9 @@ fn x(s: ~str, n: int) {
 }
 
 pub fn main() {
-    task::spawn(|| x(~"hello from first spawned fn", 65) );
-    task::spawn(|| x(~"hello from second spawned fn", 66) );
-    task::spawn(|| x(~"hello from third spawned fn", 67) );
+    task::spawn(proc() x(~"hello from first spawned fn", 65) );
+    task::spawn(proc() x(~"hello from second spawned fn", 66) );
+    task::spawn(proc() x(~"hello from third spawned fn", 67) );
     let mut i: int = 30;
     while i > 0 { i = i - 1; info!("parent sleeping"); task::deschedule(); }
 }
index 111e0df1d6d5c85d74e0cd13c31933f711403053..18459b7a3a31207f9de86155965ffad9099e197f 100644 (file)
@@ -24,5 +24,5 @@ fn iotask(_cx: &ctx, ip: ~str) {
 
 pub fn main() {
     let (_p, ch) = stream::<int>();
-    task::spawn(|| iotask(&ch, ~"localhost") );
+    task::spawn(proc() iotask(&ch, ~"localhost") );
 }
index 7e486a1129d5abdd60bfd06a67211aee92632fc6..d95f032e8143838ce67082137b335f72c9fa6b67 100644 (file)
@@ -13,7 +13,7 @@
 use std::task;
 
 pub fn main() {
-    task::spawn(|| child(10) );
+    task::spawn(proc() child(10) );
 }
 
 fn child(i: int) { error!("{}", i); assert!((i == 10)); }
index 81c7483ffef689d0c23fa0e4182bc978d982e5b2..8530c583b165475e97ab4522d600b2c7d915c25c 100644 (file)
@@ -10,7 +10,7 @@
 
 use std::task;
 
-pub fn main() { task::spawn(|| child((10, 20, 30, 40, 50, 60, 70, 80, 90)) ); }
+pub fn main() { task::spawn(proc() child((10, 20, 30, 40, 50, 60, 70, 80, 90)) ); }
 
 fn child(args: (int, int, int, int, int, int, int, int, int)) {
     let (i1, i2, i3, i4, i5, i6, i7, i8, i9) = args;
index f35c5ef022e414314317070c0c55211ce95b6253..76975d15c1d0c12dd6e141f62f853e8a2c174dca 100644 (file)
@@ -18,5 +18,5 @@
 fn main() {
     let mut t = task::task();
     t.sched_mode(task::SingleThreaded);
-    t.spawn(|| ());
+    t.spawn(proc() ());
 }
index 986a9a8c49c31b85b368e3d3d9d14808062ac005..42f3089a87a193f43f083c017910900b27e2f60c 100644 (file)
@@ -18,7 +18,7 @@ pub fn main() {
             name: DynTestName(~"test"),
             should_fail: false
         },
-        testfn: DynTestFn(|| ()),
+        testfn: DynTestFn(proc() ()),
     };
     do_swap(&mut test);
 }
index 804b03559fa2f56a56b3009c5a4b653ba1fa6ccd..bcdb56a45fdb384df789e6bfe3540cf667fa1108 100644 (file)
@@ -29,7 +29,7 @@ fn test05_start(ch : &Chan<int>) {
 
 fn test05() {
     let (po, ch) = comm::stream();
-    task::spawn(|| test05_start(&ch) );
+    task::spawn(proc() test05_start(&ch) );
     let mut value: int = po.recv();
     error!("{}", value);
     value = po.recv();
index d202bac7089b1997cc2959d433971478301b64b8..830aecfa86cc98a4dbd73cb9abd0d45b7d0baf6d 100644 (file)
@@ -15,6 +15,6 @@
 fn start() { info!("Started / Finished task."); }
 
 fn test00() {
-    task::try(|| start() );
+    task::try(proc() start() );
     info!("Completing.");
 }
index 9195208fb96cac232eff2c78c39ee450de75f574..76948913288779b252a9e0f92921565f16753054 100644 (file)
@@ -31,7 +31,7 @@ fn start(c: &comm::Chan<comm::Chan<~str>>) {
 
 pub fn main() {
     let (p, ch) = comm::stream();
-    let _child = task::spawn(|| start(&ch) );
+    let _child = task::spawn(proc() start(&ch) );
 
     let c = p.recv();
     c.send(~"A");
index 5d1a68e6cc74b2d430f5eec84cc68e7e8d669b8a..e87809b2e98f1f89e37b635141df6cceee53adb3 100644 (file)
@@ -22,6 +22,6 @@ fn start(c: &comm::Chan<comm::Chan<int>>) {
 
 pub fn main() {
     let (p, ch) = comm::stream();
-    let _child = task::spawn(|| start(&ch) );
+    let _child = task::spawn(proc() start(&ch) );
     let _c = p.recv();
 }
index b039f01bf0cd90f0efd714bd24a161203110d230..c8234aefbe577ee7e585004e667740cd52516678 100644 (file)
@@ -23,6 +23,6 @@ fn start(c: &comm::Chan<int>, start: int, number_of_messages: int) {
 pub fn main() {
     info!("Check that we don't deadlock.");
     let (_p, ch) = comm::stream();
-    task::try(|| start(&ch, 0, 10) );
+    task::try(proc() start(&ch, 0, 10) );
     info!("Joined task");
 }
index da9b3703a99f5f6030348ec8c8c6a24779b38a8e..8ef7f85e76827b17250e4806e4eb0663db5597f3 100644 (file)
@@ -22,7 +22,7 @@ pub fn main() {
     while (i > 0) {
         info!("{}", i);
         let ch = ch.clone();
-        task::spawn({let i = i; || child(i, &ch)});
+        task::spawn({let i = i; proc() child(i, &ch)});
         i = i - 1;
     }
 
index 394b7e4865429f17fc7c133431db28dc575bdcaf..66b7b4db5bea7c3a7482729b19aaa3c9f8acbaaa 100644 (file)
@@ -29,6 +29,6 @@ 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 (p, ch) = comm::stream();
-    task::spawn(|| start(&ch, 10));
+    task::spawn(proc() start(&ch, 10));
     p.recv();
 }
index 47e0a710a125c462f8ed1ead7c8af23e93cd3b16..4f9285d30b9e07063008ac447f4eba2efbec1c44 100644 (file)
@@ -20,5 +20,5 @@ fn f() {
 }
 
 pub fn main() {
-    task::spawn(|| f() );
+    task::spawn(proc() f() );
 }
index eb48fa1812d749e33fabc4ec01c974a58dbd14b8..030b70924f69ce8a257fbac4a571432c8332fbae 100644 (file)
@@ -48,7 +48,7 @@ fn test00() {
         results.push(builder.future_result());
         builder.spawn({
             let i = i;
-            || test00_start(&ch, i, number_of_messages)
+            proc() test00_start(&ch, i, number_of_messages)
         });
         i = i + 1;
     }
index b58fe2aad5805026e92c07659f0e94a6441ae185..b60e3f2a4eebab39f77d92e56e6f0a77581d629a 100644 (file)
@@ -13,7 +13,7 @@
 use std::task;
 
 pub fn main() {
-    task::spawn(|| child(~"Hello") );
+    task::spawn(proc() child(~"Hello") );
 }
 
 fn child(_s: ~str) {
index 92697054be33b583cb4205bb6bddde240854a3fb..aeca54c1fb566b17352885da8acde09510937bbf 100644 (file)
@@ -17,7 +17,7 @@ pub fn main() {
     let x = ~1;
     let x_in_parent = ptr::to_unsafe_ptr(&(*x)) as uint;
 
-    task::spawn(|| {
+    task::spawn(proc() {
         let x_in_child = ptr::to_unsafe_ptr(&(*x)) as uint;
         ch.send(x_in_child);
     });
index cee2079251a28cd5658d8ccd9fabbb60757c7d9e..3ab0fe1c058d878e38ae018e31264ab7d74748a0 100644 (file)
@@ -40,7 +40,7 @@ fn test_tempdir() {
 
 fn test_rm_tempdir() {
     let (rd, wr) = stream();
-    let f: proc() = || {
+    let f: proc() = proc() {
         let tmp = TempDir::new("test_rm_tempdir").unwrap();
         wr.send(tmp.path().clone());
         fail!("fail to unwind past `tmp`");
@@ -52,7 +52,7 @@ fn test_rm_tempdir() {
     let tmp = TempDir::new("test_rm_tempdir").unwrap();
     let path = tmp.path().clone();
     let cell = Cell::new(tmp);
-    let f: proc() = || {
+    let f: proc() = proc() {
         let _tmp = cell.take();
         fail!("fail to unwind past `tmp`");
     };
@@ -61,7 +61,7 @@ fn test_rm_tempdir() {
 
     let path;
     {
-        let f: proc() -> TempDir = || {
+        let f: proc() -> TempDir = proc() {
             TempDir::new("test_rm_tempdir").unwrap()
         };
         let tmp = task::try(f).expect("test_rm_tmdir");
index b630884de86b8761821bb4d289ad74b730b4a555..aaedb2d322be10aadedc6b5152889298883bfec9 100644 (file)
 
 fn test_fail() {
     fn f() { let _x: @int = fail!(); }
-    task::try(|| f() );
+    task::try(proc() f() );
 }
 
 fn test_fail_indirect() {
     fn f() -> ! { fail!(); }
     fn g() { let _x: @int = f(); }
-    task::try(|| g() );
+    task::try(proc() g() );
 }
 
 pub fn main() {
index baa2b363a23935856f8684793f9f6bcabb917746..7df9dac219a1f5deb06347ffedbf1ce4f20c6769 100644 (file)
@@ -14,7 +14,7 @@
 
 pub fn main() {
     let mut i = 10;
-    while i > 0 { task::spawn({let i = i; || child(i)}); i = i - 1; }
+    while i > 0 { task::spawn({let i = i; proc() child(i)}); i = i - 1; }
     info!("main thread exiting");
 }
 
index ada3607beaef577d5766b8488b4003355fc04541..ebf3da60db8f3c0a913875f9b8485a74d8e906b6 100644 (file)
@@ -23,7 +23,7 @@ struct Pointy {
 }
 
 fn make_uniq_closure<A:Send>(a: A) -> proc() -> uint {
-    let result: proc() -> uint = || ptr::to_unsafe_ptr(&a) as uint;
+    let result: proc() -> uint = proc() ptr::to_unsafe_ptr(&a) as uint;
     result
 }
 
index fc58374d46d6128cdb2e7ef47bacbac780c5f1ef..20b5761e6bdb660e25188214cfa7ae205875e70d 100644 (file)
@@ -25,7 +25,7 @@ fn empty_pointy() -> @mut Pointy {
     return @mut Pointy {
         a : none,
         c : ~22,
-        d : || {},
+        d : proc() {},
     }
 }
 
index e697af80dcc91df88ec7fdd66abe70d3d4c6c8f4..f44802a9b34cfb1b6d926e555f963d892ce94d17 100644 (file)
@@ -22,7 +22,7 @@ pub fn main() {
     let mut expected = 0u;
     for i in range(0u, n) {
         let ch = ch.clone();
-        task::spawn(|| child(&ch, i) );
+        task::spawn(proc() child(&ch, i) );
         expected += i;
     }
 
index e2460ba6b04885e1baa22cfda6cd1722931d067c..2e01eef1c69616d37dd3f358fb2785f8045126c6 100644 (file)
@@ -42,7 +42,7 @@ fn f(c: SharedChan<bool>) {
 pub fn main() {
     let (p, c) = stream();
     let c = SharedChan::new(c);
-    task::spawn(|| f(c.clone()) );
+    task::spawn(proc() f(c.clone()));
     error!("hiiiiiiiii");
     assert!(p.recv());
 }