about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2013-08-01 12:52:29 -0700
committerbors <bors@rust-lang.org>2013-08-01 12:52:29 -0700
commit82b24559e6aa0914f8a49e0a9dbfb3cf35372515 (patch)
treec2b0ff9b26400eac3f3405d78fe89dc07607c3ae /src/libstd
parent479809a267dbbcc3e2ec87da677c63430d3d229a (diff)
parent94f1a5d6f8ecd30c6f59dfeaacdd5962f58bc44c (diff)
downloadrust-82b24559e6aa0914f8a49e0a9dbfb3cf35372515.tar.gz
rust-82b24559e6aa0914f8a49e0a9dbfb3cf35372515.zip
auto merge of #8190 : thestinger/rust/for, r=thestinger
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/cleanup.rs15
-rw-r--r--src/libstd/container.rs12
-rw-r--r--src/libstd/gc.rs107
-rw-r--r--src/libstd/hash.rs75
-rw-r--r--src/libstd/hashmap.rs57
-rw-r--r--src/libstd/io.rs17
-rw-r--r--src/libstd/iter.rs4
-rw-r--r--src/libstd/iterator.rs6
-rw-r--r--src/libstd/num/uint.rs13
-rw-r--r--src/libstd/os.rs3
-rw-r--r--src/libstd/rand.rs6
-rw-r--r--src/libstd/rt/comm.rs38
-rw-r--r--src/libstd/rt/io/net/tcp.rs8
-rw-r--r--src/libstd/rt/mod.rs2
-rw-r--r--src/libstd/rt/sched.rs2
-rw-r--r--src/libstd/rt/select.rs8
-rw-r--r--src/libstd/stackwalk.rs7
-rw-r--r--src/libstd/str.rs2
-rw-r--r--src/libstd/task/mod.rs18
-rw-r--r--src/libstd/task/spawn.rs3
-rw-r--r--src/libstd/to_bytes.rs7
-rw-r--r--src/libstd/trie.rs51
-rw-r--r--src/libstd/unstable/extfmt.rs2
-rw-r--r--src/libstd/unstable/sync.rs2
-rw-r--r--src/libstd/vec.rs33
25 files changed, 243 insertions, 255 deletions
diff --git a/src/libstd/cleanup.rs b/src/libstd/cleanup.rs
index ed2b0e16818..24ca6fc2309 100644
--- a/src/libstd/cleanup.rs
+++ b/src/libstd/cleanup.rs
@@ -94,27 +94,29 @@ pub unsafe fn annihilate() {
     //
     // In this pass, nothing gets freed, so it does not matter whether
     // we read the next field before or after the callback.
-    for each_live_alloc(true) |box, uniq| {
+    do each_live_alloc(true) |box, uniq| {
         stats.n_total_boxes += 1;
         if uniq {
             stats.n_unique_boxes += 1;
         } else {
             (*box).ref_count = managed::RC_IMMORTAL;
         }
-    }
+        true
+    };
 
     // Pass 2: Drop all boxes.
     //
     // In this pass, unique-managed boxes may get freed, but not
     // managed boxes, so we must read the `next` field *after* the
     // callback, as the original value may have been freed.
-    for each_live_alloc(false) |box, uniq| {
+    do each_live_alloc(false) |box, uniq| {
         if !uniq {
             let tydesc = (*box).type_desc;
             let data = &(*box).data as *();
             ((*tydesc).drop_glue)(data as *i8);
         }
-    }
+        true
+    };
 
     // Pass 3: Free all boxes.
     //
@@ -122,14 +124,15 @@ pub unsafe fn annihilate() {
     // unique-managed boxes, though I think that none of those are
     // left), so we must read the `next` field before, since it will
     // not be valid after.
-    for each_live_alloc(true) |box, uniq| {
+    do each_live_alloc(true) |box, uniq| {
         if !uniq {
             stats.n_bytes_freed +=
                 (*((*box).type_desc)).size
                 + sys::size_of::<raw::Box<()>>();
             local_free(box as *i8);
         }
-    }
+        true
+    };
 
     if debug_mem() {
         // We do logging here w/o allocation.
diff --git a/src/libstd/container.rs b/src/libstd/container.rs
index d855beea50b..10f3fc6586f 100644
--- a/src/libstd/container.rs
+++ b/src/libstd/container.rs
@@ -87,17 +87,7 @@ pub trait Set<T>: Container {
     /// Return true if the set is a superset of another
     fn is_superset(&self, other: &Self) -> bool;
 
-    /// Visit the values representing the difference
-    fn difference(&self, other: &Self, f: &fn(&T) -> bool) -> bool;
-
-    /// Visit the values representing the symmetric difference
-    fn symmetric_difference(&self, other: &Self, f: &fn(&T) -> bool) -> bool;
-
-    /// Visit the values representing the intersection
-    fn intersection(&self, other: &Self, f: &fn(&T) -> bool) -> bool;
-
-    /// Visit the values representing the union
-    fn union(&self, other: &Self, f: &fn(&T) -> bool) -> bool;
+    // FIXME #8154: Add difference, sym. difference, intersection and union iterators
 }
 
 /// This trait represents actions which can be performed on sets to mutate
diff --git a/src/libstd/gc.rs b/src/libstd/gc.rs
index ee270b553e6..9a8db6990b6 100644
--- a/src/libstd/gc.rs
+++ b/src/libstd/gc.rs
@@ -121,11 +121,11 @@ unsafe fn is_safe_point(pc: *Word) -> Option<SafePoint> {
     return None;
 }
 
-type Visitor<'self> = &'self fn(root: **Word, tydesc: *TyDesc) -> bool;
+type Visitor<'self> = &'self fn(root: **Word, tydesc: *TyDesc);
 
 // Walks the list of roots for the given safe point, and calls visitor
 // on each root.
-unsafe fn _walk_safe_point(fp: *Word, sp: SafePoint, visitor: Visitor) -> bool {
+unsafe fn _walk_safe_point(fp: *Word, sp: SafePoint, visitor: Visitor) {
     let fp_bytes = fp as *u8;
     let sp_meta = sp.sp_meta as *u32;
 
@@ -151,7 +151,7 @@ unsafe fn _walk_safe_point(fp: *Word, sp: SafePoint, visitor: Visitor) -> bool {
             } else {
                 ptr::null()
             };
-            if !visitor(root, tydesc) { return false; }
+            visitor(root, tydesc);
         }
         sri += 1;
     }
@@ -164,10 +164,9 @@ unsafe fn _walk_safe_point(fp: *Word, sp: SafePoint, visitor: Visitor) -> bool {
         }
         rri += 1;
     }
-    return true;
 }
 
-unsafe fn walk_safe_point(fp: *Word, sp: SafePoint, visitor: Visitor) -> bool {
+unsafe fn walk_safe_point(fp: *Word, sp: SafePoint, visitor: Visitor) {
     _walk_safe_point(fp, sp, visitor)
 }
 
@@ -223,7 +222,7 @@ static need_cleanup:    Memory = exchange_heap | stack;
 
 // Walks stack, searching for roots of the requested type, and passes
 // each root to the visitor.
-unsafe fn _walk_gc_roots(mem: Memory, sentinel: **Word, visitor: Visitor) -> bool {
+unsafe fn _walk_gc_roots(mem: Memory, sentinel: **Word, visitor: Visitor) {
     let mut segment = rustrt::rust_get_stack_segment();
     let mut last_ret: *Word = ptr::null();
     // To avoid collecting memory used by the GC itself, skip stack
@@ -231,7 +230,7 @@ unsafe fn _walk_gc_roots(mem: Memory, sentinel: **Word, visitor: Visitor) -> boo
     // frame is marked by a sentinel, which is a box pointer stored on
     // the stack.
     let mut reached_sentinel = ptr::is_null(sentinel);
-    for walk_stack |frame| {
+    do walk_stack |frame| {
         let pc = last_ret;
         let Segment {segment: next_segment, boundary: boundary} =
             find_segment_for_frame(frame.fp, segment);
@@ -248,53 +247,46 @@ unsafe fn _walk_gc_roots(mem: Memory, sentinel: **Word, visitor: Visitor) -> boo
         let ret_offset = if boundary { 4 } else { 1 };
         last_ret = *ptr::offset(frame.fp, ret_offset as int) as *Word;
 
-        if ptr::is_null(pc) {
-            loop;
-        }
-
-        let mut delay_reached_sentinel = reached_sentinel;
-        let sp = is_safe_point(pc);
-        match sp {
-          Some(sp_info) => {
-            for walk_safe_point(frame.fp, sp_info) |root, tydesc| {
-                // Skip roots until we see the sentinel.
-                if !reached_sentinel {
-                    if root == sentinel {
-                        delay_reached_sentinel = true;
-                    }
-                    loop;
-                }
-
-                // Skip null pointers, which can occur when a
-                // unique pointer has already been freed.
-                if ptr::is_null(*root) {
-                    loop;
-                }
-
-                if ptr::is_null(tydesc) {
-                    // Root is a generic box.
-                    let refcount = **root;
-                    if mem | task_local_heap != 0 && refcount != -1 {
-                        if !visitor(root, tydesc) { return false; }
-                    } else if mem | exchange_heap != 0 && refcount == -1 {
-                        if !visitor(root, tydesc) { return false; }
-                    }
-                } else {
-                    // Root is a non-immediate.
-                    if mem | stack != 0 {
-                        if !visitor(root, tydesc) { return false; }
+        if !ptr::is_null(pc) {
+
+            let mut delay_reached_sentinel = reached_sentinel;
+            let sp = is_safe_point(pc);
+            match sp {
+                Some(sp_info) => {
+                    do walk_safe_point(frame.fp, sp_info) |root, tydesc| {
+                        // Skip roots until we see the sentinel.
+                        if !reached_sentinel && root == sentinel {
+                            delay_reached_sentinel = true;
+                        }
+
+                        // Skip null pointers, which can occur when a
+                        // unique pointer has already been freed.
+                        if reached_sentinel && !ptr::is_null(*root) {
+                            if ptr::is_null(tydesc) {
+                                // Root is a generic box.
+                                let refcount = **root;
+                                if mem | task_local_heap != 0 && refcount != -1 {
+                                    visitor(root, tydesc);
+                                } else if mem | exchange_heap != 0 && refcount == -1 {
+                                    visitor(root, tydesc);
+                                }
+                            } else {
+                                // Root is a non-immediate.
+                                if mem | stack != 0 {
+                                    visitor(root, tydesc);
+                                }
+                            }
+                        }
                     }
                 }
+                None => ()
             }
-          }
-          None => ()
+            reached_sentinel = delay_reached_sentinel;
         }
-        reached_sentinel = delay_reached_sentinel;
     }
-    return true;
 }
 
-unsafe fn walk_gc_roots(mem: Memory, sentinel: **Word, visitor: Visitor) -> bool {
+unsafe fn walk_gc_roots(mem: Memory, sentinel: **Word, visitor: Visitor) {
     _walk_gc_roots(mem, sentinel, visitor)
 }
 pub fn gc() {
@@ -304,7 +296,7 @@ pub fn gc() {
             return;
         }
 
-        for walk_gc_roots(task_local_heap, ptr::null()) |_root, _tydesc| {
+        do walk_gc_roots(task_local_heap, ptr::null()) |_root, _tydesc| {
             // FIXME(#2997): Walk roots and mark them.
             io::stdout().write([46]); // .
         }
@@ -349,18 +341,17 @@ pub fn cleanup_stack_for_failure() {
         };
 
         let mut roots = HashSet::new();
-        for walk_gc_roots(need_cleanup, sentinel) |root, tydesc| {
+        do walk_gc_roots(need_cleanup, sentinel) |root, tydesc| {
             // Track roots to avoid double frees.
-            if roots.contains(&*root) {
-                loop;
-            }
-            roots.insert(*root);
+            if !roots.contains(&*root) {
+                roots.insert(*root);
 
-            if ptr::is_null(tydesc) {
-                // FIXME #4420: Destroy this box
-                // FIXME #4330: Destroy this box
-            } else {
-                ((*tydesc).drop_glue)(*root as *i8);
+                if ptr::is_null(tydesc) {
+                    // FIXME #4420: Destroy this box
+                    // FIXME #4330: Destroy this box
+                } else {
+                    ((*tydesc).drop_glue)(*root as *i8);
+                }
             }
         }
     }
diff --git a/src/libstd/hash.rs b/src/libstd/hash.rs
index 16d138d4e1f..5d4b9b4e3f0 100644
--- a/src/libstd/hash.rs
+++ b/src/libstd/hash.rs
@@ -85,9 +85,10 @@ impl<A:IterBytes> Hash for A {
     #[inline]
     fn hash_keyed(&self, k0: u64, k1: u64) -> u64 {
         let mut s = State::new(k0, k1);
-        for self.iter_bytes(true) |bytes| {
+        do self.iter_bytes(true) |bytes| {
             s.input(bytes);
-        }
+            true
+        };
         s.result_u64()
     }
 }
@@ -95,12 +96,14 @@ impl<A:IterBytes> Hash for A {
 fn hash_keyed_2<A: IterBytes,
                 B: IterBytes>(a: &A, b: &B, k0: u64, k1: u64) -> u64 {
     let mut s = State::new(k0, k1);
-    for a.iter_bytes(true) |bytes| {
+    do a.iter_bytes(true) |bytes| {
         s.input(bytes);
-    }
-    for b.iter_bytes(true) |bytes| {
+        true
+    };
+    do b.iter_bytes(true) |bytes| {
         s.input(bytes);
-    }
+        true
+    };
     s.result_u64()
 }
 
@@ -108,15 +111,18 @@ fn hash_keyed_3<A: IterBytes,
                 B: IterBytes,
                 C: IterBytes>(a: &A, b: &B, c: &C, k0: u64, k1: u64) -> u64 {
     let mut s = State::new(k0, k1);
-    for a.iter_bytes(true) |bytes| {
+    do a.iter_bytes(true) |bytes| {
         s.input(bytes);
-    }
-    for b.iter_bytes(true) |bytes| {
+        true
+    };
+    do b.iter_bytes(true) |bytes| {
         s.input(bytes);
-    }
-    for c.iter_bytes(true) |bytes| {
+        true
+    };
+    do c.iter_bytes(true) |bytes| {
         s.input(bytes);
-    }
+        true
+    };
     s.result_u64()
 }
 
@@ -132,18 +138,22 @@ fn hash_keyed_4<A: IterBytes,
                 k1: u64)
                 -> u64 {
     let mut s = State::new(k0, k1);
-    for a.iter_bytes(true) |bytes| {
+    do a.iter_bytes(true) |bytes| {
         s.input(bytes);
-    }
-    for b.iter_bytes(true) |bytes| {
+        true
+    };
+    do b.iter_bytes(true) |bytes| {
         s.input(bytes);
-    }
-    for c.iter_bytes(true) |bytes| {
+        true
+    };
+    do c.iter_bytes(true) |bytes| {
         s.input(bytes);
-    }
-    for d.iter_bytes(true) |bytes| {
+        true
+    };
+    do d.iter_bytes(true) |bytes| {
         s.input(bytes);
-    }
+        true
+    };
     s.result_u64()
 }
 
@@ -161,21 +171,26 @@ fn hash_keyed_5<A: IterBytes,
                 k1: u64)
                 -> u64 {
     let mut s = State::new(k0, k1);
-    for a.iter_bytes(true) |bytes| {
+    do a.iter_bytes(true) |bytes| {
         s.input(bytes);
-    }
-    for b.iter_bytes(true) |bytes| {
+        true
+    };
+    do b.iter_bytes(true) |bytes| {
         s.input(bytes);
-    }
-    for c.iter_bytes(true) |bytes| {
+        true
+    };
+    do c.iter_bytes(true) |bytes| {
         s.input(bytes);
-    }
-    for d.iter_bytes(true) |bytes| {
+        true
+    };
+    do d.iter_bytes(true) |bytes| {
         s.input(bytes);
-    }
-    for e.iter_bytes(true) |bytes| {
+        true
+    };
+    do e.iter_bytes(true) |bytes| {
         s.input(bytes);
-    }
+        true
+    };
     s.result_u64()
 }
 
diff --git a/src/libstd/hashmap.rs b/src/libstd/hashmap.rs
index b162869201d..ca61f3e5ad8 100644
--- a/src/libstd/hashmap.rs
+++ b/src/libstd/hashmap.rs
@@ -130,15 +130,17 @@ impl<K:Hash + Eq,V> HashMap<K, V> {
                                 hash: uint,
                                 k: &K)
                              -> SearchResult {
-        for self.bucket_sequence(hash) |i| {
+        let mut ret = TableFull;
+        do self.bucket_sequence(hash) |i| {
             match self.buckets[i] {
-                Some(ref bkt) => if bkt.hash == hash && *k == bkt.key {
-                    return FoundEntry(i);
+                Some(ref bkt) if bkt.hash == hash && *k == bkt.key => {
+                    ret = FoundEntry(i); false
                 },
-                None => return FoundHole(i)
+                None => { ret = FoundHole(i); false }
+                _ => true,
             }
-        }
-        TableFull
+        };
+        ret
     }
 
     #[inline]
@@ -146,17 +148,17 @@ impl<K:Hash + Eq,V> HashMap<K, V> {
                                                   hash: uint,
                                                   k: &Q)
                                                -> SearchResult {
-        for self.bucket_sequence(hash) |i| {
+        let mut ret = TableFull;
+        do self.bucket_sequence(hash) |i| {
             match self.buckets[i] {
-                Some(ref bkt) => {
-                    if bkt.hash == hash && k.equiv(&bkt.key) {
-                        return FoundEntry(i);
-                    }
+                Some(ref bkt) if bkt.hash == hash && k.equiv(&bkt.key) => {
+                    ret = FoundEntry(i); false
                 },
-                None => return FoundHole(i)
+                None => { ret = FoundHole(i); false }
+                _ => true,
             }
-        }
-        TableFull
+        };
+        ret
     }
 
     /// Expand the capacity of the array to the next power of two
@@ -272,11 +274,6 @@ impl<K:Hash + Eq,V> HashMap<K, V> {
 
         value
     }
-
-    fn search(&self, hash: uint,
-              op: &fn(x: &Option<Bucket<K, V>>) -> bool) {
-        let _ = self.bucket_sequence(hash, |i| op(&self.buckets[i]));
-    }
 }
 
 impl<K:Hash + Eq,V> Container for HashMap<K, V> {
@@ -675,28 +672,6 @@ impl<T:Hash + Eq> Set<T> for HashSet<T> {
     fn is_superset(&self, other: &HashSet<T>) -> bool {
         other.is_subset(self)
     }
-
-    /// Visit the values representing the difference
-    fn difference(&self, other: &HashSet<T>, f: &fn(&T) -> bool) -> bool {
-        self.difference_iter(other).advance(f)
-    }
-
-    /// Visit the values representing the symmetric difference
-    fn symmetric_difference(&self,
-                            other: &HashSet<T>,
-                            f: &fn(&T) -> bool) -> bool {
-        self.symmetric_difference_iter(other).advance(f)
-    }
-
-    /// Visit the values representing the intersection
-    fn intersection(&self, other: &HashSet<T>, f: &fn(&T) -> bool) -> bool {
-        self.intersection_iter(other).advance(f)
-    }
-
-    /// Visit the values representing the union
-    fn union(&self, other: &HashSet<T>, f: &fn(&T) -> bool) -> bool {
-        self.union_iter(other).advance(f)
-    }
 }
 
 impl<T:Hash + Eq> MutableSet<T> for HashSet<T> {
diff --git a/src/libstd/io.rs b/src/libstd/io.rs
index cef183d0429..153286a311a 100644
--- a/src/libstd/io.rs
+++ b/src/libstd/io.rs
@@ -770,9 +770,10 @@ impl<T:Reader> ReaderUtil for T {
 
     fn read_lines(&self) -> ~[~str] {
         do vec::build |push| {
-            for self.each_line |line| {
+            do self.each_line |line| {
                 push(line.to_owned());
-            }
+                true
+            };
         }
     }
 
@@ -1880,16 +1881,16 @@ mod tests {
 
         {
             let file = io::file_reader(&path).unwrap();
-            for file.each_byte() |_| {
-                fail!("must be empty");
-            }
+            do file.each_byte() |_| {
+                fail!("must be empty")
+            };
         }
 
         {
             let file = io::file_reader(&path).unwrap();
-            for file.each_char() |_| {
-                fail!("must be empty");
-            }
+            do file.each_char() |_| {
+                fail!("must be empty")
+            };
         }
     }
 
diff --git a/src/libstd/iter.rs b/src/libstd/iter.rs
index 2092ae588d0..ce528bc9522 100644
--- a/src/libstd/iter.rs
+++ b/src/libstd/iter.rs
@@ -14,13 +14,13 @@
 use iter::Times;
 let ten = 10 as uint;
 let mut accum = 0;
-for ten.times { accum += 1; }
+do ten.times { accum += 1; }
 ~~~
 
 */
 
 #[allow(missing_doc)]
 pub trait Times {
-    fn times(&self, it: &fn() -> bool) -> bool;
+    fn times(&self, it: &fn());
 }
 
diff --git a/src/libstd/iterator.rs b/src/libstd/iterator.rs
index 84923876cbf..013901d57f8 100644
--- a/src/libstd/iterator.rs
+++ b/src/libstd/iterator.rs
@@ -18,7 +18,6 @@ implementing the `Iterator` trait.
 */
 
 use cmp;
-use iter::Times;
 use num::{Zero, One};
 use option::{Option, Some, None};
 use ops::{Add, Mul};
@@ -1229,8 +1228,9 @@ impl<A, T: Iterator<A>> Iterator<A> for Skip<T> {
         if self.n == 0 {
             next
         } else {
-            let n = self.n;
-            for n.times {
+            let mut n = self.n;
+            while n > 0 {
+                n -= 1;
                 match next {
                     Some(_) => {
                         next = self.iter.next();
diff --git a/src/libstd/num/uint.rs b/src/libstd/num/uint.rs
index 126150c0f1b..275a72d6ecc 100644
--- a/src/libstd/num/uint.rs
+++ b/src/libstd/num/uint.rs
@@ -97,22 +97,21 @@ pub fn iterate(lo: uint, hi: uint, it: &fn(uint) -> bool) -> bool {
 impl iter::Times for uint {
     #[inline]
     ///
-    /// A convenience form for basic iteration. Given a uint `x`,
-    /// `for x.times { ... }` executes the given block x times.
+    /// A convenience form for basic repetition. Given a uint `x`,
+    /// `do x.times { ... }` executes the given block x times.
     ///
     /// Equivalent to `for uint::range(0, x) |_| { ... }`.
     ///
     /// Not defined on all integer types to permit unambiguous
     /// use with integer literals of inferred integer-type as
-    /// the self-value (eg. `for 100.times { ... }`).
+    /// the self-value (eg. `do 100.times { ... }`).
     ///
-    fn times(&self, it: &fn() -> bool) -> bool {
+    fn times(&self, it: &fn()) {
         let mut i = *self;
         while i > 0 {
-            if !it() { return false; }
+            it();
             i -= 1;
         }
-        return true;
     }
 }
 
@@ -190,6 +189,6 @@ pub fn test_times() {
     use iter::Times;
     let ten = 10 as uint;
     let mut accum = 0;
-    for ten.times { accum += 1; }
+    do ten.times { accum += 1; }
     assert!((accum == 10));
 }
diff --git a/src/libstd/os.rs b/src/libstd/os.rs
index 3afd946ee26..1bfae8c40e1 100644
--- a/src/libstd/os.rs
+++ b/src/libstd/os.rs
@@ -790,7 +790,7 @@ pub fn list_dir_path(p: &Path) -> ~[Path] {
 /// all its contents. Use carefully!
 pub fn remove_dir_recursive(p: &Path) -> bool {
     let mut error_happened = false;
-    for walk_dir(p) |inner| {
+    do walk_dir(p) |inner| {
         if !error_happened {
             if path_is_dir(inner) {
                 if !remove_dir_recursive(inner) {
@@ -803,6 +803,7 @@ pub fn remove_dir_recursive(p: &Path) -> bool {
                 }
             }
         }
+        true
     };
     // Directory should now be empty
     !error_happened && remove_dir(p)
diff --git a/src/libstd/rand.rs b/src/libstd/rand.rs
index aed68f47fdf..9134d2da257 100644
--- a/src/libstd/rand.rs
+++ b/src/libstd/rand.rs
@@ -695,7 +695,7 @@ impl IsaacRng {
             }}
         );
 
-        for 4.times { mix!(); }
+        do 4.times { mix!(); }
 
         if use_rsl {
             macro_rules! memloop (
@@ -1092,7 +1092,7 @@ mod test {
         }
 
         // run against several seeds
-        for 10.times {
+        do 10.times {
             unsafe {
                 let seed = super::seed();
                 let rt_rng = do seed.as_imm_buf |p, sz| {
@@ -1100,7 +1100,7 @@ mod test {
                 };
                 let mut rng = IsaacRng::new_seeded(seed);
 
-                for 10000.times {
+                do 10000.times {
                     assert_eq!(rng.next(), rustrt::rand_next(rt_rng));
                 }
                 rustrt::rand_free(rt_rng);
diff --git a/src/libstd/rt/comm.rs b/src/libstd/rt/comm.rs
index a27ff559b2b..79ee8405531 100644
--- a/src/libstd/rt/comm.rs
+++ b/src/libstd/rt/comm.rs
@@ -769,7 +769,7 @@ mod test {
 
     #[test]
     fn oneshot_multi_thread_close_stress() {
-        for stress_factor().times {
+        do stress_factor().times {
             do run_in_newsched_task {
                 let (port, chan) = oneshot::<int>();
                 let port_cell = Cell::new(port);
@@ -784,7 +784,7 @@ mod test {
 
     #[test]
     fn oneshot_multi_thread_send_close_stress() {
-        for stress_factor().times {
+        do stress_factor().times {
             do run_in_newsched_task {
                 let (port, chan) = oneshot::<int>();
                 let chan_cell = Cell::new(chan);
@@ -804,7 +804,7 @@ mod test {
 
     #[test]
     fn oneshot_multi_thread_recv_close_stress() {
-        for stress_factor().times {
+        do stress_factor().times {
             do run_in_newsched_task {
                 let (port, chan) = oneshot::<int>();
                 let chan_cell = Cell::new(chan);
@@ -830,7 +830,7 @@ mod test {
 
     #[test]
     fn oneshot_multi_thread_send_recv_stress() {
-        for stress_factor().times {
+        do stress_factor().times {
             do run_in_newsched_task {
                 let (port, chan) = oneshot::<~int>();
                 let chan_cell = Cell::new(chan);
@@ -849,7 +849,7 @@ mod test {
 
     #[test]
     fn stream_send_recv_stress() {
-        for stress_factor().times {
+        do stress_factor().times {
             do run_in_mt_newsched_task {
                 let (port, chan) = stream::<~int>();
 
@@ -886,8 +886,8 @@ mod test {
         // Regression test that we don't run out of stack in scheduler context
         do run_in_newsched_task {
             let (port, chan) = stream();
-            for 10000.times { chan.send(()) }
-            for 10000.times { port.recv() }
+            do 10000.times { chan.send(()) }
+            do 10000.times { port.recv() }
         }
     }
 
@@ -897,14 +897,14 @@ mod test {
             let (port, chan) = stream();
             let chan = SharedChan::new(chan);
             let total = stress_factor() + 100;
-            for total.times {
+            do total.times {
                 let chan_clone = chan.clone();
                 do spawntask_random {
                     chan_clone.send(());
                 }
             }
 
-            for total.times {
+            do total.times {
                 port.recv();
             }
         }
@@ -919,7 +919,7 @@ mod test {
             let end_chan = SharedChan::new(end_chan);
             let port = SharedPort::new(port);
             let total = stress_factor() + 100;
-            for total.times {
+            do total.times {
                 let end_chan_clone = end_chan.clone();
                 let port_clone = port.clone();
                 do spawntask_random {
@@ -928,11 +928,11 @@ mod test {
                 }
             }
 
-            for total.times {
+            do total.times {
                 chan.send(());
             }
 
-            for total.times {
+            do total.times {
                 end_port.recv();
             }
         }
@@ -959,7 +959,7 @@ mod test {
             let send_total = 10;
             let recv_total = 20;
             do spawntask_random {
-                for send_total.times {
+                do send_total.times {
                     let chan_clone = chan.clone();
                     do spawntask_random {
                         chan_clone.send(());
@@ -968,7 +968,7 @@ mod test {
             }
             let end_chan_clone = end_chan.clone();
             do spawntask_random {
-                for recv_total.times {
+                do recv_total.times {
                     let port_clone = port.clone();
                     let end_chan_clone = end_chan_clone.clone();
                     do spawntask_random {
@@ -979,7 +979,7 @@ mod test {
             }
 
             let mut recvd = 0;
-            for recv_total.times {
+            do recv_total.times {
                 recvd += if end_port.recv() { 1 } else { 0 };
             }
 
@@ -998,15 +998,15 @@ mod test {
             let pipe = megapipe();
             let total = stress_factor() + 10;
             let mut rng = rand::rng();
-            for total.times {
+            do total.times {
                 let msgs = rng.gen_uint_range(0, 10);
                 let pipe_clone = pipe.clone();
                 let end_chan_clone = end_chan.clone();
                 do spawntask_random {
-                    for msgs.times {
+                    do msgs.times {
                         pipe_clone.send(());
                     }
-                    for msgs.times {
+                    do msgs.times {
                         pipe_clone.recv();
                     }
                 }
@@ -1014,7 +1014,7 @@ mod test {
                 end_chan_clone.send(());
             }
 
-            for total.times {
+            do total.times {
                 end_port.recv();
             }
         }
diff --git a/src/libstd/rt/io/net/tcp.rs b/src/libstd/rt/io/net/tcp.rs
index 82278875fa5..1d7dafc4302 100644
--- a/src/libstd/rt/io/net/tcp.rs
+++ b/src/libstd/rt/io/net/tcp.rs
@@ -371,7 +371,7 @@ mod test {
 
             do spawntask_immediately {
                 let mut listener = TcpListener::bind(addr);
-                for max.times {
+                do max.times {
                     let mut stream = listener.accept();
                     let mut buf = [0];
                     stream.read(buf);
@@ -380,7 +380,7 @@ mod test {
             }
 
             do spawntask_immediately {
-                for max.times {
+                do max.times {
                     let mut stream = TcpStream::connect(addr);
                     stream.write([99]);
                 }
@@ -396,7 +396,7 @@ mod test {
 
             do spawntask_immediately {
                 let mut listener = TcpListener::bind(addr);
-                for max.times {
+                do max.times {
                     let mut stream = listener.accept();
                     let mut buf = [0];
                     stream.read(buf);
@@ -405,7 +405,7 @@ mod test {
             }
 
             do spawntask_immediately {
-                for max.times {
+                do max.times {
                     let mut stream = TcpStream::connect(addr);
                     stream.write([99]);
                 }
diff --git a/src/libstd/rt/mod.rs b/src/libstd/rt/mod.rs
index 8648832c591..3bcf6787824 100644
--- a/src/libstd/rt/mod.rs
+++ b/src/libstd/rt/mod.rs
@@ -255,7 +255,7 @@ fn run_(main: ~fn(), use_main_sched: bool) -> int {
     // sent the Shutdown message to terminate the schedulers.
     let mut handles = ~[];
 
-    for nscheds.times {
+    do nscheds.times {
         // Every scheduler is driven by an I/O event loop.
         let loop_ = ~UvEventLoop::new();
         let mut sched = ~Scheduler::new(loop_, work_queue.clone(), sleepers.clone());
diff --git a/src/libstd/rt/sched.rs b/src/libstd/rt/sched.rs
index 98df38f9b1d..ae4ca2b9783 100644
--- a/src/libstd/rt/sched.rs
+++ b/src/libstd/rt/sched.rs
@@ -1097,7 +1097,7 @@ mod test {
 
         do run_in_mt_newsched_task {
             let mut ports = ~[];
-            for 10.times {
+            do 10.times {
                 let (port, chan) = oneshot();
                 let chan_cell = Cell::new(chan);
                 do spawntask_later {
diff --git a/src/libstd/rt/select.rs b/src/libstd/rt/select.rs
index 6296186aa49..b19357fa221 100644
--- a/src/libstd/rt/select.rs
+++ b/src/libstd/rt/select.rs
@@ -53,8 +53,8 @@ pub fn select<A: Select>(ports: &mut [A]) -> uint {
     do sched.deschedule_running_task_and_then |sched, task| {
         let task_handles = task.make_selectable(ports.len());
 
-        for ports.mut_iter().zip(task_handles.consume_iter()).enumerate().advance
-                |(index, (port, task_handle))| {
+        foreach (index, (port, task_handle)) in
+                ports.mut_iter().zip(task_handles.consume_iter()).enumerate() {
             // If one of the ports has data by now, it will wake the handle.
             if port.block_on(sched, task_handle) {
                 ready_index = index;
@@ -187,7 +187,7 @@ mod test {
         do run_in_newsched_task {
             let (ports, _) = unzip(from_fn(10, |_| stream()));
             let (port, chan) = stream();
-            for 10.times { chan.send(31337); }
+            do 10.times { chan.send(31337); }
             let mut ports = ports;
             let mut port = Some(port);
             let order = [5u,0,4,3,2,6,9,8,7,1];
@@ -268,7 +268,7 @@ mod test {
 
             do run_in_newsched_task {
                 // A bit of stress, since ordinarily this is just smoke and mirrors.
-                for 4.times {
+                do 4.times {
                     let send_on_chans = send_on_chans.clone();
                     do task::spawn {
                         let mut ports = ~[];
diff --git a/src/libstd/stackwalk.rs b/src/libstd/stackwalk.rs
index c3e3ca57a8e..cc516fb559e 100644
--- a/src/libstd/stackwalk.rs
+++ b/src/libstd/stackwalk.rs
@@ -25,7 +25,7 @@ pub fn Frame(fp: *Word) -> Frame {
     }
 }
 
-pub fn walk_stack(visit: &fn(Frame) -> bool) -> bool {
+pub fn walk_stack(visit: &fn(Frame)) {
 
     debug!("beginning stack walk");
 
@@ -51,12 +51,11 @@ pub fn walk_stack(visit: &fn(Frame) -> bool) -> bool {
             }
         }
     }
-    return true;
 }
 
 #[test]
 fn test_simple() {
-    for walk_stack |_frame| {
+    do walk_stack |_frame| {
     }
 }
 
@@ -65,7 +64,7 @@ fn test_simple_deep() {
     fn run(i: int) {
         if i == 0 { return }
 
-        for walk_stack |_frame| {
+        do walk_stack |_frame| {
             // Would be nice to test something here...
         }
         run(i - 1);
diff --git a/src/libstd/str.rs b/src/libstd/str.rs
index 894351bcc53..f0c0595744c 100644
--- a/src/libstd/str.rs
+++ b/src/libstd/str.rs
@@ -1828,7 +1828,7 @@ impl<'self> StrSlice<'self> for &'self str {
                 do ret.as_mut_buf |rbuf, _len| {
                     let mut rbuf = rbuf;
 
-                    for nn.times {
+                    do nn.times {
                         ptr::copy_memory(rbuf, buf, len);
                         rbuf = rbuf.offset(len as int);
                     }
diff --git a/src/libstd/task/mod.rs b/src/libstd/task/mod.rs
index aff4bc12039..d0124407bd4 100644
--- a/src/libstd/task/mod.rs
+++ b/src/libstd/task/mod.rs
@@ -683,7 +683,7 @@ fn test_spawn_unlinked_unsup_no_fail_down() { // grandchild sends on a port
         let ch = ch.clone();
         do spawn_unlinked {
             // Give middle task a chance to fail-but-not-kill-us.
-            for 16.times { task::yield(); }
+            do 16.times { task::yield(); }
             ch.send(()); // If killed first, grandparent hangs.
         }
         fail!(); // Shouldn't kill either (grand)parent or (grand)child.
@@ -698,7 +698,7 @@ fn test_spawn_unlinked_unsup_no_fail_up() { // child unlinked fails
 fn test_spawn_unlinked_sup_no_fail_up() { // child unlinked fails
     do spawn_supervised { fail!(); }
     // Give child a chance to fail-but-not-kill-us.
-    for 16.times { task::yield(); }
+    do 16.times { task::yield(); }
 }
 #[test] #[should_fail] #[ignore(cfg(windows))]
 fn test_spawn_unlinked_sup_fail_down() {
@@ -760,7 +760,7 @@ fn test_spawn_failure_propagate_grandchild() {
     do spawn_supervised {
         do spawn_supervised { block_forever(); }
     }
-    for 16.times { task::yield(); }
+    do 16.times { task::yield(); }
     fail!();
 }
 
@@ -770,7 +770,7 @@ fn test_spawn_failure_propagate_secondborn() {
     do spawn_supervised {
         do spawn { block_forever(); } // linked
     }
-    for 16.times { task::yield(); }
+    do 16.times { task::yield(); }
     fail!();
 }
 
@@ -780,7 +780,7 @@ fn test_spawn_failure_propagate_nephew_or_niece() {
     do spawn { // linked
         do spawn_supervised { block_forever(); }
     }
-    for 16.times { task::yield(); }
+    do 16.times { task::yield(); }
     fail!();
 }
 
@@ -790,7 +790,7 @@ fn test_spawn_linked_sup_propagate_sibling() {
     do spawn { // linked
         do spawn { block_forever(); } // linked
     }
-    for 16.times { task::yield(); }
+    do 16.times { task::yield(); }
     fail!();
 }
 
@@ -970,7 +970,7 @@ fn test_spawn_sched_blocking() {
 
         // Testing that a task in one scheduler can block in foreign code
         // without affecting other schedulers
-        for 20u.times {
+        do 20u.times {
             let (start_po, start_ch) = stream();
             let (fin_po, fin_ch) = stream();
 
@@ -1076,7 +1076,7 @@ fn test_unkillable() {
 
     // We want to do this after failing
     do spawn_unlinked {
-        for 10.times { yield() }
+        do 10.times { yield() }
         ch.send(());
     }
 
@@ -1111,7 +1111,7 @@ fn test_unkillable_nested() {
 
     // We want to do this after failing
     do spawn_unlinked || {
-        for 10.times { yield() }
+        do 10.times { yield() }
         ch.send(());
     }
 
diff --git a/src/libstd/task/spawn.rs b/src/libstd/task/spawn.rs
index 81db5e690a6..4558f8e32c1 100644
--- a/src/libstd/task/spawn.rs
+++ b/src/libstd/task/spawn.rs
@@ -372,8 +372,9 @@ impl Drop for Taskgroup {
                 // with our own taskgroup, so long as both happen before we die.
                 // We remove ourself from every ancestor we can, so no cleanup; no
                 // break.
-                for each_ancestor(&mut this.ancestors, |_| {}) |ancestor_group| {
+                do each_ancestor(&mut this.ancestors, |_| {}) |ancestor_group| {
                     leave_taskgroup(ancestor_group, &me, false);
+                    true
                 };
             }
         }
diff --git a/src/libstd/to_bytes.rs b/src/libstd/to_bytes.rs
index 60df31fd4ca..5ad7969c8d2 100644
--- a/src/libstd/to_bytes.rs
+++ b/src/libstd/to_bytes.rs
@@ -353,9 +353,10 @@ pub trait ToBytes {
 impl<A:IterBytes> ToBytes for A {
     fn to_bytes(&self, lsb0: bool) -> ~[u8] {
         do io::with_bytes_writer |wr| {
-            for self.iter_bytes(lsb0) |bytes| {
-                wr.write(bytes)
-            }
+            do self.iter_bytes(lsb0) |bytes| {
+                wr.write(bytes);
+                true
+            };
         }
     }
 }
diff --git a/src/libstd/trie.rs b/src/libstd/trie.rs
index 704e3a500f1..f60093ce48c 100644
--- a/src/libstd/trie.rs
+++ b/src/libstd/trie.rs
@@ -459,11 +459,12 @@ mod test_map {
         assert!(m.insert(1, 2));
 
         let mut n = 0;
-        for m.each |k, v| {
+        do m.each |k, v| {
             assert_eq!(*k, n);
             assert_eq!(*v, n * 2);
             n += 1;
-        }
+            true
+        };
     }
 
     #[test]
@@ -475,14 +476,16 @@ mod test_map {
         }
 
         let mut n = uint::max_value - 10000;
-        for m.each |k, v| {
-            if n == uint::max_value - 5000 { break }
-            assert!(n < uint::max_value - 5000);
-
-            assert_eq!(*k, n);
-            assert_eq!(*v, n / 2);
-            n += 1;
-        }
+        do m.each |k, v| {
+            if n == uint::max_value - 5000 { false } else {
+                assert!(n < uint::max_value - 5000);
+
+                assert_eq!(*k, n);
+                assert_eq!(*v, n / 2);
+                n += 1;
+                true
+            }
+        };
     }
 
     #[test]
@@ -496,11 +499,12 @@ mod test_map {
         assert!(m.insert(1, 2));
 
         let mut n = 4;
-        for m.each_reverse |k, v| {
+        do m.each_reverse |k, v| {
             assert_eq!(*k, n);
             assert_eq!(*v, n * 2);
             n -= 1;
-        }
+            true
+        };
     }
 
     #[test]
@@ -512,14 +516,16 @@ mod test_map {
         }
 
         let mut n = uint::max_value - 1;
-        for m.each_reverse |k, v| {
-            if n == uint::max_value - 5000 { break }
-            assert!(n > uint::max_value - 5000);
-
-            assert_eq!(*k, n);
-            assert_eq!(*v, n / 2);
-            n -= 1;
-        }
+        do m.each_reverse |k, v| {
+            if n == uint::max_value - 5000 { false } else {
+                assert!(n > uint::max_value - 5000);
+
+                assert_eq!(*k, n);
+                assert_eq!(*v, n / 2);
+                n -= 1;
+                true
+            }
+        };
     }
 
     #[test]
@@ -572,10 +578,11 @@ mod test_set {
 
         let mut i = 0;
 
-        for trie.each |x| {
+        do trie.each |x| {
             assert_eq!(expected[i], *x);
             i += 1;
-        }
+            true
+        };
     }
 
     #[test]
diff --git a/src/libstd/unstable/extfmt.rs b/src/libstd/unstable/extfmt.rs
index a8cdd1fb2dc..5417af50081 100644
--- a/src/libstd/unstable/extfmt.rs
+++ b/src/libstd/unstable/extfmt.rs
@@ -636,7 +636,7 @@ pub mod rt {
                 buf.push_char(c);
             }
             buf.push_str(s);
-            for diff.times {
+            do diff.times {
                 buf.push_char(padchar);
             }
             return;
diff --git a/src/libstd/unstable/sync.rs b/src/libstd/unstable/sync.rs
index e865d3a467d..f5c82bad2b1 100644
--- a/src/libstd/unstable/sync.rs
+++ b/src/libstd/unstable/sync.rs
@@ -626,7 +626,7 @@ mod tests {
             let x = Exclusive::new(~~"hello");
             let x2 = x.clone();
             do task::spawn {
-                for 10.times { task::yield(); } // try to let the unwrapper go
+                do 10.times { task::yield(); } // try to let the unwrapper go
                 fail!(); // punt it awake from its deadlock
             }
             let _z = x.unwrap();
diff --git a/src/libstd/vec.rs b/src/libstd/vec.rs
index 534dc27196c..6cff9ce84cf 100644
--- a/src/libstd/vec.rs
+++ b/src/libstd/vec.rs
@@ -2767,19 +2767,19 @@ mod tests {
         let mut results: ~[~[int]];
 
         results = ~[];
-        for each_permutation([]) |v| { results.push(v.to_owned()); }
+        do each_permutation([]) |v| { results.push(v.to_owned()); true };
         assert_eq!(results, ~[~[]]);
 
         results = ~[];
-        for each_permutation([7]) |v| { results.push(v.to_owned()); }
+        do each_permutation([7]) |v| { results.push(v.to_owned()); true };
         assert_eq!(results, ~[~[7]]);
 
         results = ~[];
-        for each_permutation([1,1]) |v| { results.push(v.to_owned()); }
+        do each_permutation([1,1]) |v| { results.push(v.to_owned()); true };
         assert_eq!(results, ~[~[1,1],~[1,1]]);
 
         results = ~[];
-        for each_permutation([5,2,0]) |v| { results.push(v.to_owned()); }
+        do each_permutation([5,2,0]) |v| { results.push(v.to_owned()); true };
         assert!(results ==
             ~[~[5,2,0],~[5,0,2],~[2,5,0],~[2,0,5],~[0,5,2],~[0,2,5]]);
     }
@@ -3107,12 +3107,13 @@ mod tests {
     fn test_permute_fail() {
         let v = [(~0, @0), (~0, @0), (~0, @0), (~0, @0)];
         let mut i = 0;
-        for each_permutation(v) |_elt| {
+        do each_permutation(v) |_elt| {
             if i == 2 {
                 fail!()
             }
             i += 0;
-        }
+            true
+        };
     }
 
     #[test]
@@ -3425,9 +3426,10 @@ mod tests {
     fn test_permutations0() {
         let values = [];
         let mut v : ~[~[int]] = ~[];
-        for each_permutation(values) |p| {
+        do each_permutation(values) |p| {
             v.push(p.to_owned());
-        }
+            true
+        };
         assert_eq!(v, ~[~[]]);
     }
 
@@ -3435,9 +3437,10 @@ mod tests {
     fn test_permutations1() {
         let values = [1];
         let mut v : ~[~[int]] = ~[];
-        for each_permutation(values) |p| {
+        do each_permutation(values) |p| {
             v.push(p.to_owned());
-        }
+            true
+        };
         assert_eq!(v, ~[~[1]]);
     }
 
@@ -3445,9 +3448,10 @@ mod tests {
     fn test_permutations2() {
         let values = [1,2];
         let mut v : ~[~[int]] = ~[];
-        for each_permutation(values) |p| {
+        do each_permutation(values) |p| {
             v.push(p.to_owned());
-        }
+            true
+        };
         assert_eq!(v, ~[~[1,2],~[2,1]]);
     }
 
@@ -3455,9 +3459,10 @@ mod tests {
     fn test_permutations3() {
         let values = [1,2,3];
         let mut v : ~[~[int]] = ~[];
-        for each_permutation(values) |p| {
+        do each_permutation(values) |p| {
             v.push(p.to_owned());
-        }
+            true
+        };
         assert_eq!(v, ~[~[1,2,3],~[1,3,2],~[2,1,3],~[2,3,1],~[3,1,2],~[3,2,1]]);
     }