Skip to content

Commit 1b8e671

Browse files
committed
auto merge of #15514 : luqmana/rust/die-advance-die, r=cmr
Closes #15492.
2 parents 942c72e + 5d39d0b commit 1b8e671

File tree

12 files changed

+32
-70
lines changed

12 files changed

+32
-70
lines changed

src/libcollections/bitv.rs

Lines changed: 10 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1426,18 +1426,14 @@ mod tests {
14261426
fn test_small_clear() {
14271427
let mut b = Bitv::with_capacity(14, true);
14281428
b.clear();
1429-
BitvSet::from_bitv(b).iter().advance(|i| {
1430-
fail!("found 1 at {:?}", i)
1431-
});
1429+
assert!(b.none());
14321430
}
14331431

14341432
#[test]
14351433
fn test_big_clear() {
14361434
let mut b = Bitv::with_capacity(140, true);
14371435
b.clear();
1438-
BitvSet::from_bitv(b).iter().advance(|i| {
1439-
fail!("found 1 at {:?}", i)
1440-
});
1436+
assert!(b.none());
14411437
}
14421438

14431439
#[test]
@@ -1494,14 +1490,9 @@ mod tests {
14941490
assert!(b.insert(5));
14951491
assert!(b.insert(3));
14961492

1497-
let mut i = 0;
14981493
let expected = [3, 5, 11, 77];
1499-
a.intersection(&b).advance(|x| {
1500-
assert_eq!(x, expected[i]);
1501-
i += 1;
1502-
true
1503-
});
1504-
assert_eq!(i, expected.len());
1494+
let actual = a.intersection(&b).collect::<Vec<uint>>();
1495+
assert_eq!(actual.as_slice(), expected.as_slice());
15051496
}
15061497

15071498
#[test]
@@ -1518,14 +1509,9 @@ mod tests {
15181509
assert!(b.insert(3));
15191510
assert!(b.insert(200));
15201511

1521-
let mut i = 0;
15221512
let expected = [1, 5, 500];
1523-
a.difference(&b).advance(|x| {
1524-
assert_eq!(x, expected[i]);
1525-
i += 1;
1526-
true
1527-
});
1528-
assert_eq!(i, expected.len());
1513+
let actual = a.difference(&b).collect::<Vec<uint>>();
1514+
assert_eq!(actual.as_slice(), expected.as_slice());
15291515
}
15301516

15311517
#[test]
@@ -1544,14 +1530,9 @@ mod tests {
15441530
assert!(b.insert(14));
15451531
assert!(b.insert(220));
15461532

1547-
let mut i = 0;
15481533
let expected = [1, 5, 11, 14, 220];
1549-
a.symmetric_difference(&b).advance(|x| {
1550-
assert_eq!(x, expected[i]);
1551-
i += 1;
1552-
true
1553-
});
1554-
assert_eq!(i, expected.len());
1534+
let actual = a.symmetric_difference(&b).collect::<Vec<uint>>();
1535+
assert_eq!(actual.as_slice(), expected.as_slice());
15551536
}
15561537

15571538
#[test]
@@ -1573,14 +1554,9 @@ mod tests {
15731554
assert!(b.insert(13));
15741555
assert!(b.insert(19));
15751556

1576-
let mut i = 0;
15771557
let expected = [1, 3, 5, 9, 11, 13, 19, 24, 160];
1578-
a.union(&b).advance(|x| {
1579-
assert_eq!(x, expected[i]);
1580-
i += 1;
1581-
true
1582-
});
1583-
assert_eq!(i, expected.len());
1558+
let actual = a.union(&b).collect::<Vec<uint>>();
1559+
assert_eq!(actual.as_slice(), expected.as_slice());
15841560
}
15851561

15861562
#[test]

src/libcollections/treemap.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1770,7 +1770,7 @@ mod test_set {
17701770
#[test]
17711771
fn test_intersection() {
17721772
fn check_intersection(a: &[int], b: &[int], expected: &[int]) {
1773-
check(a, b, expected, |x, y, f| x.intersection(y).advance(f))
1773+
check(a, b, expected, |x, y, f| x.intersection(y).all(f))
17741774
}
17751775

17761776
check_intersection([], [], []);
@@ -1786,7 +1786,7 @@ mod test_set {
17861786
#[test]
17871787
fn test_difference() {
17881788
fn check_difference(a: &[int], b: &[int], expected: &[int]) {
1789-
check(a, b, expected, |x, y, f| x.difference(y).advance(f))
1789+
check(a, b, expected, |x, y, f| x.difference(y).all(f))
17901790
}
17911791

17921792
check_difference([], [], []);
@@ -1804,7 +1804,7 @@ mod test_set {
18041804
fn test_symmetric_difference() {
18051805
fn check_symmetric_difference(a: &[int], b: &[int],
18061806
expected: &[int]) {
1807-
check(a, b, expected, |x, y, f| x.symmetric_difference(y).advance(f))
1807+
check(a, b, expected, |x, y, f| x.symmetric_difference(y).all(f))
18081808
}
18091809

18101810
check_symmetric_difference([], [], []);
@@ -1819,7 +1819,7 @@ mod test_set {
18191819
fn test_union() {
18201820
fn check_union(a: &[int], b: &[int],
18211821
expected: &[int]) {
1822-
check(a, b, expected, |x, y, f| x.union(y).advance(f))
1822+
check(a, b, expected, |x, y, f| x.union(y).all(f))
18231823
}
18241824

18251825
check_union([], [], []);

src/libcore/iter.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -435,9 +435,10 @@ pub trait Iterator<A> {
435435
///
436436
/// # Example
437437
///
438-
/// ```rust
438+
/// ```rust,ignore
439439
/// range(0u, 5).advance(|x| {print!("{} ", x); true});
440440
/// ```
441+
#[deprecated = "use the `all` method instead"]
441442
#[inline]
442443
fn advance(&mut self, f: |A| -> bool) -> bool {
443444
loop {

src/libgetopts/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -896,7 +896,7 @@ fn each_split_within<'a>(ss: &'a str, lim: uint, it: |&'a str| -> bool)
896896
*cont
897897
};
898898

899-
ss.char_indices().advance(|x| machine(&mut cont, x));
899+
ss.char_indices().all(|x| machine(&mut cont, x));
900900

901901
// Let the automaton 'run out' by supplying trailing whitespace
902902
while cont && match state { B | C => true, A => false } {

src/librustc/middle/graph.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,12 +207,12 @@ impl<N,E> Graph<N,E> {
207207

208208
pub fn each_node<'a>(&'a self, f: |NodeIndex, &'a Node<N>| -> bool) -> bool {
209209
//! Iterates over all edges defined in the graph.
210-
self.nodes.iter().enumerate().advance(|(i, node)| f(NodeIndex(i), node))
210+
self.nodes.iter().enumerate().all(|(i, node)| f(NodeIndex(i), node))
211211
}
212212

213213
pub fn each_edge<'a>(&'a self, f: |EdgeIndex, &'a Edge<E>| -> bool) -> bool {
214214
//! Iterates over all edges defined in the graph
215-
self.edges.iter().enumerate().advance(|(i, edge)| f(EdgeIndex(i), edge))
215+
self.edges.iter().enumerate().all(|(i, edge)| f(EdgeIndex(i), edge))
216216
}
217217

218218
pub fn each_outgoing_edge<'a>(&'a self,

src/librustc/middle/resolve.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5149,7 +5149,7 @@ impl<'a> Resolver<'a> {
51495149
}
51505150
_ => {
51515151
let mut method_scope = false;
5152-
self.value_ribs.borrow().iter().rev().advance(|rib| {
5152+
self.value_ribs.borrow().iter().rev().all(|rib| {
51535153
let res = match *rib {
51545154
Rib { bindings: _, kind: MethodRibKind(_, _) } => true,
51555155
Rib { bindings: _, kind: ItemRibKind } => false,

src/librustc/middle/ty.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3887,13 +3887,13 @@ pub fn lookup_trait_def(cx: &ctxt, did: ast::DefId) -> Rc<ty::TraitDef> {
38873887
pub fn each_attr(tcx: &ctxt, did: DefId, f: |&ast::Attribute| -> bool) -> bool {
38883888
if is_local(did) {
38893889
let item = tcx.map.expect_item(did.node);
3890-
item.attrs.iter().advance(|attr| f(attr))
3890+
item.attrs.iter().all(|attr| f(attr))
38913891
} else {
38923892
info!("getting foreign attrs");
38933893
let mut cont = true;
38943894
csearch::get_item_attrs(&tcx.sess.cstore, did, |attrs| {
38953895
if cont {
3896-
cont = attrs.iter().advance(|attr| f(attr));
3896+
cont = attrs.iter().all(|attr| f(attr));
38973897
}
38983898
});
38993899
info!("done");

src/libsyntax/abi.rs

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -87,24 +87,9 @@ static AbiDatas: &'static [AbiData] = &[
8787
AbiData {abi: RustIntrinsic, name: "rust-intrinsic", abi_arch: RustArch},
8888
];
8989

90-
/// Iterates through each of the defined ABIs.
91-
fn each_abi(op: |abi: Abi| -> bool) -> bool {
92-
AbiDatas.iter().advance(|abi_data| op(abi_data.abi))
93-
}
94-
9590
/// Returns the ABI with the given name (if any).
9691
pub fn lookup(name: &str) -> Option<Abi> {
97-
let mut res = None;
98-
99-
each_abi(|abi| {
100-
if name == abi.data().name {
101-
res = Some(abi);
102-
false
103-
} else {
104-
true
105-
}
106-
});
107-
res
92+
AbiDatas.iter().find(|abi_data| name == abi_data.name).map(|&x| x.abi)
10893
}
10994

11095
pub fn all_names() -> Vec<&'static str> {

src/libsyntax/ast_util.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -611,18 +611,18 @@ pub fn walk_pat(pat: &Pat, it: |&Pat| -> bool) -> bool {
611611
match pat.node {
612612
PatIdent(_, _, Some(ref p)) => walk_pat(&**p, it),
613613
PatStruct(_, ref fields, _) => {
614-
fields.iter().advance(|f| walk_pat(&*f.pat, |p| it(p)))
614+
fields.iter().all(|field| walk_pat(&*field.pat, |p| it(p)))
615615
}
616616
PatEnum(_, Some(ref s)) | PatTup(ref s) => {
617-
s.iter().advance(|p| walk_pat(&**p, |p| it(p)))
617+
s.iter().all(|p| walk_pat(&**p, |p| it(p)))
618618
}
619619
PatBox(ref s) | PatRegion(ref s) => {
620620
walk_pat(&**s, it)
621621
}
622622
PatVec(ref before, ref slice, ref after) => {
623-
before.iter().advance(|p| walk_pat(&**p, |p| it(p))) &&
624-
slice.iter().advance(|p| walk_pat(&**p, |p| it(p))) &&
625-
after.iter().advance(|p| walk_pat(&**p, |p| it(p)))
623+
before.iter().all(|p| walk_pat(&**p, |p| it(p))) &&
624+
slice.iter().all(|p| walk_pat(&**p, |p| it(p))) &&
625+
after.iter().all(|p| walk_pat(&**p, |p| it(p)))
626626
}
627627
PatMac(_) => fail!("attempted to analyze unexpanded pattern"),
628628
PatWild | PatWildMulti | PatLit(_) | PatRange(_, _) | PatIdent(_, _, _) |

src/test/compile-fail/liveness-issue-2163.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use std::vec::Vec;
1212

1313
fn main() {
1414
let a: Vec<int> = Vec::new();
15-
a.iter().advance(|_| -> bool {
15+
a.iter().all(|_| -> bool {
1616
//~^ ERROR mismatched types
1717
});
1818
}

src/test/run-pass/assignability-trait.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ trait iterable<A> {
1919

2020
impl<'a,A> iterable<A> for &'a [A] {
2121
fn iterate(&self, f: |x: &A| -> bool) -> bool {
22-
self.iter().advance(f)
22+
self.iter().all(f)
2323
}
2424
}
2525

2626
impl<A> iterable<A> for Vec<A> {
2727
fn iterate(&self, f: |x: &A| -> bool) -> bool {
28-
self.iter().advance(f)
28+
self.iter().all(f)
2929
}
3030
}
3131

src/test/run-pass/borrowck-mut-uniq.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ fn add_int(x: &mut Ints, v: int) {
2424

2525
fn iter_ints(x: &Ints, f: |x: &int| -> bool) -> bool {
2626
let l = x.values.len();
27-
range(0u, l).advance(|i| f(x.values.get(i)))
27+
range(0u, l).all(|i| f(x.values.get(i)))
2828
}
2929

3030
pub fn main() {

0 commit comments

Comments
 (0)