diff options
| author | bors <bors@rust-lang.org> | 2014-07-09 23:51:27 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2014-07-09 23:51:27 +0000 |
| commit | 1b8e671d748407a377da04f389518cd981418d2c (patch) | |
| tree | 27d36b78119308f4095479684be5db5188f7a576 | |
| parent | 942c72e1179bc2d3d351ea97235d65b39160cc18 (diff) | |
| parent | 5d39d0befaa567e1a438d6b0151390052931094c (diff) | |
| download | rust-1b8e671d748407a377da04f389518cd981418d2c.tar.gz rust-1b8e671d748407a377da04f389518cd981418d2c.zip | |
auto merge of #15514 : luqmana/rust/die-advance-die, r=cmr
Closes #15492.
| -rw-r--r-- | src/libcollections/bitv.rs | 44 | ||||
| -rw-r--r-- | src/libcollections/treemap.rs | 8 | ||||
| -rw-r--r-- | src/libcore/iter.rs | 3 | ||||
| -rw-r--r-- | src/libgetopts/lib.rs | 2 | ||||
| -rw-r--r-- | src/librustc/middle/graph.rs | 4 | ||||
| -rw-r--r-- | src/librustc/middle/resolve.rs | 2 | ||||
| -rw-r--r-- | src/librustc/middle/ty.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax/abi.rs | 17 | ||||
| -rw-r--r-- | src/libsyntax/ast_util.rs | 10 | ||||
| -rw-r--r-- | src/test/compile-fail/liveness-issue-2163.rs | 2 | ||||
| -rw-r--r-- | src/test/run-pass/assignability-trait.rs | 4 | ||||
| -rw-r--r-- | src/test/run-pass/borrowck-mut-uniq.rs | 2 |
12 files changed, 32 insertions, 70 deletions
diff --git a/src/libcollections/bitv.rs b/src/libcollections/bitv.rs index 905c27ee82c..23be65cc4e2 100644 --- a/src/libcollections/bitv.rs +++ b/src/libcollections/bitv.rs @@ -1426,18 +1426,14 @@ mod tests { fn test_small_clear() { let mut b = Bitv::with_capacity(14, true); b.clear(); - BitvSet::from_bitv(b).iter().advance(|i| { - fail!("found 1 at {:?}", i) - }); + assert!(b.none()); } #[test] fn test_big_clear() { let mut b = Bitv::with_capacity(140, true); b.clear(); - BitvSet::from_bitv(b).iter().advance(|i| { - fail!("found 1 at {:?}", i) - }); + assert!(b.none()); } #[test] @@ -1494,14 +1490,9 @@ mod tests { assert!(b.insert(5)); assert!(b.insert(3)); - let mut i = 0; let expected = [3, 5, 11, 77]; - a.intersection(&b).advance(|x| { - assert_eq!(x, expected[i]); - i += 1; - true - }); - assert_eq!(i, expected.len()); + let actual = a.intersection(&b).collect::<Vec<uint>>(); + assert_eq!(actual.as_slice(), expected.as_slice()); } #[test] @@ -1518,14 +1509,9 @@ mod tests { assert!(b.insert(3)); assert!(b.insert(200)); - let mut i = 0; let expected = [1, 5, 500]; - a.difference(&b).advance(|x| { - assert_eq!(x, expected[i]); - i += 1; - true - }); - assert_eq!(i, expected.len()); + let actual = a.difference(&b).collect::<Vec<uint>>(); + assert_eq!(actual.as_slice(), expected.as_slice()); } #[test] @@ -1544,14 +1530,9 @@ mod tests { assert!(b.insert(14)); assert!(b.insert(220)); - let mut i = 0; let expected = [1, 5, 11, 14, 220]; - a.symmetric_difference(&b).advance(|x| { - assert_eq!(x, expected[i]); - i += 1; - true - }); - assert_eq!(i, expected.len()); + let actual = a.symmetric_difference(&b).collect::<Vec<uint>>(); + assert_eq!(actual.as_slice(), expected.as_slice()); } #[test] @@ -1573,14 +1554,9 @@ mod tests { assert!(b.insert(13)); assert!(b.insert(19)); - let mut i = 0; let expected = [1, 3, 5, 9, 11, 13, 19, 24, 160]; - a.union(&b).advance(|x| { - assert_eq!(x, expected[i]); - i += 1; - true - }); - assert_eq!(i, expected.len()); + let actual = a.union(&b).collect::<Vec<uint>>(); + assert_eq!(actual.as_slice(), expected.as_slice()); } #[test] diff --git a/src/libcollections/treemap.rs b/src/libcollections/treemap.rs index e0242af3c99..1451bf9d7c7 100644 --- a/src/libcollections/treemap.rs +++ b/src/libcollections/treemap.rs @@ -1770,7 +1770,7 @@ mod test_set { #[test] fn test_intersection() { fn check_intersection(a: &[int], b: &[int], expected: &[int]) { - check(a, b, expected, |x, y, f| x.intersection(y).advance(f)) + check(a, b, expected, |x, y, f| x.intersection(y).all(f)) } check_intersection([], [], []); @@ -1786,7 +1786,7 @@ mod test_set { #[test] fn test_difference() { fn check_difference(a: &[int], b: &[int], expected: &[int]) { - check(a, b, expected, |x, y, f| x.difference(y).advance(f)) + check(a, b, expected, |x, y, f| x.difference(y).all(f)) } check_difference([], [], []); @@ -1804,7 +1804,7 @@ mod test_set { fn test_symmetric_difference() { fn check_symmetric_difference(a: &[int], b: &[int], expected: &[int]) { - check(a, b, expected, |x, y, f| x.symmetric_difference(y).advance(f)) + check(a, b, expected, |x, y, f| x.symmetric_difference(y).all(f)) } check_symmetric_difference([], [], []); @@ -1819,7 +1819,7 @@ mod test_set { fn test_union() { fn check_union(a: &[int], b: &[int], expected: &[int]) { - check(a, b, expected, |x, y, f| x.union(y).advance(f)) + check(a, b, expected, |x, y, f| x.union(y).all(f)) } check_union([], [], []); diff --git a/src/libcore/iter.rs b/src/libcore/iter.rs index 5895d871dbe..77795a33352 100644 --- a/src/libcore/iter.rs +++ b/src/libcore/iter.rs @@ -435,9 +435,10 @@ pub trait Iterator<A> { /// /// # Example /// - /// ```rust + /// ```rust,ignore /// range(0u, 5).advance(|x| {print!("{} ", x); true}); /// ``` + #[deprecated = "use the `all` method instead"] #[inline] fn advance(&mut self, f: |A| -> bool) -> bool { loop { diff --git a/src/libgetopts/lib.rs b/src/libgetopts/lib.rs index bb3e90958f1..23f16be1659 100644 --- a/src/libgetopts/lib.rs +++ b/src/libgetopts/lib.rs @@ -896,7 +896,7 @@ fn each_split_within<'a>(ss: &'a str, lim: uint, it: |&'a str| -> bool) *cont }; - ss.char_indices().advance(|x| machine(&mut cont, x)); + ss.char_indices().all(|x| machine(&mut cont, x)); // Let the automaton 'run out' by supplying trailing whitespace while cont && match state { B | C => true, A => false } { diff --git a/src/librustc/middle/graph.rs b/src/librustc/middle/graph.rs index b1f9b0bff9f..78eeb26997d 100644 --- a/src/librustc/middle/graph.rs +++ b/src/librustc/middle/graph.rs @@ -207,12 +207,12 @@ impl<N,E> Graph<N,E> { pub fn each_node<'a>(&'a self, f: |NodeIndex, &'a Node<N>| -> bool) -> bool { //! Iterates over all edges defined in the graph. - self.nodes.iter().enumerate().advance(|(i, node)| f(NodeIndex(i), node)) + self.nodes.iter().enumerate().all(|(i, node)| f(NodeIndex(i), node)) } pub fn each_edge<'a>(&'a self, f: |EdgeIndex, &'a Edge<E>| -> bool) -> bool { //! Iterates over all edges defined in the graph - self.edges.iter().enumerate().advance(|(i, edge)| f(EdgeIndex(i), edge)) + self.edges.iter().enumerate().all(|(i, edge)| f(EdgeIndex(i), edge)) } pub fn each_outgoing_edge<'a>(&'a self, diff --git a/src/librustc/middle/resolve.rs b/src/librustc/middle/resolve.rs index 129a5b7c6be..4655507f5d1 100644 --- a/src/librustc/middle/resolve.rs +++ b/src/librustc/middle/resolve.rs @@ -5149,7 +5149,7 @@ impl<'a> Resolver<'a> { } _ => { let mut method_scope = false; - self.value_ribs.borrow().iter().rev().advance(|rib| { + self.value_ribs.borrow().iter().rev().all(|rib| { let res = match *rib { Rib { bindings: _, kind: MethodRibKind(_, _) } => true, Rib { bindings: _, kind: ItemRibKind } => false, diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs index f9eda70d16e..eee53b79763 100644 --- a/src/librustc/middle/ty.rs +++ b/src/librustc/middle/ty.rs @@ -3887,13 +3887,13 @@ pub fn lookup_trait_def(cx: &ctxt, did: ast::DefId) -> Rc<ty::TraitDef> { pub fn each_attr(tcx: &ctxt, did: DefId, f: |&ast::Attribute| -> bool) -> bool { if is_local(did) { let item = tcx.map.expect_item(did.node); - item.attrs.iter().advance(|attr| f(attr)) + item.attrs.iter().all(|attr| f(attr)) } else { info!("getting foreign attrs"); let mut cont = true; csearch::get_item_attrs(&tcx.sess.cstore, did, |attrs| { if cont { - cont = attrs.iter().advance(|attr| f(attr)); + cont = attrs.iter().all(|attr| f(attr)); } }); info!("done"); diff --git a/src/libsyntax/abi.rs b/src/libsyntax/abi.rs index 5aaf7ed3dba..8b01002831b 100644 --- a/src/libsyntax/abi.rs +++ b/src/libsyntax/abi.rs @@ -87,24 +87,9 @@ static AbiDatas: &'static [AbiData] = &[ AbiData {abi: RustIntrinsic, name: "rust-intrinsic", abi_arch: RustArch}, ]; -/// Iterates through each of the defined ABIs. -fn each_abi(op: |abi: Abi| -> bool) -> bool { - AbiDatas.iter().advance(|abi_data| op(abi_data.abi)) -} - /// Returns the ABI with the given name (if any). pub fn lookup(name: &str) -> Option<Abi> { - let mut res = None; - - each_abi(|abi| { - if name == abi.data().name { - res = Some(abi); - false - } else { - true - } - }); - res + AbiDatas.iter().find(|abi_data| name == abi_data.name).map(|&x| x.abi) } pub fn all_names() -> Vec<&'static str> { diff --git a/src/libsyntax/ast_util.rs b/src/libsyntax/ast_util.rs index 13fe8a15064..cd38c9b3e98 100644 --- a/src/libsyntax/ast_util.rs +++ b/src/libsyntax/ast_util.rs @@ -611,18 +611,18 @@ pub fn walk_pat(pat: &Pat, it: |&Pat| -> bool) -> bool { match pat.node { PatIdent(_, _, Some(ref p)) => walk_pat(&**p, it), PatStruct(_, ref fields, _) => { - fields.iter().advance(|f| walk_pat(&*f.pat, |p| it(p))) + fields.iter().all(|field| walk_pat(&*field.pat, |p| it(p))) } PatEnum(_, Some(ref s)) | PatTup(ref s) => { - s.iter().advance(|p| walk_pat(&**p, |p| it(p))) + s.iter().all(|p| walk_pat(&**p, |p| it(p))) } PatBox(ref s) | PatRegion(ref s) => { walk_pat(&**s, it) } PatVec(ref before, ref slice, ref after) => { - before.iter().advance(|p| walk_pat(&**p, |p| it(p))) && - slice.iter().advance(|p| walk_pat(&**p, |p| it(p))) && - after.iter().advance(|p| walk_pat(&**p, |p| it(p))) + before.iter().all(|p| walk_pat(&**p, |p| it(p))) && + slice.iter().all(|p| walk_pat(&**p, |p| it(p))) && + after.iter().all(|p| walk_pat(&**p, |p| it(p))) } PatMac(_) => fail!("attempted to analyze unexpanded pattern"), PatWild | PatWildMulti | PatLit(_) | PatRange(_, _) | PatIdent(_, _, _) | diff --git a/src/test/compile-fail/liveness-issue-2163.rs b/src/test/compile-fail/liveness-issue-2163.rs index 4bfa614063b..e46d00c4ab9 100644 --- a/src/test/compile-fail/liveness-issue-2163.rs +++ b/src/test/compile-fail/liveness-issue-2163.rs @@ -12,7 +12,7 @@ use std::vec::Vec; fn main() { let a: Vec<int> = Vec::new(); - a.iter().advance(|_| -> bool { + a.iter().all(|_| -> bool { //~^ ERROR mismatched types }); } diff --git a/src/test/run-pass/assignability-trait.rs b/src/test/run-pass/assignability-trait.rs index dddec5a5624..1ffee6aad76 100644 --- a/src/test/run-pass/assignability-trait.rs +++ b/src/test/run-pass/assignability-trait.rs @@ -19,13 +19,13 @@ trait iterable<A> { impl<'a,A> iterable<A> for &'a [A] { fn iterate(&self, f: |x: &A| -> bool) -> bool { - self.iter().advance(f) + self.iter().all(f) } } impl<A> iterable<A> for Vec<A> { fn iterate(&self, f: |x: &A| -> bool) -> bool { - self.iter().advance(f) + self.iter().all(f) } } diff --git a/src/test/run-pass/borrowck-mut-uniq.rs b/src/test/run-pass/borrowck-mut-uniq.rs index 1bf29fb3482..c0be4abafbe 100644 --- a/src/test/run-pass/borrowck-mut-uniq.rs +++ b/src/test/run-pass/borrowck-mut-uniq.rs @@ -24,7 +24,7 @@ fn add_int(x: &mut Ints, v: int) { fn iter_ints(x: &Ints, f: |x: &int| -> bool) -> bool { let l = x.values.len(); - range(0u, l).advance(|i| f(x.values.get(i))) + range(0u, l).all(|i| f(x.values.get(i))) } pub fn main() { |
