about summary refs log tree commit diff
path: root/src/libstd/rt
diff options
context:
space:
mode:
authorPatrick Walton <pcwalton@mimiga.net>2013-11-20 14:17:12 -0800
committerPatrick Walton <pcwalton@mimiga.net>2013-11-26 08:23:57 -0800
commit1eca34de7dd55719cd83153994e5caf2027f62a2 (patch)
tree14ba2903a9ead6e569d08a33c9ebfc2c6ba07e9e /src/libstd/rt
parent6801bc8f552ce740deb60212903ba43de197689c (diff)
downloadrust-1eca34de7dd55719cd83153994e5caf2027f62a2.tar.gz
rust-1eca34de7dd55719cd83153994e5caf2027f62a2.zip
libstd: Remove all non-`proc` uses of `do` from libstd
Diffstat (limited to 'src/libstd/rt')
-rw-r--r--src/libstd/rt/basic.rs16
-rw-r--r--src/libstd/rt/borrowck.rs34
-rw-r--r--src/libstd/rt/comm.rs100
-rw-r--r--src/libstd/rt/kill.rs5
-rw-r--r--src/libstd/rt/local.rs16
-rw-r--r--src/libstd/rt/local_heap.rs12
-rw-r--r--src/libstd/rt/local_ptr.rs6
-rw-r--r--src/libstd/rt/logging.rs8
-rw-r--r--src/libstd/rt/mpmc_bounded_queue.rs4
-rw-r--r--src/libstd/rt/sched.rs40
-rw-r--r--src/libstd/rt/task.rs32
-rw-r--r--src/libstd/rt/tube.rs4
-rw-r--r--src/libstd/rt/work_queue.rs8
13 files changed, 131 insertions, 154 deletions
diff --git a/src/libstd/rt/basic.rs b/src/libstd/rt/basic.rs
index 2c1c5d84be1..d857f39ceaf 100644
--- a/src/libstd/rt/basic.rs
+++ b/src/libstd/rt/basic.rs
@@ -71,13 +71,13 @@ impl BasicLoop {
 
     fn remote_work(&mut self) {
         let messages = unsafe {
-            do self.messages.with |messages| {
+            self.messages.with(|messages| {
                 if messages.len() > 0 {
                     Some(util::replace(messages, ~[]))
                 } else {
                     None
                 }
-            }
+            })
         };
         let messages = match messages {
             Some(m) => m, None => return
@@ -139,11 +139,11 @@ impl EventLoop for BasicLoop {
             unsafe {
                 // We block here if we have no messages to process and we may
                 // receive a message at a later date
-                do self.messages.hold_and_wait |messages| {
+                self.messages.hold_and_wait(|messages| {
                     self.remotes.len() > 0 &&
                         messages.len() == 0 &&
                         self.work.len() == 0
-                }
+                })
             }
         }
     }
@@ -189,9 +189,9 @@ impl BasicRemote {
 impl RemoteCallback for BasicRemote {
     fn fire(&mut self) {
         unsafe {
-            do self.queue.hold_and_signal |queue| {
+            self.queue.hold_and_signal(|queue| {
                 queue.push(RunRemote(self.id));
-            }
+            })
         }
     }
 }
@@ -199,9 +199,9 @@ impl RemoteCallback for BasicRemote {
 impl Drop for BasicRemote {
     fn drop(&mut self) {
         unsafe {
-            do self.queue.hold_and_signal |queue| {
+            self.queue.hold_and_signal(|queue| {
                 queue.push(RemoveRemote(self.id));
-            }
+            })
         }
     }
 }
diff --git a/src/libstd/rt/borrowck.rs b/src/libstd/rt/borrowck.rs
index 2c78a32a4b6..30c2264bd86 100644
--- a/src/libstd/rt/borrowck.rs
+++ b/src/libstd/rt/borrowck.rs
@@ -35,9 +35,7 @@ pub struct BorrowRecord {
 }
 
 fn try_take_task_borrow_list() -> Option<~[BorrowRecord]> {
-    do Local::borrow |task: &mut Task| {
-        task.borrow_list.take()
-    }
+    Local::borrow(|task: &mut Task| task.borrow_list.take())
 }
 
 fn swap_task_borrow_list(f: |~[BorrowRecord]| -> ~[BorrowRecord]) {
@@ -47,9 +45,7 @@ fn swap_task_borrow_list(f: |~[BorrowRecord]| -> ~[BorrowRecord]) {
     };
     let borrows = f(borrows);
     let borrows = Cell::new(borrows);
-    do Local::borrow |task: &mut Task| {
-        task.borrow_list = Some(borrows.take());
-    }
+    Local::borrow(|task: &mut Task| task.borrow_list = Some(borrows.take()))
 }
 
 pub fn clear_task_borrow_list() {
@@ -64,9 +60,7 @@ unsafe fn fail_borrowed(box: *mut raw::Box<()>, file: *c_char, line: size_t) ->
     match try_take_task_borrow_list() {
         None => { // not recording borrows
             let msg = "borrowed";
-            do msg.with_c_str |msg_p| {
-                task::begin_unwind_raw(msg_p, file, line);
-            }
+            msg.with_c_str(|msg_p| task::begin_unwind_raw(msg_p, file, line))
         }
         Some(borrow_list) => { // recording borrows
             let mut msg = ~"borrowed";
@@ -80,9 +74,7 @@ unsafe fn fail_borrowed(box: *mut raw::Box<()>, file: *c_char, line: size_t) ->
                     sep = " and at ";
                 }
             }
-            do msg.with_c_str |msg_p| {
-                task::begin_unwind_raw(msg_p, file, line)
-            }
+            msg.with_c_str(|msg_p| task::begin_unwind_raw(msg_p, file, line))
         }
     }
 }
@@ -158,33 +150,35 @@ pub unsafe fn record_borrow(a: *u8, old_ref_count: uint,
         // was not borrowed before
         let a = a as *mut raw::Box<()>;
         debug_borrow("record_borrow:", a, old_ref_count, 0, file, line);
-        do swap_task_borrow_list |borrow_list| {
+        swap_task_borrow_list(|borrow_list| {
             let mut borrow_list = borrow_list;
             borrow_list.push(BorrowRecord {box: a, file: file, line: line});
             borrow_list
-        }
+        })
     }
 }
 
-pub unsafe fn unrecord_borrow(a: *u8, old_ref_count: uint,
-                              file: *c_char, line: size_t) {
+pub unsafe fn unrecord_borrow(a: *u8,
+                              old_ref_count: uint,
+                              file: *c_char,
+                              line: size_t) {
     if (old_ref_count & ALL_BITS) == 0 {
         // was not borrowed before, so we should find the record at
         // the end of the list
         let a = a as *mut raw::Box<()>;
         debug_borrow("unrecord_borrow:", a, old_ref_count, 0, file, line);
-        do swap_task_borrow_list |borrow_list| {
+        swap_task_borrow_list(|borrow_list| {
             let mut borrow_list = borrow_list;
             assert!(!borrow_list.is_empty());
             let br = borrow_list.pop();
             if br.box != a || br.file != file || br.line != line {
                 let err = format!("wrong borrow found, br={:?}", br);
-                do err.with_c_str |msg_p| {
+                err.with_c_str(|msg_p| {
                     task::begin_unwind_raw(msg_p, file, line)
-                }
+                })
             }
             borrow_list
-        }
+        })
     }
 }
 
diff --git a/src/libstd/rt/comm.rs b/src/libstd/rt/comm.rs
index 8635f9372c4..e3e425f620b 100644
--- a/src/libstd/rt/comm.rs
+++ b/src/libstd/rt/comm.rs
@@ -165,14 +165,14 @@ impl<T: Send> ChanOne<T> {
                     // Port is blocked. Wake it up.
                     let recvr = BlockedTask::cast_from_uint(task_as_state);
                     if do_resched {
-                        do recvr.wake().map |woken_task| {
+                        recvr.wake().map(|woken_task| {
                             Scheduler::run_task(woken_task);
-                        };
+                        });
                     } else {
                         let recvr = Cell::new(recvr);
-                        do Local::borrow |sched: &mut Scheduler| {
+                        Local::borrow(|sched: &mut Scheduler| {
                             sched.enqueue_blocked_task(recvr.take());
-                        }
+                        })
                     }
                 }
             }
@@ -209,9 +209,9 @@ impl<T: Send> PortOne<T> {
             // No data available yet.
             // Switch to the scheduler to put the ~Task into the Packet state.
             let sched: ~Scheduler = Local::take();
-            do sched.deschedule_running_task_and_then |sched, task| {
+            sched.deschedule_running_task_and_then(|sched, task| {
                 self.block_on(sched, task);
-            }
+            })
         }
 
         // Task resumes.
@@ -230,9 +230,9 @@ impl<T: Send> SelectInner for PortOne<T> {
         // The optimistic check is never necessary for correctness. For testing
         // purposes, making it randomly return false simulates a racing sender.
         use rand::{Rand};
-        let actually_check = do Local::borrow |sched: &mut Scheduler| {
+        let actually_check = Local::borrow(|sched: &mut Scheduler| {
             Rand::rand(&mut sched.rng)
-        };
+        });
         if actually_check {
             unsafe { (*self.packet()).state.load(Acquire) == STATE_ONE }
         } else {
@@ -387,9 +387,9 @@ impl<T: Send> Drop for ChanOne<T> {
                     // The port is blocked waiting for a message we will never send. Wake it.
                     rtassert!((*self.packet()).payload.is_none());
                     let recvr = BlockedTask::cast_from_uint(task_as_state);
-                    do recvr.wake().map |woken_task| {
+                    recvr.wake().map(|woken_task| {
                         Scheduler::run_task(woken_task);
-                    };
+                    });
                 }
             }
         }
@@ -491,7 +491,7 @@ impl<T: Send> GenericPort<T> for Port<T> {
 
     fn try_recv(&self) -> Option<T> {
         let mut b = self.next.borrow_mut();
-        do b.get().take().map_default(None) |pone| {
+        b.get().take().map_default(None, |pone| {
             match pone.try_recv() {
                 Some(StreamPayload { val, next }) => {
                     *b.get() = Some(next);
@@ -499,7 +499,7 @@ impl<T: Send> GenericPort<T> for Port<T> {
                 }
                 None => None
             }
-        }
+        })
     }
 }
 
@@ -516,7 +516,7 @@ impl<T: Send> Peekable<T> for Port<T> {
 impl<'self, T: Send> SelectInner for &'self Port<T> {
     #[inline]
     fn optimistic_check(&mut self) -> bool {
-        do self.next.with_mut |pone| { pone.get_mut_ref().optimistic_check() }
+        self.next.with_mut(|pone| { pone.get_mut_ref().optimistic_check() })
     }
 
     #[inline]
@@ -527,7 +527,7 @@ impl<'self, T: Send> SelectInner for &'self Port<T> {
 
     #[inline]
     fn unblock_from(&mut self) -> bool {
-        do self.next.with_mut |pone| { pone.get_mut_ref().unblock_from() }
+        self.next.with_mut(|pone| { pone.get_mut_ref().unblock_from() })
     }
 }
 
@@ -871,7 +871,7 @@ mod test {
     #[test]
     fn oneshot_multi_thread_close_stress() {
         if util::limit_thread_creation_due_to_osx_and_valgrind() { return; }
-        do stress_factor().times {
+        stress_factor().times(|| {
             do run_in_newsched_task {
                 let (port, chan) = oneshot::<int>();
                 let port_cell = Cell::new(port);
@@ -881,13 +881,13 @@ mod test {
                 let _chan = chan;
                 thread.join();
             }
-        }
+        })
     }
 
     #[test]
     fn oneshot_multi_thread_send_close_stress() {
         if util::limit_thread_creation_due_to_osx_and_valgrind() { return; }
-        do stress_factor().times {
+        stress_factor().times(|| {
             do run_in_newsched_task {
                 let (port, chan) = oneshot::<int>();
                 let chan_cell = Cell::new(chan);
@@ -902,13 +902,13 @@ mod test {
                 thread1.join();
                 thread2.join();
             }
-        }
+        })
     }
 
     #[test]
     fn oneshot_multi_thread_recv_close_stress() {
         if util::limit_thread_creation_due_to_osx_and_valgrind() { return; }
-        do stress_factor().times {
+        stress_factor().times(|| {
             do run_in_newsched_task {
                 let (port, chan) = oneshot::<int>();
                 let chan_cell = Cell::new(chan);
@@ -929,13 +929,13 @@ mod test {
                 thread1.join();
                 thread2.join();
             }
-        }
+        })
     }
 
     #[test]
     fn oneshot_multi_thread_send_recv_stress() {
         if util::limit_thread_creation_due_to_osx_and_valgrind() { return; }
-        do stress_factor().times {
+        stress_factor().times(|| {
             do run_in_newsched_task {
                 let (port, chan) = oneshot::<~int>();
                 let chan_cell = Cell::new(chan);
@@ -949,13 +949,13 @@ mod test {
                 thread1.join();
                 thread2.join();
             }
-        }
+        })
     }
 
     #[test]
     fn stream_send_recv_stress() {
         if util::limit_thread_creation_due_to_osx_and_valgrind() { return; }
-        do stress_factor().times {
+        stress_factor().times(|| {
             do run_in_mt_newsched_task {
                 let (port, chan) = stream::<~int>();
 
@@ -984,17 +984,17 @@ mod test {
                     };
                 }
             }
-        }
+        })
     }
 
     #[test]
     fn recv_a_lot() {
         // Regression test that we don't run out of stack in scheduler context
-        do run_in_newsched_task {
+        run_in_newsched_task(|| {
             let (port, chan) = stream();
-            do 10000.times { chan.send(()) }
-            do 10000.times { port.recv() }
-        }
+            10000.times(|| { chan.send(()) });
+            10000.times(|| { port.recv() });
+        })
     }
 
     #[test]
@@ -1004,16 +1004,16 @@ mod test {
             let (port, chan) = stream();
             let chan = SharedChan::new(chan);
             let total = stress_factor() + 100;
-            do total.times {
+            total.times(|| {
                 let chan_clone = chan.clone();
                 do spawntask_random {
                     chan_clone.send(());
                 }
-            }
+            });
 
-            do total.times {
+            total.times(|| {
                 port.recv();
-            }
+            })
         }
     }
 
@@ -1026,22 +1026,22 @@ mod test {
             let end_chan = SharedChan::new(end_chan);
             let port = SharedPort::new(port);
             let total = stress_factor() + 100;
-            do total.times {
+            total.times(|| {
                 let end_chan_clone = end_chan.clone();
                 let port_clone = port.clone();
                 do spawntask_random {
                     port_clone.recv();
                     end_chan_clone.send(());
                 }
-            }
+            });
 
-            do total.times {
+            total.times(|| {
                 chan.send(());
-            }
+            });
 
-            do total.times {
+            total.times(|| {
                 end_port.recv();
-            }
+            })
         }
     }
 
@@ -1066,29 +1066,29 @@ mod test {
             let send_total = 10;
             let recv_total = 20;
             do spawntask_random {
-                do send_total.times {
+                send_total.times(|| {
                     let chan_clone = chan.clone();
                     do spawntask_random {
                         chan_clone.send(());
                     }
-                }
+                })
             }
             let end_chan_clone = end_chan.clone();
             do spawntask_random {
-                do recv_total.times {
+                recv_total.times(|| {
                     let port_clone = port.clone();
                     let end_chan_clone = end_chan_clone.clone();
                     do spawntask_random {
                         let recvd = port_clone.try_recv().is_some();
                         end_chan_clone.send(recvd);
                     }
-                }
+                })
             }
 
             let mut recvd = 0;
-            do recv_total.times {
+            recv_total.times(|| {
                 recvd += if end_port.recv() { 1 } else { 0 };
-            }
+            });
 
             assert!(recvd == send_total);
         }
@@ -1107,7 +1107,7 @@ mod test {
             let pipe = megapipe();
             let total = stress_factor() + 10;
             let mut rng = rand::rng();
-            do total.times {
+            total.times(|| {
                 let msgs = rng.gen_range(0u, 10);
                 let pipe_clone = pipe.clone();
                 let end_chan_clone = end_chan.clone();
@@ -1121,11 +1121,11 @@ mod test {
                 }
 
                 end_chan_clone.send(());
-            }
+            });
 
-            do total.times {
+            total.times(|| {
                 end_port.recv();
-            }
+            })
         }
     }
 
@@ -1152,13 +1152,13 @@ mod test {
 
             let cs = Cell::new((cone, cstream, cshared, mp));
             unsafe {
-                do atomically {
+                atomically(|| {
                     let (cone, cstream, cshared, mp) = cs.take();
                     cone.send_deferred(());
                     cstream.send_deferred(());
                     cshared.send_deferred(());
                     mp.send_deferred(());
-                }
+                })
             }
         }
     }
diff --git a/src/libstd/rt/kill.rs b/src/libstd/rt/kill.rs
index ac13b12c9ad..56c77ffaa0d 100644
--- a/src/libstd/rt/kill.rs
+++ b/src/libstd/rt/kill.rs
@@ -257,10 +257,7 @@ impl Death {
     /// Collect failure exit codes from children and propagate them to a parent.
     pub fn collect_failure(&mut self, result: UnwindResult) {
         let result = Cell::new(result);
-
-        do self.on_exit.take().map |on_exit| {
-            on_exit(result.take());
-        };
+        self.on_exit.take().map(|on_exit| on_exit(result.take()));
     }
 
     /// Enter a possibly-nested "atomic" section of code. Just for assertions.
diff --git a/src/libstd/rt/local.rs b/src/libstd/rt/local.rs
index d47dae96283..23345926543 100644
--- a/src/libstd/rt/local.rs
+++ b/src/libstd/rt/local.rs
@@ -34,10 +34,10 @@ impl Local for Task {
         let mut res: Option<T> = None;
         let res_ptr: *mut Option<T> = &mut res;
         unsafe {
-            do local_ptr::borrow |task| {
+            local_ptr::borrow(|task| {
                 let result = f(task);
                 *res_ptr = Some(result);
-            }
+            })
         }
         match res {
             Some(r) => { r }
@@ -57,10 +57,10 @@ impl Local for Task {
 impl Local for Scheduler {
     fn put(value: ~Scheduler) {
         let value = Cell::new(value);
-        do Local::borrow |task: &mut Task| {
+        Local::borrow(|task: &mut Task| {
             let task = task;
             task.sched = Some(value.take());
-        };
+        });
     }
     #[inline]
     fn take() -> ~Scheduler {
@@ -71,15 +71,15 @@ impl Local for Scheduler {
         }
     }
     fn exists(_: Option<Scheduler>) -> bool {
-        do Local::borrow |task: &mut Task| {
+        Local::borrow(|task: &mut Task| {
             match task.sched {
                 Some(ref _task) => true,
                 None => false
             }
-        }
+        })
     }
     fn borrow<T>(f: |&mut Scheduler| -> T) -> T {
-        do Local::borrow |task: &mut Task| {
+        Local::borrow(|task: &mut Task| {
             match task.sched {
                 Some(~ref mut task) => {
                     f(task)
@@ -88,7 +88,7 @@ impl Local for Scheduler {
                     rtabort!("no scheduler")
                 }
             }
-        }
+        })
     }
     unsafe fn unsafe_take() -> ~Scheduler { rtabort!("unimpl") }
     unsafe fn unsafe_borrow() -> *mut Scheduler {
diff --git a/src/libstd/rt/local_heap.rs b/src/libstd/rt/local_heap.rs
index d5ec6bd3f37..a7805a9f559 100644
--- a/src/libstd/rt/local_heap.rs
+++ b/src/libstd/rt/local_heap.rs
@@ -302,9 +302,7 @@ pub unsafe fn local_free(ptr: *libc::c_char) {
 }
 
 pub fn live_allocs() -> *mut Box {
-    do Local::borrow |task: &mut Task| {
-        task.heap.live_allocs
-    }
+    Local::borrow(|task: &mut Task| task.heap.live_allocs)
 }
 
 #[cfg(test)]
@@ -313,15 +311,11 @@ mod bench {
 
     #[bench]
     fn alloc_managed_small(bh: &mut BenchHarness) {
-        do bh.iter {
-            @10;
-        }
+        bh.iter(|| @10);
     }
 
     #[bench]
     fn alloc_managed_big(bh: &mut BenchHarness) {
-        do bh.iter {
-            @[10, ..1000];
-        }
+        bh.iter(|| @[10, ..1000]);
     }
 }
diff --git a/src/libstd/rt/local_ptr.rs b/src/libstd/rt/local_ptr.rs
index 862ecd6499a..eb7d8ef2f5f 100644
--- a/src/libstd/rt/local_ptr.rs
+++ b/src/libstd/rt/local_ptr.rs
@@ -110,11 +110,7 @@ pub unsafe fn borrow<T>(f: |&mut T|) {
     let unsafe_ptr = cast::transmute_mut_region(&mut *value);
     let value_cell = Cell::new(value);
 
-    do (|| {
-        f(unsafe_ptr);
-    }).finally {
-        put(value_cell.take());
-    }
+    (|| f(unsafe_ptr)).finally(|| put(value_cell.take()));
 }
 
 /// Borrow a mutable reference to the thread-local value
diff --git a/src/libstd/rt/logging.rs b/src/libstd/rt/logging.rs
index 2ca47dbff59..13e18f7d9b7 100644
--- a/src/libstd/rt/logging.rs
+++ b/src/libstd/rt/logging.rs
@@ -142,19 +142,17 @@ fn update_log_settings(crate_map: &CrateMap, settings: ~str) {
     if settings.len() > 0 {
         if settings == ~"::help" || settings == ~"?" {
             rterrln!("\nCrate log map:\n");
-            do iter_crate_map(crate_map) |entry| {
-                rterrln!(" {}", entry.name);
-            }
+            iter_crate_map(crate_map, |entry| rterrln!(" {}", entry.name));
             unsafe { exit(1); }
         }
         dirs = parse_logging_spec(settings);
     }
 
     let mut n_matches: u32 = 0;
-    do iter_crate_map(crate_map) |entry| {
+    iter_crate_map(crate_map, |entry| {
         let m = update_entry(dirs, entry);
         n_matches += m;
-    }
+    });
 
     if n_matches < (dirs.len() as u32) {
         rterrln!("warning: got {} RUST_LOG specs but only matched\n\
diff --git a/src/libstd/rt/mpmc_bounded_queue.rs b/src/libstd/rt/mpmc_bounded_queue.rs
index 2f61a433983..7f607fcf12a 100644
--- a/src/libstd/rt/mpmc_bounded_queue.rs
+++ b/src/libstd/rt/mpmc_bounded_queue.rs
@@ -68,9 +68,9 @@ impl<T: Send> State<T> {
         } else {
             capacity
         };
-        let buffer = do vec::from_fn(capacity) |i:uint| {
+        let buffer = vec::from_fn(capacity, |i:uint| {
             Node{sequence:AtomicUint::new(i),value:None}
-        };
+        });
         State{
             pad0: [0, ..64],
             buffer: buffer,
diff --git a/src/libstd/rt/sched.rs b/src/libstd/rt/sched.rs
index 1caaf77bd96..519274bb131 100644
--- a/src/libstd/rt/sched.rs
+++ b/src/libstd/rt/sched.rs
@@ -236,9 +236,9 @@ impl Scheduler {
             // Our scheduler must be in the task before the event loop
             // is started.
             let self_sched = Cell::new(self);
-            do Local::borrow |stask: &mut Task| {
+            Local::borrow(|stask: &mut Task| {
                 stask.sched = Some(self_sched.take());
-            };
+            });
 
             (*event_loop).run();
         }
@@ -538,9 +538,7 @@ impl Scheduler {
     /// As enqueue_task, but with the possibility for the blocked task to
     /// already have been killed.
     pub fn enqueue_blocked_task(&mut self, blocked_task: BlockedTask) {
-        do blocked_task.wake().map |task| {
-            self.enqueue_task(task);
-        };
+        blocked_task.wake().map(|task| self.enqueue_task(task));
     }
 
     // * Core Context Switching Functions
@@ -643,9 +641,9 @@ impl Scheduler {
     // * Context Swapping Helpers - Here be ugliness!
 
     pub fn resume_task_immediately(~self, task: ~Task) {
-        do self.change_task_context(task) |sched, stask| {
+        self.change_task_context(task, |sched, stask| {
             sched.sched_task = Some(stask);
-        }
+        })
     }
 
     fn resume_task_immediately_cl(sched: ~Scheduler,
@@ -686,15 +684,15 @@ impl Scheduler {
                                          f: |&mut Scheduler, BlockedTask|) {
         // This is where we convert the BlockedTask-taking closure into one
         // that takes just a Task
-        do self.change_task_context(next_task) |sched, task| {
+        self.change_task_context(next_task, |sched, task| {
             f(sched, BlockedTask::block(task))
-        }
+        })
     }
 
     fn switch_task(sched: ~Scheduler, task: ~Task) {
-        do sched.switch_running_tasks_and_then(task) |sched, last_task| {
+        sched.switch_running_tasks_and_then(task, |sched, last_task| {
             sched.enqueue_blocked_task(last_task);
-        };
+        });
     }
 
     // * Task Context Helpers
@@ -705,10 +703,10 @@ impl Scheduler {
         // Similar to deschedule running task and then, but cannot go through
         // the task-blocking path. The task is already dying.
         let stask = self.sched_task.take_unwrap();
-        do self.change_task_context(stask) |sched, mut dead_task| {
+        self.change_task_context(stask, |sched, mut dead_task| {
             let coroutine = dead_task.coroutine.take_unwrap();
             coroutine.recycle(&mut sched.stack_pool);
-        }
+        })
     }
 
     pub fn run_task(task: ~Task) {
@@ -718,9 +716,9 @@ impl Scheduler {
 
     pub fn run_task_later(next_task: ~Task) {
         let next_task = Cell::new(next_task);
-        do Local::borrow |sched: &mut Scheduler| {
+        Local::borrow(|sched: &mut Scheduler| {
             sched.enqueue_task(next_task.take());
-        };
+        });
     }
 
     /// Yield control to the scheduler, executing another task. This is guaranteed
@@ -731,9 +729,9 @@ impl Scheduler {
         self.yield_check_count = reset_yield_check(&mut self.rng);
         // Tell the scheduler to start stealing on the next iteration
         self.steal_for_yield = true;
-        do self.deschedule_running_task_and_then |sched, task| {
+        self.deschedule_running_task_and_then(|sched, task| {
             sched.enqueue_blocked_task(task);
-        }
+        })
     }
 
     pub fn maybe_yield(mut ~self) {
@@ -852,9 +850,9 @@ fn new_sched_rng() -> XorShiftRng {
     use iter::Iterator;
     use rand::SeedableRng;
 
-    let fd = do "/dev/urandom".with_c_str |name| {
+    let fd = "/dev/urandom".with_c_str(|name| {
         unsafe { libc::open(name, libc::O_RDONLY, 0) }
-    };
+    });
     if fd == -1 {
         rtabort!("could not open /dev/urandom for reading.")
     }
@@ -862,13 +860,13 @@ fn new_sched_rng() -> XorShiftRng {
     let mut seeds = [0u32, .. 4];
     let size = mem::size_of_val(&seeds);
     loop {
-        let nbytes = do seeds.as_mut_buf |buf, _| {
+        let nbytes = seeds.as_mut_buf(|buf, _| {
             unsafe {
                 libc::read(fd,
                            buf as *mut libc::c_void,
                            size as libc::size_t)
             }
-        };
+        });
         rtassert!(nbytes as uint == size);
 
         if !seeds.iter().all(|x| *x == 0) {
diff --git a/src/libstd/rt/task.rs b/src/libstd/rt/task.rs
index bc9496b16cd..569d96ae388 100644
--- a/src/libstd/rt/task.rs
+++ b/src/libstd/rt/task.rs
@@ -142,7 +142,7 @@ impl Task {
                              -> ~Task {
         let f = Cell::new(f);
         let home = Cell::new(home);
-        do Local::borrow |running_task: &mut Task| {
+        Local::borrow(|running_task: &mut Task| {
             let mut sched = running_task.sched.take_unwrap();
             let new_task = ~running_task.new_child_homed(&mut sched.stack_pool,
                                                          stack_size,
@@ -150,7 +150,7 @@ impl Task {
                                                          f.take());
             running_task.sched = Some(sched);
             new_task
-        }
+        })
     }
 
     pub fn build_child(stack_size: Option<uint>, f: proc()) -> ~Task {
@@ -163,7 +163,7 @@ impl Task {
                             -> ~Task {
         let f = Cell::new(f);
         let home = Cell::new(home);
-        do Local::borrow |running_task: &mut Task| {
+        Local::borrow(|running_task: &mut Task| {
             let mut sched = running_task.sched.take_unwrap();
             let new_task = ~Task::new_root_homed(&mut sched.stack_pool,
                                                  stack_size,
@@ -171,7 +171,7 @@ impl Task {
                                                  f.take());
             running_task.sched = Some(sched);
             new_task
-        }
+        })
     }
 
     pub fn build_root(stack_size: Option<uint>, f: proc()) -> ~Task {
@@ -280,10 +280,10 @@ impl Task {
 
         // The only try/catch block in the world. Attempt to run the task's
         // client-specified code and catch any failures.
-        do self.unwinder.try {
+        self.unwinder.try(|| {
 
             // Run the task main function, then do some cleanup.
-            do f.finally {
+            f.finally(|| {
 
                 // First, destroy task-local storage. This may run user dtors.
                 //
@@ -320,8 +320,8 @@ impl Task {
                     None => {}
                 }
                 self.logger.take();
-            }
-        }
+            })
+        });
 
         // Cleanup the dynamic borrowck debugging info
         borrowck::clear_task_borrow_list();
@@ -364,7 +364,7 @@ impl Task {
     // Grab both the scheduler and the task from TLS and check if the
     // task is executing on an appropriate scheduler.
     pub fn on_appropriate_sched() -> bool {
-        do Local::borrow |task: &mut Task| {
+        Local::borrow(|task: &mut Task| {
             let sched_id = task.sched.get_ref().sched_id();
             let sched_run_anything = task.sched.get_ref().run_anything;
             match task.task_type {
@@ -383,7 +383,7 @@ impl Task {
                     rtabort!("type error: expected: GreenTask, found: SchedTask");
                 }
             }
-        }
+        })
     }
 }
 
@@ -431,9 +431,9 @@ impl Coroutine {
             unsafe {
 
                 // Again - might work while safe, or it might not.
-                do Local::borrow |sched: &mut Scheduler| {
+                Local::borrow(|sched: &mut Scheduler| {
                     sched.run_cleanup_job();
-                }
+                });
 
                 // To call the run method on a task we need a direct
                 // reference to it. The task is in TLS, so we can
@@ -442,7 +442,7 @@ impl Coroutine {
                 // need to unsafe_borrow.
                 let task: *mut Task = Local::unsafe_borrow();
 
-                do (*task).run {
+                (*task).run(|| {
                     // N.B. Removing `start` from the start wrapper
                     // closure by emptying a cell is critical for
                     // correctness. The ~Task pointer, and in turn the
@@ -455,7 +455,7 @@ impl Coroutine {
                     // scope while the task is still running.
                     let start = start_cell.take();
                     start();
-                };
+                });
             }
 
             // We remove the sched from the Task in TLS right now.
@@ -584,7 +584,7 @@ pub extern "C" fn rust_stack_exhausted() {
         //  #2361 - possible implementation of not using landing pads
 
         if in_green_task_context() {
-            do Local::borrow |task: &mut Task| {
+            Local::borrow(|task: &mut Task| {
                 let n = task.name.as_ref().map(|n| n.as_slice()).unwrap_or("<unnamed>");
 
                 // See the message below for why this is not emitted to the
@@ -593,7 +593,7 @@ pub extern "C" fn rust_stack_exhausted() {
                 // call would happen to initialized it (calling out to libuv),
                 // and the FFI call needs 2MB of stack when we just ran out.
                 rterrln!("task '{}' has overflowed its stack", n);
-            }
+            })
         } else {
             rterrln!("stack overflow in non-task context");
         }
diff --git a/src/libstd/rt/tube.rs b/src/libstd/rt/tube.rs
index 16fd3fa38ea..360764daf15 100644
--- a/src/libstd/rt/tube.rs
+++ b/src/libstd/rt/tube.rs
@@ -68,9 +68,9 @@ impl<T> Tube<T> {
                 assert!(self.p.refcount() > 1); // There better be somebody to wake us up
                 assert!((*state).blocked_task.is_none());
                 let sched: ~Scheduler = Local::take();
-                do sched.deschedule_running_task_and_then |_, task| {
+                sched.deschedule_running_task_and_then(|_, task| {
                     (*state).blocked_task = Some(task);
-                }
+                });
                 rtdebug!("waking after tube recv");
                 let buf = &mut (*state).buf;
                 assert!(!buf.is_empty());
diff --git a/src/libstd/rt/work_queue.rs b/src/libstd/rt/work_queue.rs
index 24792f3904e..02ea8ab4f50 100644
--- a/src/libstd/rt/work_queue.rs
+++ b/src/libstd/rt/work_queue.rs
@@ -37,25 +37,25 @@ impl<T: Send> WorkQueue<T> {
 
     pub fn pop(&mut self) -> Option<T> {
         unsafe {
-            do self.queue.with |q| {
+            self.queue.with(|q| {
                 if !q.is_empty() {
                     Some(q.shift())
                 } else {
                     None
                 }
-            }
+            })
         }
     }
 
     pub fn steal(&mut self) -> Option<T> {
         unsafe {
-            do self.queue.with |q| {
+            self.queue.with(|q| {
                 if !q.is_empty() {
                     Some(q.pop())
                 } else {
                     None
                 }
-            }
+            })
         }
     }