Remove empty argument lists from do expressions
This commit is contained in:
committed by
Brian Anderson
parent
718849b202
commit
f2e2a14f36
@@ -172,7 +172,7 @@ mod tests {
|
||||
let p = port();
|
||||
let c = chan(p);
|
||||
|
||||
do task::spawn() || {
|
||||
do task::spawn() {
|
||||
let p = port();
|
||||
c.send(chan(p));
|
||||
|
||||
@@ -198,7 +198,7 @@ mod tests {
|
||||
let p = port();
|
||||
let c = chan(p);
|
||||
|
||||
do task::spawn() || {
|
||||
do task::spawn() {
|
||||
let arc_v = get_arc(arc_c);
|
||||
let v = *get(&arc_v);
|
||||
assert v[2] == 3;
|
||||
|
||||
@@ -98,7 +98,7 @@ class port_ptr<T:send> {
|
||||
let po: *rust_port;
|
||||
new(po: *rust_port) { self.po = po; }
|
||||
drop unsafe {
|
||||
do task::unkillable || {
|
||||
do task::unkillable {
|
||||
// Once the port is detached it's guaranteed not to receive further
|
||||
// messages
|
||||
let yield = 0u;
|
||||
@@ -364,15 +364,15 @@ fn test_select2_rendezvous() {
|
||||
let ch_a = chan(po_a);
|
||||
let ch_b = chan(po_b);
|
||||
|
||||
for iter::repeat(10u) || {
|
||||
do task::spawn || {
|
||||
for iter::repeat(10u) {
|
||||
do task::spawn {
|
||||
for iter::repeat(10u) { task::yield() }
|
||||
send(ch_a, "a");
|
||||
};
|
||||
|
||||
assert select2(po_a, po_b) == either::left("a");
|
||||
|
||||
do task::spawn || {
|
||||
do task::spawn {
|
||||
for iter::repeat(10u) { task::yield() }
|
||||
send(ch_b, "b");
|
||||
};
|
||||
@@ -391,14 +391,14 @@ fn test_select2_stress() {
|
||||
let msgs = 100u;
|
||||
let times = 4u;
|
||||
|
||||
for iter::repeat(times) || {
|
||||
do task::spawn || {
|
||||
for iter::repeat(msgs) || {
|
||||
for iter::repeat(times) {
|
||||
do task::spawn {
|
||||
for iter::repeat(msgs) {
|
||||
send(ch_a, "a")
|
||||
}
|
||||
};
|
||||
do task::spawn || {
|
||||
for iter::repeat(msgs) || {
|
||||
do task::spawn {
|
||||
for iter::repeat(msgs) {
|
||||
send(ch_b, "b")
|
||||
}
|
||||
};
|
||||
@@ -406,7 +406,7 @@ fn test_select2_stress() {
|
||||
|
||||
let mut as = 0;
|
||||
let mut bs = 0;
|
||||
for iter::repeat(msgs * times * 2u) || {
|
||||
for iter::repeat(msgs * times * 2u) {
|
||||
alt check select2(po_a, po_b) {
|
||||
either::left("a") { as += 1 }
|
||||
either::right("b") { bs += 1 }
|
||||
@@ -463,7 +463,7 @@ fn test_chan_peek() {
|
||||
#[test]
|
||||
fn test_listen() {
|
||||
do listen |parent| {
|
||||
do task::spawn || {
|
||||
do task::spawn {
|
||||
parent.send("oatmeal-salad");
|
||||
}
|
||||
assert parent.recv() == "oatmeal-salad";
|
||||
@@ -473,18 +473,18 @@ fn test_listen() {
|
||||
#[test]
|
||||
#[ignore(cfg(windows))]
|
||||
fn test_port_detach_fail() {
|
||||
for iter::repeat(100u) || {
|
||||
for iter::repeat(100u) {
|
||||
let builder = task::builder();
|
||||
task::unsupervise(builder);
|
||||
do task::run(builder) || {
|
||||
do task::run(builder) {
|
||||
let po = port();
|
||||
let ch = po.chan();
|
||||
|
||||
do task::spawn || {
|
||||
do task::spawn {
|
||||
fail;
|
||||
}
|
||||
|
||||
do task::spawn || {
|
||||
do task::spawn {
|
||||
ch.send(());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ fn from_port<A:send>(-port: comm::port<A>) -> future<A> {
|
||||
waiting for the result to be received on the port.
|
||||
"];
|
||||
|
||||
do from_fn || {
|
||||
do from_fn {
|
||||
comm::recv(port)
|
||||
}
|
||||
}
|
||||
@@ -93,7 +93,7 @@ fn spawn<A:send>(+blk: fn~() -> A) -> future<A> {
|
||||
|
||||
let mut po = comm::port();
|
||||
let ch = comm::chan(po);
|
||||
do task::spawn || {
|
||||
do task::spawn {
|
||||
comm::send(ch, blk())
|
||||
};
|
||||
from_port(po)
|
||||
|
||||
@@ -121,7 +121,7 @@ fn test_from_global_chan1() {
|
||||
#[test]
|
||||
fn test_from_global_chan2() {
|
||||
|
||||
for iter::repeat(100u) || {
|
||||
for iter::repeat(100u) {
|
||||
// The global channel
|
||||
let globchan = 0u;
|
||||
let globchanp = ptr::addr_of(globchan);
|
||||
@@ -132,7 +132,7 @@ fn test_from_global_chan2() {
|
||||
// Spawn a bunch of tasks that all want to compete to
|
||||
// create the global channel
|
||||
for uint::range(0u, 10u) |i| {
|
||||
do task::spawn || {
|
||||
do task::spawn {
|
||||
let ch = unsafe {
|
||||
do chan_from_global_ptr(
|
||||
globchanp, task::builder) |po| {
|
||||
@@ -200,7 +200,7 @@ unsafe fn weaken_task(f: fn(comm::port<()>)) {
|
||||
|
||||
#[test]
|
||||
fn test_weaken_task_then_unweaken() {
|
||||
do task::try || {
|
||||
do task::try {
|
||||
unsafe {
|
||||
do weaken_task |_po| {
|
||||
}
|
||||
@@ -212,7 +212,7 @@ fn test_weaken_task_then_unweaken() {
|
||||
fn test_weaken_task_wait() {
|
||||
let builder = task::builder();
|
||||
task::unsupervise(builder);
|
||||
do task::run(builder) || {
|
||||
do task::run(builder) {
|
||||
unsafe {
|
||||
do weaken_task |po| {
|
||||
comm::recv(po);
|
||||
@@ -224,8 +224,8 @@ fn test_weaken_task_wait() {
|
||||
#[test]
|
||||
fn test_weaken_task_stress() {
|
||||
// Create a bunch of weak tasks
|
||||
for iter::repeat(100u) || {
|
||||
do task::spawn || {
|
||||
for iter::repeat(100u) {
|
||||
do task::spawn {
|
||||
unsafe {
|
||||
do weaken_task |_po| {
|
||||
}
|
||||
@@ -233,7 +233,7 @@ fn test_weaken_task_stress() {
|
||||
}
|
||||
let builder = task::builder();
|
||||
task::unsupervise(builder);
|
||||
do task::run(builder) || {
|
||||
do task::run(builder) {
|
||||
unsafe {
|
||||
do weaken_task |po| {
|
||||
// Wait for it to tell us to die
|
||||
@@ -247,7 +247,7 @@ fn test_weaken_task_stress() {
|
||||
#[test]
|
||||
#[ignore(cfg(windows))]
|
||||
fn test_weaken_task_fail() {
|
||||
let res = do task::try || {
|
||||
let res = do task::try {
|
||||
unsafe {
|
||||
do weaken_task |_po| {
|
||||
fail;
|
||||
|
||||
@@ -298,11 +298,11 @@ fn program_output(prog: str, args: ~[str]) ->
|
||||
// clever way to do this.
|
||||
let p = comm::port();
|
||||
let ch = comm::chan(p);
|
||||
do task::spawn_sched(task::single_threaded) || {
|
||||
do task::spawn_sched(task::single_threaded) {
|
||||
let errput = readclose(pipe_err.in);
|
||||
comm::send(ch, (2, errput));
|
||||
};
|
||||
do task::spawn_sched(task::single_threaded) || {
|
||||
do task::spawn_sched(task::single_threaded) {
|
||||
let output = readclose(pipe_out.in);
|
||||
comm::send(ch, (1, output));
|
||||
};
|
||||
|
||||
@@ -296,7 +296,7 @@ fn future_result(builder: builder) -> future::future<task_result> {
|
||||
with get_opts(builder)
|
||||
});
|
||||
|
||||
do future::from_fn || {
|
||||
do future::from_fn {
|
||||
alt comm::recv(po) {
|
||||
exit(_, result) { result }
|
||||
}
|
||||
@@ -343,7 +343,7 @@ fn run_listener<A:send>(-builder: builder,
|
||||
let setup_po = comm::port();
|
||||
let setup_ch = comm::chan(setup_po);
|
||||
|
||||
do run(builder) || {
|
||||
do run(builder) {
|
||||
let po = comm::port();
|
||||
let mut ch = comm::chan(po);
|
||||
comm::send(setup_ch, ch);
|
||||
@@ -440,7 +440,7 @@ fn try<T:send>(+f: fn~() -> T) -> result<T,()> {
|
||||
let mut builder = builder();
|
||||
unsupervise(builder);
|
||||
let result = future_result(builder);
|
||||
do run(builder) || {
|
||||
do run(builder) {
|
||||
comm::send(ch, f());
|
||||
}
|
||||
alt future::get(result) {
|
||||
@@ -800,7 +800,7 @@ extern mod rustrt {
|
||||
fn test_spawn_raw_simple() {
|
||||
let po = comm::port();
|
||||
let ch = comm::chan(po);
|
||||
do spawn_raw(default_task_opts()) || {
|
||||
do spawn_raw(default_task_opts()) {
|
||||
comm::send(ch, ());
|
||||
}
|
||||
comm::recv(po);
|
||||
@@ -813,7 +813,7 @@ fn test_spawn_raw_unsupervise() {
|
||||
supervise: false
|
||||
with default_task_opts()
|
||||
};
|
||||
do spawn_raw(opts) || {
|
||||
do spawn_raw(opts) {
|
||||
fail;
|
||||
}
|
||||
}
|
||||
@@ -830,7 +830,7 @@ fn test_spawn_raw_notify() {
|
||||
notify_chan: some(notify_ch)
|
||||
with default_task_opts()
|
||||
};
|
||||
do spawn_raw(opts) || {
|
||||
do spawn_raw(opts) {
|
||||
comm::send(task_ch, get_task());
|
||||
}
|
||||
let task_ = comm::recv(task_po);
|
||||
@@ -841,7 +841,7 @@ fn test_spawn_raw_notify() {
|
||||
notify_chan: some(notify_ch)
|
||||
with default_task_opts()
|
||||
};
|
||||
do spawn_raw(opts) || {
|
||||
do spawn_raw(opts) {
|
||||
comm::send(task_ch, get_task());
|
||||
fail;
|
||||
}
|
||||
@@ -854,7 +854,7 @@ fn test_run_basic() {
|
||||
let po = comm::port();
|
||||
let ch = comm::chan(po);
|
||||
let buildr = builder();
|
||||
do run(buildr) || {
|
||||
do run(buildr) {
|
||||
comm::send(ch, ());
|
||||
}
|
||||
comm::recv(po);
|
||||
@@ -871,7 +871,7 @@ fn test_add_wrapper() {
|
||||
comm::send(ch, ());
|
||||
}
|
||||
}
|
||||
do run(buildr) || { }
|
||||
do run(buildr) { }
|
||||
comm::recv(po);
|
||||
}
|
||||
|
||||
@@ -880,13 +880,13 @@ fn test_add_wrapper() {
|
||||
fn test_future_result() {
|
||||
let buildr = builder();
|
||||
let result = future_result(buildr);
|
||||
do run(buildr) || { }
|
||||
do run(buildr) { }
|
||||
assert future::get(result) == success;
|
||||
|
||||
let buildr = builder();
|
||||
let result = future_result(buildr);
|
||||
unsupervise(buildr);
|
||||
do run(buildr) || { fail }
|
||||
do run(buildr) { fail }
|
||||
assert future::get(result) == failure;
|
||||
}
|
||||
|
||||
@@ -896,7 +896,7 @@ fn test_future_task() {
|
||||
let ch = comm::chan(po);
|
||||
let buildr = builder();
|
||||
let task1 = future_task(buildr);
|
||||
do run(buildr) || { comm::send(ch, get_task()) }
|
||||
do run(buildr) { comm::send(ch, get_task()) }
|
||||
assert future::get(task1) == comm::recv(po);
|
||||
}
|
||||
|
||||
@@ -919,7 +919,7 @@ fn test_spawn_listiner_bidi() {
|
||||
|
||||
#[test]
|
||||
fn test_try_success() {
|
||||
alt do try || {
|
||||
alt do try {
|
||||
"Success!"
|
||||
} {
|
||||
result::ok("Success!") { }
|
||||
@@ -930,7 +930,7 @@ fn test_try_success() {
|
||||
#[test]
|
||||
#[ignore(cfg(windows))]
|
||||
fn test_try_fail() {
|
||||
alt do try || {
|
||||
alt do try {
|
||||
fail
|
||||
} {
|
||||
result::err(()) { }
|
||||
@@ -942,7 +942,7 @@ fn test_try_fail() {
|
||||
#[should_fail]
|
||||
#[ignore(cfg(windows))]
|
||||
fn test_spawn_sched_no_threads() {
|
||||
do spawn_sched(manual_threads(0u)) || { }
|
||||
do spawn_sched(manual_threads(0u)) { }
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -953,7 +953,7 @@ fn test_spawn_sched() {
|
||||
fn f(i: int, ch: comm::chan<()>) {
|
||||
let parent_sched_id = rustrt::rust_get_sched_id();
|
||||
|
||||
do spawn_sched(single_threaded) || {
|
||||
do spawn_sched(single_threaded) {
|
||||
let child_sched_id = rustrt::rust_get_sched_id();
|
||||
assert parent_sched_id != child_sched_id;
|
||||
|
||||
@@ -974,9 +974,9 @@ fn test_spawn_sched_childs_on_same_sched() {
|
||||
let po = comm::port();
|
||||
let ch = comm::chan(po);
|
||||
|
||||
do spawn_sched(single_threaded) || {
|
||||
do spawn_sched(single_threaded) {
|
||||
let parent_sched_id = rustrt::rust_get_sched_id();
|
||||
do spawn || {
|
||||
do spawn {
|
||||
let child_sched_id = rustrt::rust_get_sched_id();
|
||||
// This should be on the same scheduler
|
||||
assert parent_sched_id == child_sched_id;
|
||||
@@ -1003,7 +1003,7 @@ fn test_spawn_sched_blocking() {
|
||||
|
||||
// Testing that a task in one scheduler can block in foreign code
|
||||
// without affecting other schedulers
|
||||
for iter::repeat(20u) || {
|
||||
for iter::repeat(20u) {
|
||||
|
||||
let start_po = comm::port();
|
||||
let start_ch = comm::chan(start_po);
|
||||
@@ -1012,7 +1012,7 @@ fn test_spawn_sched_blocking() {
|
||||
|
||||
let lock = testrt::rust_dbg_lock_create();
|
||||
|
||||
do spawn_sched(single_threaded) || {
|
||||
do spawn_sched(single_threaded) {
|
||||
testrt::rust_dbg_lock_lock(lock);
|
||||
|
||||
comm::send(start_ch, ());
|
||||
@@ -1039,7 +1039,7 @@ fn test_spawn_sched_blocking() {
|
||||
let setup_ch = comm::chan(setup_po);
|
||||
let parent_po = comm::port();
|
||||
let parent_ch = comm::chan(parent_po);
|
||||
do spawn || {
|
||||
do spawn {
|
||||
let child_po = comm::port();
|
||||
comm::send(setup_ch, comm::chan(child_po));
|
||||
pingpong(child_po, parent_ch);
|
||||
@@ -1064,7 +1064,7 @@ fn avoid_copying_the_body(spawnfn: fn(+fn~())) {
|
||||
let x = ~1;
|
||||
let x_in_parent = ptr::addr_of(*x) as uint;
|
||||
|
||||
do spawnfn || {
|
||||
do spawnfn {
|
||||
let x_in_child = ptr::addr_of(*x) as uint;
|
||||
comm::send(ch, x_in_child);
|
||||
}
|
||||
@@ -1091,7 +1091,7 @@ fn test_avoid_copying_the_body_spawn_listener() {
|
||||
fn test_avoid_copying_the_body_run() {
|
||||
do avoid_copying_the_body |f| {
|
||||
let buildr = builder();
|
||||
do run(buildr) || {
|
||||
do run(buildr) {
|
||||
f();
|
||||
}
|
||||
}
|
||||
@@ -1110,7 +1110,7 @@ fn test_avoid_copying_the_body_run_listener() {
|
||||
#[test]
|
||||
fn test_avoid_copying_the_body_try() {
|
||||
do avoid_copying_the_body |f| {
|
||||
do try || {
|
||||
do try {
|
||||
f()
|
||||
};
|
||||
}
|
||||
@@ -1121,7 +1121,7 @@ fn test_avoid_copying_the_body_future_task() {
|
||||
do avoid_copying_the_body |f| {
|
||||
let buildr = builder();
|
||||
future_task(buildr);
|
||||
do run(buildr) || {
|
||||
do run(buildr) {
|
||||
f();
|
||||
}
|
||||
}
|
||||
@@ -1132,7 +1132,7 @@ fn test_avoid_copying_the_body_unsupervise() {
|
||||
do avoid_copying_the_body |f| {
|
||||
let buildr = builder();
|
||||
unsupervise(buildr);
|
||||
do run(buildr) || {
|
||||
do run(buildr) {
|
||||
f();
|
||||
}
|
||||
}
|
||||
@@ -1152,7 +1152,7 @@ fn test_osmain() {
|
||||
|
||||
let po = comm::port();
|
||||
let ch = comm::chan(po);
|
||||
do run(buildr) || {
|
||||
do run(buildr) {
|
||||
comm::send(ch, ());
|
||||
}
|
||||
comm::recv(po);
|
||||
@@ -1167,12 +1167,12 @@ fn test_unkillable() {
|
||||
let ch = po.chan();
|
||||
|
||||
// We want to do this after failing
|
||||
do spawn || {
|
||||
do spawn {
|
||||
for iter::repeat(10u) { yield() }
|
||||
ch.send(());
|
||||
}
|
||||
|
||||
do spawn || {
|
||||
do spawn {
|
||||
yield();
|
||||
// We want to fail after the unkillable task
|
||||
// blocks on recv
|
||||
@@ -1180,7 +1180,7 @@ fn test_unkillable() {
|
||||
}
|
||||
|
||||
unsafe {
|
||||
do unkillable || {
|
||||
do unkillable {
|
||||
let p = ~0;
|
||||
let pp: *uint = unsafe::transmute(p);
|
||||
|
||||
@@ -1199,7 +1199,7 @@ fn test_unkillable() {
|
||||
fn test_tls_multitask() unsafe {
|
||||
fn my_key(+_x: @str) { }
|
||||
local_data_set(my_key, @"parent data");
|
||||
do task::spawn || {
|
||||
do task::spawn {
|
||||
assert local_data_get(my_key) == none; // TLS shouldn't carry over.
|
||||
local_data_set(my_key, @"child data");
|
||||
assert *(local_data_get(my_key).get()) == "child data";
|
||||
@@ -1255,7 +1255,7 @@ fn test_tls_crust_automorestack_memorial_bug() unsafe {
|
||||
// something within a rust stack segment. Then a subsequent upcall (esp.
|
||||
// for logging, think vsnprintf) would run on a stack smaller than 1 MB.
|
||||
fn my_key(+_x: @str) { }
|
||||
do task::spawn || {
|
||||
do task::spawn {
|
||||
unsafe { local_data_set(my_key, @"hax"); }
|
||||
}
|
||||
}
|
||||
@@ -1265,7 +1265,7 @@ fn test_tls_multiple_types() unsafe {
|
||||
fn str_key(+_x: @str) { }
|
||||
fn box_key(+_x: @@()) { }
|
||||
fn int_key(+_x: @int) { }
|
||||
do task::spawn || {
|
||||
do task::spawn {
|
||||
local_data_set(str_key, @"string data");
|
||||
local_data_set(box_key, @@());
|
||||
local_data_set(int_key, @42);
|
||||
@@ -1277,7 +1277,7 @@ fn test_tls_overwrite_multiple_types() unsafe {
|
||||
fn str_key(+_x: @str) { }
|
||||
fn box_key(+_x: @@()) { }
|
||||
fn int_key(+_x: @int) { }
|
||||
do task::spawn || {
|
||||
do task::spawn {
|
||||
local_data_set(str_key, @"string data");
|
||||
local_data_set(int_key, @42);
|
||||
// This could cause a segfault if overwriting-destruction is done with
|
||||
@@ -1295,7 +1295,7 @@ fn test_tls_cleanup_on_failure() unsafe {
|
||||
fn int_key(+_x: @int) { }
|
||||
local_data_set(str_key, @"parent data");
|
||||
local_data_set(box_key, @@());
|
||||
do task::spawn || { // spawn_linked
|
||||
do task::spawn { // spawn_linked
|
||||
local_data_set(str_key, @"string data");
|
||||
local_data_set(box_key, @@());
|
||||
local_data_set(int_key, @42);
|
||||
|
||||
Reference in New Issue
Block a user