about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2013-05-10 17:56:02 -0700
committerbors <bors@rust-lang.org>2013-05-10 17:56:02 -0700
commit3e0400fb86170baff30282edcdccff73e243fd6e (patch)
treeec7cc5de5ce7c80845c77fdcbb670cd54c120783 /src/test
parentd546493096f35e68cbcd9b5d3d7654e7a9345744 (diff)
parent606bd75586419948f109de313ab37e31397ca7a3 (diff)
downloadrust-3e0400fb86170baff30282edcdccff73e243fd6e.tar.gz
rust-3e0400fb86170baff30282edcdccff73e243fd6e.zip
auto merge of #6223 : alexcrichton/rust/issue-6183, r=pcwalton
Closes #6183.

The first commit changes the compiler's method of treating a `for` loop, and all the remaining commits are just dealing with the fallout.

The biggest fallout was the `IterBytes` trait, although it's really a whole lot nicer now because all of the `iter_bytes_XX` methods are just and-ed together. Sadly there was a huge amount of stuff that's `cfg(stage0)` gated, but whoever lands the next snapshot is going to have a lot of fun deleting all this code!

Diffstat (limited to 'src/test')
-rw-r--r--src/test/bench/graph500-bfs.rs7
-rw-r--r--src/test/compile-fail/bad-for-loop.rs1
-rw-r--r--src/test/compile-fail/borrowck-lend-flow-loop.rs2
-rw-r--r--src/test/compile-fail/issue-2817-2.rs2
-rw-r--r--src/test/compile-fail/issue-2817.rs4
-rw-r--r--src/test/compile-fail/issue-3651-2.rs2
-rw-r--r--src/test/compile-fail/issue-3651.rs1
-rw-r--r--src/test/compile-fail/private-method.rs2
-rw-r--r--src/test/run-pass/assignability-trait.rs14
-rw-r--r--src/test/run-pass/borrowck-mut-uniq.rs2
-rw-r--r--src/test/run-pass/class-impl-very-parameterized-trait.rs15
-rw-r--r--src/test/run-pass/do-for-empty-args.rs11
-rw-r--r--src/test/run-pass/do-for-no-args.rs2
-rw-r--r--src/test/run-pass/ret-break-cont-in-block.rs5
14 files changed, 34 insertions, 36 deletions
diff --git a/src/test/bench/graph500-bfs.rs b/src/test/bench/graph500-bfs.rs
index 1842a8ff42e..fb276723543 100644
--- a/src/test/bench/graph500-bfs.rs
+++ b/src/test/bench/graph500-bfs.rs
@@ -10,8 +10,6 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-#[allow(deprecated_mode)];
-
 /*!
 
 An implementation of the Graph500 Breadth First Search problem in Rust.
@@ -23,7 +21,7 @@ use std::arc;
 use std::time;
 use std::deque::Deque;
 use std::par;
-use core::hashmap::{HashMap, HashSet};
+use core::hashmap::HashSet;
 use core::int::abs;
 use core::rand::RngUtil;
 
@@ -83,14 +81,13 @@ fn make_graph(N: uint, edges: ~[(node_id, node_id)]) -> graph {
         HashSet::new()
     };
 
-    do vec::each(edges) |e| {
+    for vec::each(edges) |e| {
         match *e {
             (i, j) => {
                 graph[i].insert(j);
                 graph[j].insert(i);
             }
         }
-        true
     }
 
     do vec::map_consume(graph) |mut v| {
diff --git a/src/test/compile-fail/bad-for-loop.rs b/src/test/compile-fail/bad-for-loop.rs
index 8835c577fa8..7ff51eff8ee 100644
--- a/src/test/compile-fail/bad-for-loop.rs
+++ b/src/test/compile-fail/bad-for-loop.rs
@@ -11,4 +11,5 @@
 fn main() {
     fn baz(_x: &fn(y: int) -> int) {}
     for baz |_e| { } //~ ERROR A `for` loop iterator should expect a closure that returns `bool`
+                     //~^ ERROR expected `for` closure to return `bool`
 }
diff --git a/src/test/compile-fail/borrowck-lend-flow-loop.rs b/src/test/compile-fail/borrowck-lend-flow-loop.rs
index b6384ad9590..f7a72d6e610 100644
--- a/src/test/compile-fail/borrowck-lend-flow-loop.rs
+++ b/src/test/compile-fail/borrowck-lend-flow-loop.rs
@@ -17,7 +17,7 @@
 fn borrow(_v: &int) {}
 fn borrow_mut(_v: &mut int) {}
 fn cond() -> bool { fail!() }
-fn for_func(_f: &fn() -> bool) { fail!() }
+fn for_func(_f: &fn() -> bool) -> bool { fail!() }
 fn produce<T>() -> T { fail!(); }
 
 fn inc(v: &mut ~int) {
diff --git a/src/test/compile-fail/issue-2817-2.rs b/src/test/compile-fail/issue-2817-2.rs
index 6084552f0ed..17b0d88a6a8 100644
--- a/src/test/compile-fail/issue-2817-2.rs
+++ b/src/test/compile-fail/issue-2817-2.rs
@@ -8,7 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-fn not_bool(f: &fn(int) -> ~str) {}
+fn not_bool(f: &fn(int) -> ~str) -> bool {}
 
 fn main() {
     for uint::range(0, 100000) |_i| { //~ ERROR A for-loop body must return (), but
diff --git a/src/test/compile-fail/issue-2817.rs b/src/test/compile-fail/issue-2817.rs
index 8c28fcdc7fc..77585d15b6b 100644
--- a/src/test/compile-fail/issue-2817.rs
+++ b/src/test/compile-fail/issue-2817.rs
@@ -16,10 +16,10 @@ fn uuid_random() -> uint { fail!(); }
 
 fn main() {
     do uint::range(0, 100000) |_i| { //~ ERROR Do-block body must return bool, but
-    }
+    };
     // should get a more general message if the callback
     // doesn't return nil
     do uint::range(0, 100000) |_i| { //~ ERROR mismatched types
         ~"str"
-    }
+    };
 }
diff --git a/src/test/compile-fail/issue-3651-2.rs b/src/test/compile-fail/issue-3651-2.rs
index 2431313df63..98a02b6b746 100644
--- a/src/test/compile-fail/issue-3651-2.rs
+++ b/src/test/compile-fail/issue-3651-2.rs
@@ -9,5 +9,5 @@
 // except according to those terms.
 
 fn main() {
-    do 5.times {} //~ ERROR Do-block body must return bool, but returns () here. Perhaps
+    do 5.times {}; //~ ERROR Do-block body must return bool, but returns () here. Perhaps
 }
diff --git a/src/test/compile-fail/issue-3651.rs b/src/test/compile-fail/issue-3651.rs
index 38e9348155a..8d704859fe5 100644
--- a/src/test/compile-fail/issue-3651.rs
+++ b/src/test/compile-fail/issue-3651.rs
@@ -10,4 +10,5 @@
 
 fn main() {
     for task::spawn { return true; } //~ ERROR A `for` loop iterator should expect a closure that
+                                     //~^ ERROR expected `for` closure to return `bool`
 }
diff --git a/src/test/compile-fail/private-method.rs b/src/test/compile-fail/private-method.rs
index c918758ad7c..0d84bc2fc60 100644
--- a/src/test/compile-fail/private-method.rs
+++ b/src/test/compile-fail/private-method.rs
@@ -18,7 +18,7 @@ mod kitties {
     }
 
     pub impl cat {
-        priv fn nap(&self) { uint::range(1u, 10000u, |_i| false)}
+        priv fn nap(&self) { uint::range(1u, 10000u, |_i| false); }
     }
 
     pub fn cat(in_x : uint, in_y : int) -> cat {
diff --git a/src/test/run-pass/assignability-trait.rs b/src/test/run-pass/assignability-trait.rs
index c557aa7e223..6946ed3fbcf 100644
--- a/src/test/run-pass/assignability-trait.rs
+++ b/src/test/run-pass/assignability-trait.rs
@@ -13,22 +13,18 @@
 // it.
 
 trait iterable<A> {
-    fn iterate(&self, blk: &fn(x: &A) -> bool);
+    fn iterate(&self, blk: &fn(x: &A) -> bool) -> bool;
 }
 
 impl<'self,A> iterable<A> for &'self [A] {
-    fn iterate(&self, f: &fn(x: &A) -> bool) {
-        for vec::each(*self) |e| {
-            if !f(e) { break; }
-        }
+    fn iterate(&self, f: &fn(x: &A) -> bool) -> bool {
+        vec::each(*self, f)
     }
 }
 
 impl<A> iterable<A> for ~[A] {
-    fn iterate(&self, f: &fn(x: &A) -> bool) {
-        for vec::each(*self) |e| {
-            if !f(e) { break; }
-        }
+    fn iterate(&self, f: &fn(x: &A) -> bool) -> bool {
+        vec::each(*self, f)
     }
 }
 
diff --git a/src/test/run-pass/borrowck-mut-uniq.rs b/src/test/run-pass/borrowck-mut-uniq.rs
index 5f5b9c59d76..778637701c5 100644
--- a/src/test/run-pass/borrowck-mut-uniq.rs
+++ b/src/test/run-pass/borrowck-mut-uniq.rs
@@ -18,7 +18,7 @@ fn add_int(x: &mut Ints, v: int) {
     x.values <-> values;
 }
 
-fn iter_ints(x: &Ints, f: &fn(x: &int) -> bool) {
+fn iter_ints(x: &Ints, f: &fn(x: &int) -> bool) -> bool {
     let l = x.values.len();
     uint::range(0, l, |i| f(&x.values[i]))
 }
diff --git a/src/test/run-pass/class-impl-very-parameterized-trait.rs b/src/test/run-pass/class-impl-very-parameterized-trait.rs
index b89bf064092..39d4b25f262 100644
--- a/src/test/run-pass/class-impl-very-parameterized-trait.rs
+++ b/src/test/run-pass/class-impl-very-parameterized-trait.rs
@@ -59,25 +59,26 @@ impl<T> Mutable for cat<T> {
 }
 
 impl<T> Map<int, T> for cat<T> {
-    fn each<'a>(&'a self, f: &fn(&int, &'a T) -> bool) {
+    fn each<'a>(&'a self, f: &fn(&int, &'a T) -> bool) -> bool {
         let mut n = int::abs(self.meows);
         while n > 0 {
-            if !f(&n, &self.name) { break; }
+            if !f(&n, &self.name) { return false; }
             n -= 1;
         }
+        return true;
     }
 
     fn contains_key(&self, k: &int) -> bool { *k <= self.meows }
 
-    fn each_key(&self, f: &fn(v: &int) -> bool) {
-        for self.each |k, _| { if !f(k) { break; } loop;};
+    fn each_key(&self, f: &fn(v: &int) -> bool) -> bool {
+        self.each(|k, _| f(k))
     }
 
-    fn each_value<'a>(&'a self, f: &fn(v: &'a T) -> bool) {
-        for self.each |_, v| { if !f(v) { break; } loop;};
+    fn each_value<'a>(&'a self, f: &fn(v: &'a T) -> bool) -> bool {
+        self.each(|_, v| f(v))
     }
 
-    fn mutate_values(&mut self, _f: &fn(&int, &mut T) -> bool) {
+    fn mutate_values(&mut self, _f: &fn(&int, &mut T) -> bool) -> bool {
         fail!(~"nope")
     }
 
diff --git a/src/test/run-pass/do-for-empty-args.rs b/src/test/run-pass/do-for-empty-args.rs
index c86c1768111..fb1bc37fd5e 100644
--- a/src/test/run-pass/do-for-empty-args.rs
+++ b/src/test/run-pass/do-for-empty-args.rs
@@ -11,14 +11,15 @@
 // no-reformat
 // Testing various forms of `do` and `for` with empty arg lists
 
-fn f(f: &fn() -> bool) {
+fn f(f: &fn() -> bool) -> bool {
+    true
 }
 
 pub fn main() {
-    do f() || { true }
-    do f() { true }
-    do f || { true }
-    do f { true }
+    do f() || { true };
+    do f() { true };
+    do f || { true };
+    do f { true };
     for f() || { }
     for f() { }
     for f || { }
diff --git a/src/test/run-pass/do-for-no-args.rs b/src/test/run-pass/do-for-no-args.rs
index c89d693c816..e9d7c946a9a 100644
--- a/src/test/run-pass/do-for-no-args.rs
+++ b/src/test/run-pass/do-for-no-args.rs
@@ -10,7 +10,7 @@
 
 // Testing that we can drop the || in for/do exprs
 
-fn f(f: @fn() -> bool) { }
+fn f(f: @fn() -> bool) -> bool { true }
 
 fn d(f: @fn()) { }
 
diff --git a/src/test/run-pass/ret-break-cont-in-block.rs b/src/test/run-pass/ret-break-cont-in-block.rs
index ab61cee4223..1792a89d64f 100644
--- a/src/test/run-pass/ret-break-cont-in-block.rs
+++ b/src/test/run-pass/ret-break-cont-in-block.rs
@@ -12,12 +12,13 @@
 
 use core::cmp::Eq;
 
-fn iter<T>(v: ~[T], it: &fn(&T) -> bool) {
+fn iter<T>(v: ~[T], it: &fn(&T) -> bool) -> bool {
     let mut i = 0u, l = v.len();
     while i < l {
-        if !it(&v[i]) { break; }
+        if !it(&v[i]) { return false; }
         i += 1u;
     }
+    return true;
 }
 
 fn find_pos<T:Eq + Copy + Clone>(n: T, h: ~[T]) -> Option<uint> {