提交 f2e2a14f 编写于 作者: B Ben Striegel 提交者: Brian Anderson

Remove empty argument lists from do expressions

上级 718849b2
......@@ -1638,7 +1638,7 @@ task in a _failing state_.
~~~~
# let buildr = task::builder();
# task::unsupervise(buildr);
# do task::run(buildr) || {
# do task::run(buildr) {
(~[1, 2, 3, 4])[0];
(~[mut 'x', 'y'])[1] = 'z';
......@@ -3365,7 +3365,7 @@ An example of a `spawn` call:
let po = comm::port();
let ch = comm::chan(po);
do task::spawn || {
do task::spawn {
// let task run, do other things
// ...
comm::send(ch, true);
......
......@@ -2473,7 +2473,7 @@ module `task`. Let's begin with the simplest one, `task::spawn()`:
~~~~
let some_value = 22;
do task::spawn || {
do task::spawn {
io::println("This executes in the child task.");
io::println(#fmt("%d", some_value));
}
......@@ -2499,7 +2499,7 @@ in parallel. We might write something like:
# fn some_other_expensive_computation() {}
let port = comm::port::<int>();
let chan = comm::chan::<int>(port);
do task::spawn || {
do task::spawn {
let result = some_expensive_computation();
comm::send(chan, result);
}
......@@ -2530,7 +2530,7 @@ The next statement actually spawns the child:
# fn some_expensive_computation() -> int { 42 }
# let port = comm::port::<int>();
# let chan = comm::chan::<int>(port);
do task::spawn || {
do task::spawn {
let result = some_expensive_computation();
comm::send(chan, result);
}
......
......@@ -60,11 +60,11 @@ fn run(lib_path: str,
writeclose(pipe_in.out, input);
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));
}
......
......@@ -172,7 +172,7 @@ fn manually_share_arc() {
let p = port();
let c = chan(p);
do task::spawn() || {
do task::spawn() {
let p = port();
c.send(chan(p));
......@@ -198,7 +198,7 @@ fn auto_share_arc() {
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 @@ fn listen<T: send, U>(f: fn(chan<T>) -> U) -> U {
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 @@ fn rust_task_config_notify(
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 pingpong(po: comm::port<int>, ch: comm::chan<int>) {
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 box_key(+_x: @@()) { }
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);
......
......@@ -360,7 +360,7 @@ fn emit_enum_variant(_v_name: str, v_id: uint, _cnt: uint, f: fn()) {
fn emit_enum_variant_arg(_idx: uint, f: fn()) { f() }
fn emit_vec(len: uint, f: fn()) {
do self.wr_tag(es_vec as uint) || {
do self.wr_tag(es_vec as uint) {
self._emit_tagged_uint(es_vec_len, len);
f()
}
......@@ -487,7 +487,7 @@ fn read_enum_variant<T:copy>(f: fn(uint) -> T) -> T {
#debug["read_enum_variant()"];
let idx = self._next_uint(es_enum_vid);
#debug[" idx=%u", idx];
do self.push_doc(self.next_doc(es_enum_body)) || {
do self.push_doc(self.next_doc(es_enum_body)) {
f(idx)
}
}
......@@ -499,7 +499,7 @@ fn read_enum_variant_arg<T:copy>(idx: uint, f: fn() -> T) -> T {
fn read_vec<T:copy>(f: fn(uint) -> T) -> T {
#debug["read_vec()"];
do self.push_doc(self.next_doc(es_vec)) || {
do self.push_doc(self.next_doc(es_vec)) {
let len = self._next_uint(es_vec_len);
#debug[" len=%u", len];
f(len)
......@@ -554,13 +554,13 @@ fn serialize_1<S: serialization::serializer>(s: S, v: int) {
}
fn serialize_0<S: serialization::serializer>(s: S, v: option<int>) {
do s.emit_enum("core::option::t") || {
do s.emit_enum("core::option::t") {
alt v {
none {
s.emit_enum_variant("core::option::none", 0u, 0u, || { } );
}
some(v0) {
do s.emit_enum_variant("core::option::some", 1u, 1u) || {
do s.emit_enum_variant("core::option::some", 1u, 1u) {
s.emit_enum_variant_arg(0u, || serialize_1(s, v0));
}
}
......@@ -573,12 +573,12 @@ fn deserialize_1<S: serialization::deserializer>(s: S) -> int {
}
fn deserialize_0<S: serialization::deserializer>(s: S) -> option<int> {
do s.read_enum("core::option::t") || {
do s.read_enum("core::option::t") {
do s.read_enum_variant |i| {
alt check i {
0u { none }
1u {
let v0 = do s.read_enum_variant_arg(0u) || {
let v0 = do s.read_enum_variant_arg(0u) {
deserialize_1(s)
};
some(v0)
......
......@@ -305,7 +305,7 @@ fn write(sock: tcp_socket, raw_write_data: ~[u8])
fn write_future(sock: tcp_socket, raw_write_data: ~[u8])
-> future::future<result::result<(), tcp_err_data>> unsafe {
let socket_data_ptr = ptr::addr_of(*(sock.socket_data));
do future_spawn || {
do future_spawn {
let data_copy = copy(raw_write_data);
write_common_impl(socket_data_ptr, data_copy)
}
......@@ -397,7 +397,7 @@ fn read(sock: tcp_socket, timeout_msecs: uint)
fn read_future(sock: tcp_socket, timeout_msecs: uint)
-> future::future<result::result<~[u8],tcp_err_data>> {
let socket_data = ptr::addr_of(*(sock.socket_data));
do future_spawn || {
do future_spawn {
read_common_impl(socket_data, timeout_msecs)
}
}
......@@ -1310,7 +1310,7 @@ fn impl_gl_tcp_ipv4_server_and_client() {
let cont_po = comm::port::<()>();
let cont_ch = comm::chan(cont_po);
// server
do task::spawn_sched(task::manual_threads(1u)) || {
do task::spawn_sched(task::manual_threads(1u)) {
let actual_req = do comm::listen |server_ch| {
run_tcp_test_server(
server_ip,
......@@ -1379,7 +1379,7 @@ fn impl_gl_tcp_ipv4_server_address_in_use() {
let cont_po = comm::port::<()>();
let cont_ch = comm::chan(cont_po);
// server
do task::spawn_sched(task::manual_threads(1u)) || {
do task::spawn_sched(task::manual_threads(1u)) {
let actual_req = do comm::listen |server_ch| {
run_tcp_test_server(
server_ip,
......@@ -1449,7 +1449,7 @@ fn impl_gl_tcp_ipv4_server_client_reader_writer() {
let cont_po = comm::port::<()>();
let cont_ch = comm::chan(cont_po);
// server
do task::spawn_sched(task::manual_threads(1u)) || {
do task::spawn_sched(task::manual_threads(1u)) {
let actual_req = do comm::listen |server_ch| {
run_tcp_test_server(
server_ip,
......@@ -1519,7 +1519,7 @@ fn run_tcp_test_server(server_ip: str, server_port: uint, resp: str,
|new_conn, kill_ch| {
log(debug, "SERVER: new connection!");
do comm::listen |cont_ch| {
do task::spawn_sched(task::manual_threads(1u)) || {
do task::spawn_sched(task::manual_threads(1u)) {
log(debug, "SERVER: starting worker for new req");
let accept_result = accept(new_conn);
......
......@@ -84,9 +84,9 @@
// In some cases, these should eventually be coded as traits.
fn emit_from_vec<S: serializer, T>(s: S, v: ~[T], f: fn(T)) {
do s.emit_vec(vec::len(v)) || {
do s.emit_vec(vec::len(v)) {
do vec::iteri(v) |i,e| {
do s.emit_vec_elt(i) || {
do s.emit_vec_elt(i) {
f(e)
}
}
......@@ -234,16 +234,16 @@ fn deserialize_bool<D: deserializer>(d: D) -> bool {
}
fn serialize_option<S: serializer,T>(s: S, v: option<T>, st: fn(T)) {
do s.emit_enum("option") || {
do s.emit_enum("option") {
alt v {
none {
do s.emit_enum_variant("none", 0u, 0u) || {
do s.emit_enum_variant("none", 0u, 0u) {
}
}
some(v) {
do s.emit_enum_variant("some", 1u, 1u) || {
do s.emit_enum_variant_arg(0u) || {
do s.emit_enum_variant("some", 1u, 1u) {
do s.emit_enum_variant_arg(0u) {
st(v)
}
}
......@@ -254,7 +254,7 @@ fn serialize_option<S: serializer,T>(s: S, v: option<T>, st: fn(T)) {
fn deserialize_option<D: deserializer,T: copy>(d: D, st: fn() -> T)
-> option<T> {
do d.read_enum("option") || {
do d.read_enum("option") {
do d.read_enum_variant |i| {
alt check i {
0u { // none
......
......@@ -390,7 +390,7 @@ fn run_test(+test: test_desc, monitor_ch: comm::chan<monitor_msg>) {
ret;
}
do task::spawn || {
do task::spawn {
let testfn = copy test.fn;
let mut builder = task::builder();
let result_future = task::future_result(builder);
......
......@@ -151,7 +151,7 @@ fn test_gl_timer_simple_sleep_test() {
#[test]
fn test_gl_timer_sleep_stress1() {
let hl_loop = uv::global_loop::get();
for iter::repeat(200u) || {
for iter::repeat(200u) {
sleep(hl_loop, 1u);
}
}
......@@ -171,14 +171,14 @@ fn test_gl_timer_sleep_stress2() {
};
for iter::repeat(repeat) || {
for iter::repeat(repeat) {
for spec.each |spec| {
let (times, maxms) = spec;
do task::spawn || {
do task::spawn {
import rand::*;
let rng = rng();
for iter::repeat(times) || {
for iter::repeat(times) {
sleep(hl_loop, rng.next() as uint % maxms);
}
comm::send(ch, ());
......@@ -186,7 +186,7 @@ fn test_gl_timer_sleep_stress2() {
}
}
for iter::repeat(repeat * spec.len()) || {
for iter::repeat(repeat * spec.len()) {
comm::recv(po)
}
}
......@@ -204,14 +204,14 @@ fn test_gl_timer_recv_timeout_before_time_passes() {
let mut failures = 0;
let hl_loop = uv::global_loop::get();
for iter::repeat(times as uint) || {
for iter::repeat(times as uint) {
task::yield();
let expected = rand::rng().gen_str(16u);
let test_po = comm::port::<str>();
let test_ch = comm::chan(test_po);
do task::spawn() || {
do task::spawn() {
delayed_send(hl_loop, 1u, test_ch, expected);
};
......@@ -231,12 +231,12 @@ fn test_gl_timer_recv_timeout_after_time_passes() {
let mut failures = 0;
let hl_loop = uv::global_loop::get();
for iter::repeat(times as uint) || {
for iter::repeat(times as uint) {
let expected = rand::rng().gen_str(16u);
let test_po = comm::port::<str>();
let test_ch = comm::chan(test_po);
do task::spawn() || {
do task::spawn() {
delayed_send(hl_loop, 1000u, test_ch, expected);
};
......
......@@ -191,16 +191,16 @@ fn test_stress_gl_uv_global_loop_high_level_global_timer() unsafe {
let exit_po = comm::port::<()>();
let exit_ch = comm::chan(exit_po);
let cycles = 5000u;
for iter::repeat(cycles) || {
for iter::repeat(cycles) {
task::spawn_sched(task::manual_threads(1u), || {
impl_uv_hl_simple_timer(hl_loop);
comm::send(exit_ch, ());
});
};
for iter::repeat(cycles) || {
for iter::repeat(cycles) {
comm::recv(exit_po);
};
log(debug, "test_stress_gl_uv_global_loop_high_level_global_timer"+
" exiting sucessfully!");
}
}
\ No newline at end of file
}
......@@ -41,7 +41,7 @@ fn spawn_iotask(-builder: task::builder) -> iotask {
do listen |iotask_ch| {
do run(copy(builder)) || {
do run(copy(builder)) {
#debug("entering libuv task");
run_loop(iotask_ch);
#debug("libuv task exiting");
......@@ -224,7 +224,7 @@ fn impl_uv_iotask_async(iotask: iotask) unsafe {
unsafe fn spawn_test_loop(exit_ch: comm::chan<()>) -> iotask {
let iotask_port = comm::port::<iotask>();
let iotask_ch = comm::chan(iotask_port);
do task::spawn_sched(task::manual_threads(1u)) || {
do task::spawn_sched(task::manual_threads(1u)) {
run_loop(iotask_ch);
exit_ch.send(());
};
......@@ -255,13 +255,13 @@ fn test_uv_iotask_async() unsafe {
// called, at least.
let work_exit_po = comm::port::<()>();
let work_exit_ch = comm::chan(work_exit_po);
for iter::repeat(7u) || {
do task::spawn_sched(task::manual_threads(1u)) || {
for iter::repeat(7u) {
do task::spawn_sched(task::manual_threads(1u)) {
impl_uv_iotask_async(iotask);
comm::send(work_exit_ch, ());
};
};
for iter::repeat(7u) || {
for iter::repeat(7u) {
comm::recv(work_exit_po);
};
log(debug, "sending teardown_loop msg..");
......
......@@ -1473,7 +1473,7 @@ fn impl_uv_tcp_server_and_request() unsafe {
let continue_chan = comm::chan::<bool>(continue_port);
let continue_chan_ptr = ptr::addr_of(continue_chan);
do task::spawn_sched(task::manual_threads(1u)) || {
do task::spawn_sched(task::manual_threads(1u)) {
impl_uv_tcp_server(bind_ip, port,
kill_server_msg,
server_resp_msg,
......@@ -1486,7 +1486,7 @@ fn impl_uv_tcp_server_and_request() unsafe {
comm::recv(continue_port);
log(debug, "received on continue port, set up tcp client");
do task::spawn_sched(task::manual_threads(1u)) || {
do task::spawn_sched(task::manual_threads(1u)) {
impl_uv_tcp_request(request_ip, port,
kill_server_msg,
ptr::addr_of(client_chan));
......
......@@ -211,7 +211,7 @@ enum monitor_msg {
let p = comm::port();
let ch = comm::chan(p);
alt do task::try || {
alt do task::try {
// The 'diagnostics emitter'. Every error, warning, etc. should
// go through this function.
......
......@@ -87,20 +87,20 @@ fn encode_name_and_def_id(ebml_w: ebml::writer, nm: ident,
}
fn encode_region_param(ebml_w: ebml::writer, rp: region_param) {
do ebml_w.wr_tag(tag_region_param) || {
do ebml_w.wr_tag(tag_region_param) {
serialize_region_param(ebml_w, rp)
}
}
fn encode_named_def_id(ebml_w: ebml::writer, name: ident, id: def_id) {
do ebml_w.wr_tag(tag_paths_data_item) || {
do ebml_w.wr_tag(tag_paths_data_item) {
encode_name(ebml_w, name);
encode_def_id(ebml_w, id);
}
}
fn encode_mutability(ebml_w: ebml::writer, mt: class_mutability) {
do ebml_w.wr_tag(tag_class_mut) || {
do ebml_w.wr_tag(tag_class_mut) {
ebml_w.writer.write(&[alt mt { class_immutable { 'i' }
class_mutable { 'm' } } as u8]);
}
......@@ -112,7 +112,7 @@ fn encode_enum_variant_paths(ebml_w: ebml::writer, variants: ~[variant],
path: ~[ident], &index: ~[entry<str>]) {
for variants.each |variant| {
add_to_index(ebml_w, path, index, variant.node.name);
do ebml_w.wr_tag(tag_paths_data_item) || {
do ebml_w.wr_tag(tag_paths_data_item) {
encode_name(ebml_w, variant.node.name);
encode_def_id(ebml_w, local_def(variant.node.id));
}
......@@ -170,7 +170,7 @@ fn encode_module_item_paths(ebml_w: ebml::writer, ecx: @encode_ctxt,
encode_named_def_id(ebml_w, it.ident, local_def(it.id));
}
item_mod(_mod) {
do ebml_w.wr_tag(tag_paths_data_mod) || {
do ebml_w.wr_tag(tag_paths_data_mod) {
encode_name_and_def_id(ebml_w, it.ident, it.id);
encode_module_item_paths(ebml_w, ecx, _mod,
vec::append_one(path, it.ident),
......@@ -178,7 +178,7 @@ fn encode_module_item_paths(ebml_w: ebml::writer, ecx: @encode_ctxt,
}
}
item_foreign_mod(nmod) {
do ebml_w.wr_tag(tag_paths_data_mod) || {
do ebml_w.wr_tag(tag_paths_data_mod) {
encode_name_and_def_id(ebml_w, it.ident, it.id);
encode_foreign_module_item_paths(
ebml_w, nmod,
......@@ -186,15 +186,15 @@ fn encode_module_item_paths(ebml_w: ebml::writer, ecx: @encode_ctxt,
}
}
item_ty(_, tps, _) {
do ebml_w.wr_tag(tag_paths_data_item) || {
do ebml_w.wr_tag(tag_paths_data_item) {
encode_name_and_def_id(ebml_w, it.ident, it.id);
}
}
item_class(_, _, items, ctor, m_dtor, _) {
do ebml_w.wr_tag(tag_paths_data_item) || {
do ebml_w.wr_tag(tag_paths_data_item) {
encode_name_and_def_id(ebml_w, it.ident, it.id);
}
do ebml_w.wr_tag(tag_paths) || {
do ebml_w.wr_tag(tag_paths) {
// We add the same ident twice: for the
// class and for its ctor
add_to_index(ebml_w, path, index, it.ident);
......@@ -206,13 +206,13 @@ fn encode_module_item_paths(ebml_w: ebml::writer, ecx: @encode_ctxt,
}
}
item_enum(variants, _, _) {
do ebml_w.wr_tag(tag_paths_data_item) || {
do ebml_w.wr_tag(tag_paths_data_item) {
encode_name_and_def_id(ebml_w, it.ident, it.id);
}
encode_enum_variant_paths(ebml_w, variants, path, index);
}
item_iface(*) {
do ebml_w.wr_tag(tag_paths_data_item) || {
do ebml_w.wr_tag(tag_paths_data_item) {
encode_name_and_def_id(ebml_w, it.ident, it.id);
}
}
......@@ -372,7 +372,7 @@ fn encode_path_elt(ebml_w: ebml::writer, elt: ast_map::path_elt) {
ebml_w.wr_tagged_str(tag, *name);
}
do ebml_w.wr_tag(tag_path) || {
do ebml_w.wr_tag(tag_path) {
ebml_w.wr_tagged_u32(tag_path_len, (vec::len(path) + 1u) as u32);
do vec::iter(path) |pe| { encode_path_elt(ebml_w, pe); }
encode_path_elt(ebml_w, name);
......@@ -606,7 +606,7 @@ fn add_to_index_(item: @item, ebml_w: ebml::writer,
}
item_enum(variants, tps, rp) {
add_to_index();
do ebml_w.wr_tag(tag_items_data_item) || {
do ebml_w.wr_tag(tag_items_data_item) {
encode_def_id(ebml_w, local_def(item.id));
encode_family(ebml_w, 't');
encode_type_param_bounds(ebml_w, ecx, tps);
......@@ -656,7 +656,7 @@ fn add_to_index_(item: @item, ebml_w: ebml::writer,
/* Encode the dtor */
/* Encode id for dtor */
do option::iter(m_dtor) |dtor| {
do ebml_w.wr_tag(tag_item_dtor) || {
do ebml_w.wr_tag(tag_item_dtor) {
encode_def_id(ebml_w, local_def(dtor.node.id));
}
};
......
......@@ -87,7 +87,7 @@ fn encode_inlined_item(ecx: @e::encode_ctxt,
ebml_w.writer.tell()];
let id_range = ast_util::compute_id_range_for_inlined_item(ii);
do ebml_w.wr_tag(c::tag_ast as uint) || {
do ebml_w.wr_tag(c::tag_ast as uint) {
ast_util::serialize_id_range(ebml_w, id_range);
encode_ast(ebml_w, simplify_ast(ii));
encode_side_tables_for_ii(ecx, maps, ebml_w, ii);
......@@ -210,7 +210,7 @@ fn read_def_id(xcx: extended_decode_ctxt) -> ast::def_id {
// but eventually we should add entries to the local codemap as required.
fn encode_ast(ebml_w: ebml::writer, item: ast::inlined_item) {
do ebml_w.wr_tag(c::tag_tree as uint) || {
do ebml_w.wr_tag(c::tag_tree as uint) {
ast::serialize_inlined_item(ebml_w, item)
}
}
......@@ -433,37 +433,37 @@ fn encode_vtable_res(ecx: @e::encode_ctxt,
fn encode_vtable_origin(ecx: @e::encode_ctxt,
ebml_w: ebml::writer,
vtable_origin: typeck::vtable_origin) {
do ebml_w.emit_enum("vtable_origin") || {
do ebml_w.emit_enum("vtable_origin") {
alt vtable_origin {
typeck::vtable_static(def_id, tys, vtable_res) {
do ebml_w.emit_enum_variant("vtable_static", 0u, 3u) || {
do ebml_w.emit_enum_variant_arg(0u) || {
do ebml_w.emit_enum_variant("vtable_static", 0u, 3u) {
do ebml_w.emit_enum_variant_arg(0u) {
ebml_w.emit_def_id(def_id)
}
do ebml_w.emit_enum_variant_arg(1u) || {
do ebml_w.emit_enum_variant_arg(1u) {
ebml_w.emit_tys(ecx, tys);
}
do ebml_w.emit_enum_variant_arg(2u) || {
do ebml_w.emit_enum_variant_arg(2u) {
encode_vtable_res(ecx, ebml_w, vtable_res);
}
}
}
typeck::vtable_param(pn, bn) {
do ebml_w.emit_enum_variant("vtable_param", 1u, 2u) || {
do ebml_w.emit_enum_variant_arg(0u) || {
do ebml_w.emit_enum_variant("vtable_param", 1u, 2u) {
do ebml_w.emit_enum_variant_arg(0u) {
ebml_w.emit_uint(pn);
}
do ebml_w.emit_enum_variant_arg(1u) || {
do ebml_w.emit_enum_variant_arg(1u) {
ebml_w.emit_uint(bn);
}
}
}
typeck::vtable_iface(def_id, tys) {
do ebml_w.emit_enum_variant("vtable_iface", 1u, 3u) || {
do ebml_w.emit_enum_variant_arg(0u) || {
do ebml_w.emit_enum_variant("vtable_iface", 1u, 3u) {
do ebml_w.emit_enum_variant_arg(0u) {
ebml_w.emit_def_id(def_id)
}
do ebml_w.emit_enum_variant_arg(1u) || {
do ebml_w.emit_enum_variant_arg(1u) {
ebml_w.emit_tys(ecx, tys);
}
}
......@@ -480,38 +480,38 @@ fn read_vtable_res(xcx: extended_decode_ctxt) -> typeck::vtable_res {
fn read_vtable_origin(xcx: extended_decode_ctxt)
-> typeck::vtable_origin {
do self.read_enum("vtable_origin") || {
do self.read_enum("vtable_origin") {
do self.read_enum_variant |i| {
alt check i {
0u {
typeck::vtable_static(
do self.read_enum_variant_arg(0u) || {
do self.read_enum_variant_arg(0u) {
self.read_def_id(xcx)
},
do self.read_enum_variant_arg(1u) || {
do self.read_enum_variant_arg(1u) {
self.read_tys(xcx)
},
do self.read_enum_variant_arg(2u) || {
do self.read_enum_variant_arg(2u) {
self.read_vtable_res(xcx)
}
)
}
1u {
typeck::vtable_param(
do self.read_enum_variant_arg(0u) || {
do self.read_enum_variant_arg(0u) {
self.read_uint()
},
do self.read_enum_variant_arg(1u) || {
do self.read_enum_variant_arg(1u) {
self.read_uint()
}
)
}
2u {
typeck::vtable_iface(
do self.read_enum_variant_arg(0u) || {
do self.read_enum_variant_arg(0u) {
self.read_def_id(xcx)
},
do self.read_enum_variant_arg(1u) || {
do self.read_enum_variant_arg(1u) {
self.read_tys(xcx)
}
)
......@@ -551,16 +551,16 @@ fn emit_bounds(ecx: @e::encode_ctxt, bs: ty::param_bounds) {
}
fn emit_tpbt(ecx: @e::encode_ctxt, tpbt: ty::ty_param_bounds_and_ty) {
do self.emit_rec || {
do self.emit_rec_field("bounds", 0u) || {
do self.emit_rec {
do self.emit_rec_field("bounds", 0u) {
do self.emit_from_vec(*tpbt.bounds) |bs| {
self.emit_bounds(ecx, bs)
}
}
do self.emit_rec_field("rp", 1u) || {
do self.emit_rec_field("rp", 1u) {
ast::serialize_region_param(self, tpbt.rp)
}
do self.emit_rec_field("ty", 2u) || {
do self.emit_rec_field("ty", 2u) {
self.emit_ty(ecx, tpbt.ty);
}
}
......@@ -569,7 +569,7 @@ fn emit_tpbt(ecx: @e::encode_ctxt, tpbt: ty::ty_param_bounds_and_ty) {
impl writer for ebml::writer {
fn tag(tag_id: c::astencode_tag, f: fn()) {
do self.wr_tag(tag_id as uint) || { f() }
do self.wr_tag(tag_id as uint) { f() }
}
fn id(id: ast::node_id) {
......@@ -581,7 +581,7 @@ fn encode_side_tables_for_ii(ecx: @e::encode_ctxt,
maps: maps,
ebml_w: ebml::writer,
ii: ast::inlined_item) {
do ebml_w.wr_tag(c::tag_table as uint) || {
do ebml_w.wr_tag(c::tag_table as uint) {
ast_util::visit_ids_for_inlined_item(
ii,
fn@(id: ast::node_id, copy ebml_w) {
......@@ -602,35 +602,35 @@ fn encode_side_tables_for_id(ecx: @e::encode_ctxt,
#debug["Encoding side tables for id %d", id];
do option::iter(tcx.def_map.find(id)) |def| {
do ebml_w.tag(c::tag_table_def) || {
do ebml_w.tag(c::tag_table_def) {
ebml_w.id(id);
do ebml_w.tag(c::tag_table_val) || {
do ebml_w.tag(c::tag_table_val) {
ast::serialize_def(ebml_w, def)
}
}
}
do option::iter((*tcx.node_types).find(id as uint)) |ty| {
do ebml_w.tag(c::tag_table_node_type) || {
do ebml_w.tag(c::tag_table_node_type) {
ebml_w.id(id);
do ebml_w.tag(c::tag_table_val) || {
do ebml_w.tag(c::tag_table_val) {
e::write_type(ecx, ebml_w, ty)
}
}
}
do option::iter(tcx.node_type_substs.find(id)) |tys| {
do ebml_w.tag(c::tag_table_node_type_subst) || {
do ebml_w.tag(c::tag_table_node_type_subst) {
ebml_w.id(id);
do ebml_w.tag(c::tag_table_val) || {
do ebml_w.tag(c::tag_table_val) {
ebml_w.emit_tys(ecx, tys)
}
}
}
do option::iter(tcx.freevars.find(id)) |fv| {
do ebml_w.tag(c::tag_table_freevars) || {
do ebml_w.tag(c::tag_table_freevars) {
ebml_w.id(id);
do ebml_w.tag(c::tag_table_val) || {
do ebml_w.tag(c::tag_table_val) {
do ebml_w.emit_from_vec(*fv) |fv_entry| {
encode_freevar_entry(ebml_w, *fv_entry)
}
......@@ -640,18 +640,18 @@ fn encode_side_tables_for_id(ecx: @e::encode_ctxt,
let lid = {crate: ast::local_crate, node: id};
do option::iter(tcx.tcache.find(lid)) |tpbt| {
do ebml_w.tag(c::tag_table_tcache) || {
do ebml_w.tag(c::tag_table_tcache) {
ebml_w.id(id);
do ebml_w.tag(c::tag_table_val) || {
do ebml_w.tag(c::tag_table_val) {
ebml_w.emit_tpbt(ecx, tpbt);
}
}
}
do option::iter(tcx.ty_param_bounds.find(id)) |pbs| {
do ebml_w.tag(c::tag_table_param_bounds) || {
do ebml_w.tag(c::tag_table_param_bounds) {
ebml_w.id(id);
do ebml_w.tag(c::tag_table_val) || {
do ebml_w.tag(c::tag_table_val) {
ebml_w.emit_bounds(ecx, pbs)
}
}
......@@ -672,15 +672,15 @@ fn encode_side_tables_for_id(ecx: @e::encode_ctxt,
//}
do option::iter(maps.mutbl_map.find(id)) |_m| {
do ebml_w.tag(c::tag_table_mutbl) || {
do ebml_w.tag(c::tag_table_mutbl) {
ebml_w.id(id);
}
}
do option::iter(maps.last_use_map.find(id)) |m| {
do ebml_w.tag(c::tag_table_last_use) || {
do ebml_w.tag(c::tag_table_last_use) {
ebml_w.id(id);
do ebml_w.tag(c::tag_table_val) || {
do ebml_w.tag(c::tag_table_val) {
do ebml_w.emit_from_vec((*m).get()) |id| {
ebml_w.emit_int(id);
}
......@@ -692,27 +692,27 @@ fn encode_side_tables_for_id(ecx: @e::encode_ctxt,
// don't need to keep it.
do option::iter(maps.method_map.find(id)) |mme| {
do ebml_w.tag(c::tag_table_method_map) || {
do ebml_w.tag(c::tag_table_method_map) {
ebml_w.id(id);
do ebml_w.tag(c::tag_table_val) || {
do ebml_w.tag(c::tag_table_val) {
serialize_method_map_entry(ebml_w, mme)
}
}
}
do option::iter(maps.vtable_map.find(id)) |dr| {
do ebml_w.tag(c::tag_table_vtable_map) || {
do ebml_w.tag(c::tag_table_vtable_map) {
ebml_w.id(id);
do ebml_w.tag(c::tag_table_val) || {
do ebml_w.tag(c::tag_table_val) {
encode_vtable_res(ecx, ebml_w, dr);
}
}
}
do option::iter(tcx.borrowings.find(id)) |borrow| {
do ebml_w.tag(c::tag_table_borrowings) || {
do ebml_w.tag(c::tag_table_borrowings) {
ebml_w.id(id);
do ebml_w.tag(c::tag_table_val) || {
do ebml_w.tag(c::tag_table_val) {
ty::serialize_borrow(ebml_w, borrow)
}
}
......@@ -753,7 +753,7 @@ fn read_bounds(xcx: extended_decode_ctxt) -> @~[ty::param_bound] {
fn read_ty_param_bounds_and_ty(xcx: extended_decode_ctxt)
-> ty::ty_param_bounds_and_ty {
do self.read_rec || {
do self.read_rec {
{
bounds: self.read_rec_field("bounds", 0u, || {
@self.read_to_vec(|| self.read_bounds(xcx) )
......@@ -838,7 +838,7 @@ fn decode_side_tables(xcx: extended_decode_ctxt,
#[cfg(test)]
fn encode_item_ast(ebml_w: ebml::writer, item: @ast::item) {
do ebml_w.wr_tag(c::tag_tree as uint) || {
do ebml_w.wr_tag(c::tag_tree as uint) {
ast::serialize_item(ebml_w, *item);
}
}
......
......@@ -508,9 +508,9 @@ fn check_loans_in_fn(fk: visit::fn_kind, decl: ast::fn_decl, body: ast::blk,
visitor: visit::vt<check_loan_ctxt>) {
#debug["purity on entry=%?", copy self.declared_purity];
do save_and_restore(self.in_ctor) || {
do save_and_restore(self.declared_purity) || {
do save_and_restore(self.fn_args) || {
do save_and_restore(self.in_ctor) {
do save_and_restore(self.declared_purity) {
do save_and_restore(self.fn_args) {
let is_stack_closure = self.is_stack_closure(id);
// In principle, we could consider fk_anon(*) or
......@@ -637,7 +637,7 @@ fn check_loans_in_expr(expr: @ast::expr,
fn check_loans_in_block(blk: ast::blk,
&&self: check_loan_ctxt,
vt: visit::vt<check_loan_ctxt>) {
do save_and_restore(self.declared_purity) || {
do save_and_restore(self.declared_purity) {
self.check_for_conflicting_loans(blk.node.id);
alt blk.node.rules {
......
......@@ -2800,7 +2800,7 @@ fn resolve_item(item: @item, visitor: ResolveVisitor) {
item_mod(module) {
let atom = (*self.atom_table).intern(item.ident);
do self.with_scope(some(atom)) || {
do self.with_scope(some(atom)) {
self.resolve_module(module, item.span, item.ident,
item.id, visitor);
}
......@@ -2808,7 +2808,7 @@ fn resolve_item(item: @item, visitor: ResolveVisitor) {
item_foreign_mod(foreign_module) {
let atom = (*self.atom_table).intern(item.ident);
do self.with_scope(some(atom)) || {
do self.with_scope(some(atom)) {
for foreign_module.items.each |foreign_item| {
alt foreign_item.node {
foreign_item_fn(_, type_parameters) {
......@@ -2935,7 +2935,7 @@ fn resolve_function(rib_kind: RibKind,
(*self.value_ribs).push(function_value_rib);
// If this function has type parameters, add them now.
do self.with_type_parameter_rib(type_parameters) || {
do self.with_type_parameter_rib(type_parameters) {
// Resolve the type parameters.
alt type_parameters {
NoTypeParameters {
......
......@@ -412,7 +412,7 @@ fn ty_of_fn_decl<AC: ast_conv, RS: region_scope copy>(
expected_tys: expected_tys) -> ty::fn_ty {
#debug["ty_of_fn_decl"];
do indent || {
do indent {
// new region names that appear inside of the fn decl are bound to
// that function type
let rb = in_binding_rscope(rscope);
......
......@@ -632,7 +632,7 @@ fn check_expr_with(fcx: @fn_ctxt, expr: @ast::expr, expected: ty::t) -> bool {
fn check_expr(fcx: @fn_ctxt, expr: @ast::expr,
expected: option<ty::t>) -> bool {
ret do check_expr_with_unifier(fcx, expr, expected) || {
ret do check_expr_with_unifier(fcx, expr, expected) {
for expected.each |t| {
demand::suptype(fcx, expr.span, t, fcx.expr_ty(expr));
}
......
......@@ -771,9 +771,9 @@ fn set_var_to_merged_bounds<V:copy vid, T:copy to_str st>(
// them explicitly gives the type inferencer more
// information and helps to produce tighter bounds
// when necessary.
do indent || {
do self.bnds(a.lb, b.ub).then || {
do self.bnds(b.lb, a.ub).then || {
do indent {
do self.bnds(a.lb, b.ub).then {
do self.bnds(b.lb, a.ub).then {
do self.merge_bnd(a.ub, b.ub, |x, y| x.glb(self, y) ).chain |ub| {
do self.merge_bnd(a.lb, b.lb, |x, y| x.lub(self, y) ).chain |lb| {
let bnds = {lb: lb, ub: ub};
......@@ -783,7 +783,7 @@ fn set_var_to_merged_bounds<V:copy vid, T:copy to_str st>(
// the new bounds must themselves
// be relatable:
do self.bnds(bnds.lb, bnds.ub).then || {
do self.bnds(bnds.lb, bnds.ub).then {
self.set(vb, v_id, root(bnds, rank));
uok()
}
......@@ -1021,7 +1021,7 @@ fn bnds<T:copy to_str st>(
a: bound<T>, b: bound<T>) -> ures {
#debug("bnds(%s <: %s)", a.to_str(self), b.to_str(self));
do indent || {
do indent {
alt (a, b) {
(none, none) |
(some(_), none) |
......@@ -1064,8 +1064,8 @@ fn eq_tys(a: ty::t, b: ty::t) -> ures {
fn eq_regions(a: ty::region, b: ty::region) -> ures {
#debug["eq_regions(%s, %s)",
a.to_str(self), b.to_str(self)];
do indent || {
do self.sub_regions(a, b).then || {
do indent {
do self.sub_regions(a, b).then {
self.sub_regions(b, a)
}
}
......@@ -1457,8 +1457,8 @@ fn crosspollinate(anmnt: assignment,
anmnt, a.to_str(self), nr_b.to_str(self),
r_b.to_str(self)];
do indent || {
do self.sub_tys(a, nr_b).then || {
do indent {
do self.sub_tys(a, nr_b).then {
let r_a = ty::re_scope(anmnt.borrow_scope);
#debug["anmnt=%?", anmnt];
do sub(self).contraregions(r_a, r_b).chain |_r| {
......@@ -1559,7 +1559,7 @@ fn eq_opt_regions(infcx: infer_ctxt,
ok(none)
}
(some(a), some(b)) {
do infcx.eq_regions(a, b).then || {
do infcx.eq_regions(a, b).then {
ok(some(a))
}
}
......@@ -1868,7 +1868,7 @@ fn super_tys<C:combine>(
(ty::ty_constr(a_t, a_constrs), ty::ty_constr(b_t, b_constrs)) {
do self.tys(a_t, b_t).chain |t| {
do self.infcx().constrvecs(a_constrs, b_constrs).then || {
do self.infcx().constrvecs(a_constrs, b_constrs).then {
ok(ty::mk_constr(tcx, t, a_constrs))
}
}
......@@ -1897,25 +1897,25 @@ fn regions(a: ty::region, b: ty::region) -> cres<ty::region> {
self.tag(),
a.to_str(self.infcx()),
b.to_str(self.infcx())];
do indent || {
do indent {
alt (a, b) {
(ty::re_var(a_id), ty::re_var(b_id)) {
do self.infcx().vars(self.rb, a_id, b_id).then || {
do self.infcx().vars(self.rb, a_id, b_id).then {
ok(a)
}
}
(ty::re_var(a_id), _) {
do self.infcx().vart(self.rb, a_id, b).then || {
do self.infcx().vart(self.rb, a_id, b).then {
ok(a)
}
}
(_, ty::re_var(b_id)) {
do self.infcx().tvar(self.rb, a, b_id).then || {
do self.infcx().tvar(self.rb, a, b_id).then {
ok(a)
}
}
_ {
do self.lub().regions(a, b).compare(b) || {
do self.lub().regions(a, b).compare(b) {
ty::terr_regions_differ(b, a)
}
}
......@@ -1965,7 +1965,7 @@ fn tys(a: ty::t, b: ty::t) -> cres<ty::t> {
#debug("%s.tys(%s, %s)", self.tag(),
a.to_str(*self), b.to_str(*self));
if a == b { ret ok(a); }
do indent || {
do indent {
alt (ty::get(a).struct, ty::get(b).struct) {
(ty::ty_bot, _) {
ok(a)
......@@ -2144,7 +2144,7 @@ fn regions(a: ty::region, b: ty::region) -> cres<ty::region> {
a.to_str(self.infcx()),
b.to_str(self.infcx())];
do indent || {
do indent {
alt (a, b) {
(ty::re_static, _) | (_, ty::re_static) {
ok(ty::re_static) // nothing lives longer than static
......@@ -2341,7 +2341,7 @@ fn regions(a: ty::region, b: ty::region) -> cres<ty::region> {
a.to_str(self.infcx()),
b.to_str(self.infcx())];
do indent || {
do indent {
alt (a, b) {
(ty::re_static, r) | (r, ty::re_static) {
// static lives longer than everything else
......@@ -2479,7 +2479,7 @@ fn lattice_tys<L:lattice_ops combine>(
a.to_str(self.infcx()),
b.to_str(self.infcx()));
if a == b { ret ok(a); }
do indent || {
do indent {
alt (ty::get(a).struct, ty::get(b).struct) {
(ty::ty_bot, _) { self.ty_bot(b) }
(_, ty::ty_bot) { self.ty_bot(a) }
......@@ -2606,7 +2606,7 @@ fn lattice_var_t<V:copy vid, T:copy to_str st, L:lattice_ops combine>(
// and then return b.
#debug["bnd=none"];
let a_bounds = self.with_bnd(a_bounds, b);
do self.infcx().bnds(a_bounds.lb, a_bounds.ub).then || {
do self.infcx().bnds(a_bounds.lb, a_bounds.ub).then {
self.infcx().set(vb, a_id, root(a_bounds,
nde_a.rank));
ok(b)
......
......@@ -115,7 +115,7 @@ fn should_request_new_writer_for_each_page() {
let doc = page_pass::mk_pass(config::doc_per_mod).f(srv, doc);
write_markdown(doc, writer_factory);
// We expect two pages to have been written
for iter::repeat(2u) || {
for iter::repeat(2u) {
comm::recv(po);
}
}
......@@ -146,7 +146,7 @@ fn should_write_title_for_each_page() {
"#[link(name = \"core\")]; mod a { }");
let doc = page_pass::mk_pass(config::doc_per_mod).f(srv, doc);
write_markdown(doc, writer_factory);
for iter::repeat(2u) || {
for iter::repeat(2u) {
let (page, markdown) = comm::recv(po);
alt page {
doc::cratepage(_) {
......
......@@ -101,14 +101,14 @@ fn pandoc_writer(
let stdout_po = comm::port();
let stdout_ch = comm::chan(stdout_po);
do task::spawn_sched(task::single_threaded) || {
do task::spawn_sched(task::single_threaded) {
comm::send(stdout_ch, readclose(pipe_out.in));
}
let stdout = comm::recv(stdout_po);
let stderr_po = comm::port();
let stderr_ch = comm::chan(stderr_po);
do task::spawn_sched(task::single_threaded) || {
do task::spawn_sched(task::single_threaded) {
comm::send(stderr_ch, readclose(pipe_err.in));
}
let stderr = comm::recv(stderr_po);
......@@ -262,7 +262,7 @@ fn future_writer_factory(
let writer_factory = fn~(page: doc::page) -> writer {
let writer_po = comm::port();
let writer_ch = comm::chan(writer_po);
do task::spawn || {
do task::spawn {
let (writer, future) = future_writer();
comm::send(writer_ch, writer);
let s = future::get(future);
......@@ -280,7 +280,7 @@ fn future_writer() -> (writer, future::future<str>) {
let writer = fn~(+instr: writeinstr) {
comm::send(chan, copy instr);
};
let future = do future::from_fn || {
let future = do future::from_fn {
let mut res = "";
loop {
alt comm::recv(port) {
......
......@@ -35,7 +35,7 @@ fn run_passes(
log(debug, #fmt("pass #%d", passno));
passno += 1;
log(debug, doc);
do time(pass.name) || {
do time(pass.name) {
pass.f(srv, doc)
}
}
......@@ -130,7 +130,7 @@ fn run(config: config::config) {
let source_file = config.input_crate;
do astsrv::from_file(source_file) |srv| {
do time("wait_ast") || {
do time("wait_ast") {
do astsrv::exec(srv) |_ctxt| { }
};
let doc = time("extract", || {
......
......@@ -34,7 +34,7 @@ fn port<T: send>() -> port<T> {
self.po = po; }
drop unsafe {
#debug("in the port_ptr destructor");
do task::unkillable || {
do task::unkillable {
let yield = 0u;
let yieldp = ptr::addr_of(yield);
rustrt::rust_port_begin_detach(self.po, yieldp);
......
......@@ -235,7 +235,7 @@ fn is_gray(c: color) -> bool {
let color = arc::arc(colors);
colors = do par::mapi_factory(*arc::get(&color)) || {
colors = do par::mapi_factory(*arc::get(&color)) {
let colors = arc::clone(&color);
let graph = arc::clone(&graph);
fn~(i: uint, c: color) -> color {
......
......@@ -41,7 +41,7 @@ fn run(args: ~[str]) {
for uint::range(0u, workers) |_i| {
let builder = task::builder();
vec::push(worker_results, task::future_result(builder));
do task::run(builder) || {
do task::run(builder) {
for uint::range(0u, size / workers) |_i| {
comm::send(to_child, bytes(100u));
}
......
......@@ -157,7 +157,7 @@ fn main(args: ~[str]) {
let writep = comm::port();
let writech = comm::chan(writep);
do task::spawn || {
do task::spawn {
writer(path, writech, size);
};
let ch = comm::recv(writep);
......
......@@ -17,9 +17,9 @@ fn main() {
}
fn run(repeat: int, depth: int) {
for iter::repeat(repeat as uint) || {
for iter::repeat(repeat as uint) {
#debug("starting %.4f", precise_time_s());
do task::try || {
do task::try {
recurse_or_fail(depth, none)
};
#debug("stopping %.4f", precise_time_s());
......
......@@ -12,13 +12,13 @@ fn calc(children: uint, parent_ch: comm::chan<msg>) {
let mut child_chs = ~[];
let mut sum = 0;
for iter::repeat (children) || {
do task::spawn || {
for iter::repeat (children) {
do task::spawn {
calc(0u, chan);
};
}
for iter::repeat (children) || {
for iter::repeat (children) {
alt check comm::recv(port) {
ready(child_ch) {
vec::push(child_chs, child_ch);
......@@ -36,7 +36,7 @@ fn calc(children: uint, parent_ch: comm::chan<msg>) {
}
}
for iter::repeat (children) || {
for iter::repeat (children) {
alt check comm::recv(port) {
done(child_sum) { sum += child_sum; }
}
......@@ -57,7 +57,7 @@ fn main(args: ~[str]) {
let children = uint::from_str(args[1]).get();
let port = comm::port();
let chan = comm::chan(port);
do task::spawn || {
do task::spawn {
calc(children, chan);
};
alt check comm::recv(port) {
......
......@@ -17,7 +17,7 @@ fn b() {
let mut p = ~[mut 1];
do borrow(p) || { //~ NOTE loan of mutable vec content granted here
do borrow(p) { //~ NOTE loan of mutable vec content granted here
p[0] = 5; //~ ERROR assigning to mutable vec content prohibited due to outstanding loan
}
}
......
......@@ -76,7 +76,7 @@ fn at_most_once(f: fn()) { f() }
let mut v = ~3, w = ~4;
let mut _x = &mut w;
do at_most_once || {
do at_most_once {
borrow(v); //~ ERROR loan of mutable variable declared in an outer block as immutable conflicts with prior loan
_x = &mut v; //~ NOTE prior loan as mutable granted here
}
......
......@@ -19,7 +19,7 @@ fn a() {
p.impurem();
// But in this case we do not honor the loan:
do p.blockm || { //~ NOTE loan of mutable local variable granted here
do p.blockm { //~ NOTE loan of mutable local variable granted here
p.x = 10; //~ ERROR assigning to mutable field prohibited due to outstanding loan
}
}
......
......@@ -8,13 +8,13 @@ fn takes_imm_elt(_v: &int, f: fn()) {
fn has_mut_vec_and_does_not_try_to_change_it() {
let v = ~[mut 1, 2, 3];
do takes_imm_elt(&v[0]) || {
do takes_imm_elt(&v[0]) {
}
}
fn has_mut_vec_but_tries_to_change_it() {
let v = ~[mut 1, 2, 3];
do takes_imm_elt(&v[0]) || { //~ NOTE loan of mutable vec content granted here
do takes_imm_elt(&v[0]) { //~ NOTE loan of mutable vec content granted here
v[1] = 4; //~ ERROR assigning to mutable vec content prohibited due to outstanding loan
}
}
......@@ -25,7 +25,7 @@ fn takes_const_elt(_v: &const int, f: fn()) {
fn has_mut_vec_and_tries_to_change_it() {
let v = ~[mut 1, 2, 3];
do takes_const_elt(&const v[0]) || {
do takes_const_elt(&const v[0]) {
v[1] = 4;
}
}
......
......@@ -6,7 +6,7 @@
drop { }
fn set_identity() {
do closure || {
do closure {
setsockopt_bytes(self.sock) //~ ERROR copying a noncopyable value
}
}
......
......@@ -3,7 +3,7 @@ fn use(_i: int) {}
fn foo() {
// Here, i is *moved* into the closure: Not actually OK
let mut i = 0;
do task::spawn || {
do task::spawn {
use(i); //~ ERROR mutable variables cannot be implicitly captured
}
}
......@@ -13,7 +13,7 @@ fn bar() {
// is mutable: bad
let mut i = 0;
while i < 10 {
do task::spawn || {
do task::spawn {
use(i); //~ ERROR mutable variables cannot be implicitly captured
}
i += 1;
......
......@@ -6,7 +6,7 @@ fn main() {
let v = ~[1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
let arc_v = arc::arc(v);
do task::spawn() || {
do task::spawn() {
let v = *arc::get(&arc_v);
assert v[3] == 4;
};
......
......@@ -2,4 +2,4 @@
// is probably not necessary anymore
fn blk1(b: fn()) -> fn@() { ret fn@() { }; }
fn test1() { (do blk1 || { #debug["hi"]; })(); }
fn test1() { (do blk1 { #debug["hi"]; })(); }
......@@ -21,8 +21,8 @@ fn count(n: uint) -> uint {
}
fn main() {
for iter::repeat(10u) || {
do task::spawn || {
for iter::repeat(10u) {
do task::spawn {
let result = count(5u);
#debug("result = %?", result);
fail;
......
......@@ -34,7 +34,7 @@ fn getbig(i: int) {
}
fn main() {
do task::spawn || {
do task::spawn {
let r = and_then_get_big_again(4);
getbig_call_c_and_fail(10000);
};
......
......@@ -27,7 +27,7 @@ fn getbig(i: int) {
}
fn main() {
do task::spawn || {
do task::spawn {
getbig_and_fail(400);
};
}
\ No newline at end of file
......@@ -20,7 +20,7 @@ fn getbig_and_fail(&&i: int) {
}
fn main() {
do task::spawn || {
do task::spawn {
getbig_and_fail(1);
};
}
\ No newline at end of file
......@@ -13,7 +13,7 @@
fn main() {
log(error, "whatever");
do task::spawn || {
do task::spawn {
let i = r(5);
};
fail;
......
fn main() {
fn f(i: fn() -> uint) -> uint { i() }
let v = ~[-1f, 0f, 1f, 2f, 3f];
let z = do do vec::foldl(f, v) |x, _y| { x } || { 22u };
let z = do do vec::foldl(f, v) |x, _y| { x } { 22u };
assert z == 22u;
}
......@@ -3,6 +3,6 @@ fn call_any(f: fn() -> uint) -> uint {
}
fn main() {
let x_r = do call_any || { 22u };
let x_r = do call_any { 22u };
assert x_r == 22u;
}
......@@ -2,8 +2,8 @@
}
pure fn g() {
// `f || { }` is considered pure, so `do f || { }` should be too
do f || { }
// `f || { }` is considered pure, so `do f { }` should be too
do f { }
}
fn main() {
......
......@@ -19,7 +19,7 @@ fn count(n: uint) -> uint {
fn main() {
// Make sure we're on a task with small Rust stacks (main currently
// has a large stack)
do task::spawn || {
do task::spawn {
let result = count(1000u);
#debug("result = %?", result);
assert result == 1000u;
......
......@@ -23,7 +23,7 @@ fn count(n: uint) -> uint {
fn main() {
// Make sure we're on a task with small Rust stacks (main currently
// has a large stack)
do task::spawn || {
do task::spawn {
let result = count(12u);
#debug("result = %?", result);
assert result == 2048u;
......
......@@ -20,9 +20,9 @@ fn count(n: uint) -> uint {
}
fn main() {
for iter::repeat(100u) || {
do task::spawn || {
for iter::repeat(100u) {
do task::spawn {
assert count(5u) == 16u;
};
}
}
\ No newline at end of file
}
......@@ -17,8 +17,8 @@ fn count(n: uint) -> uint {
}
fn main() {
for iter::repeat(10u) || {
do task::spawn || {
for iter::repeat(10u) {
do task::spawn {
let result = count(5u);
#debug("result = %?", result);
assert result == 16u;
......
......@@ -6,7 +6,7 @@
drop { }
fn set_identity() {
do closure || {
do closure {
setsockopt_bytes(copy self.sock)
}
}
......
......@@ -21,7 +21,7 @@ fn b(c: chan<chan<int>>) {
}
fn main() {
for iter::repeat(100u) || {
for iter::repeat(100u) {
spawn(|| a() );
}
}
......@@ -12,7 +12,7 @@ fn main() {
assert f(10, |a| a) == 10;
g(||());
assert do f(10) |a| { a } == 10;
do g() || { }
do g() { }
let _x: fn@() -> int = || 10;
let _y: fn@(int) -> int = |a| a;
assert ff()(10) == 11;
......
......@@ -24,7 +24,7 @@ fn run(i: int) {
};
task::set_opts(builder, opts);
task::unsupervise(builder);
do task::run(builder) || {
do task::run(builder) {
task::yield();
let builder = task::builder();
let opts = {
......@@ -36,7 +36,7 @@ fn run(i: int) {
};
task::set_opts(builder, opts);
task::unsupervise(builder);
do task::run(builder) || {
do task::run(builder) {
task::yield();
run(i - 1);
task::yield();
......
......@@ -11,7 +11,7 @@ fn main() {
let p = port();
let c = chan(p);
do spawn() || {
do spawn() {
let p = port();
c.send(chan(p));
......
......@@ -16,16 +16,16 @@ fn test00() {
let number_of_messages: int = 10;
let c = comm::chan(p);
do task::spawn || {
do task::spawn {
test00_start(c, number_of_messages * 0, number_of_messages);
}
do task::spawn || {
do task::spawn {
test00_start(c, number_of_messages * 1, number_of_messages);
}
do task::spawn || {
do task::spawn {
test00_start(c, number_of_messages * 2, number_of_messages);
}
do task::spawn || {
do task::spawn {
test00_start(c, number_of_messages * 3, number_of_messages);
}
......
......@@ -18,7 +18,7 @@ fn test00() {
let builder = task::builder();
let r = task::future_result(builder);
do task::run(builder) || {
do task::run(builder) {
test00_start(ch, number_of_messages);
}
......
......@@ -7,7 +7,7 @@
fn main() {
let builder = task::builder();
task::unsupervise(builder);
do task::run(builder) || {
do task::run(builder) {
fn f() { f() };
f();
};
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册