diff --git a/src/libcollectionstest/binary_heap.rs b/src/libcollectionstest/binary_heap.rs index faabcf4c372..9cd63d87931 100644 --- a/src/libcollectionstest/binary_heap.rs +++ b/src/libcollectionstest/binary_heap.rs @@ -299,5 +299,7 @@ fn test_extend_specialization() { #[allow(dead_code)] fn assert_covariance() { - fn drain<'new>(d: Drain<'static, &'static str>) -> Drain<'new, &'new str> { d } + fn drain<'new>(d: Drain<'static, &'static str>) -> Drain<'new, &'new str> { + d + } } diff --git a/src/libcollectionstest/btree/map.rs b/src/libcollectionstest/btree/map.rs index 49fce68d15e..8222da105cc 100644 --- a/src/libcollectionstest/btree/map.rs +++ b/src/libcollectionstest/btree/map.rs @@ -533,9 +533,7 @@ create_append_test!(test_append_1700, 1700); fn rand_data(len: usize) -> Vec<(u32, u32)> { let mut rng = DeterministicRng::new(); - Vec::from_iter( - (0..len).map(|_| (rng.next(), rng.next())) - ) + Vec::from_iter((0..len).map(|_| (rng.next(), rng.next()))) } #[test] diff --git a/src/libcollectionstest/btree/mod.rs b/src/libcollectionstest/btree/mod.rs index ea43f423b7c..ae8b18d0c9f 100644 --- a/src/libcollectionstest/btree/mod.rs +++ b/src/libcollectionstest/btree/mod.rs @@ -25,7 +25,7 @@ impl DeterministicRng { x: 0x193a6754, y: 0xa8a7d469, z: 0x97830e05, - w: 0x113ba7bb + w: 0x113ba7bb, } } diff --git a/src/libcollectionstest/btree/set.rs b/src/libcollectionstest/btree/set.rs index a32e3f1a76a..6171b8ba624 100644 --- a/src/libcollectionstest/btree/set.rs +++ b/src/libcollectionstest/btree/set.rs @@ -15,45 +15,51 @@ use super::DeterministicRng; #[test] fn test_clone_eq() { - let mut m = BTreeSet::new(); + let mut m = BTreeSet::new(); - m.insert(1); - m.insert(2); + m.insert(1); + m.insert(2); - assert!(m.clone() == m); + assert!(m.clone() == m); } #[test] fn test_hash() { - let mut x = BTreeSet::new(); - let mut y = BTreeSet::new(); + let mut x = BTreeSet::new(); + let mut y = BTreeSet::new(); - x.insert(1); - x.insert(2); - x.insert(3); + x.insert(1); + x.insert(2); + x.insert(3); - y.insert(3); - y.insert(2); - y.insert(1); + y.insert(3); + y.insert(2); + y.insert(1); - assert!(::hash(&x) == ::hash(&y)); + assert!(::hash(&x) == ::hash(&y)); } -fn check<F>(a: &[i32], b: &[i32], expected: &[i32], f: F) where - F: FnOnce(&BTreeSet<i32>, &BTreeSet<i32>, &mut FnMut(&i32) -> bool) -> bool, +fn check<F>(a: &[i32], b: &[i32], expected: &[i32], f: F) + where F: FnOnce(&BTreeSet<i32>, &BTreeSet<i32>, &mut FnMut(&i32) -> bool) -> bool { let mut set_a = BTreeSet::new(); let mut set_b = BTreeSet::new(); - for x in a { assert!(set_a.insert(*x)) } - for y in b { assert!(set_b.insert(*y)) } + for x in a { + assert!(set_a.insert(*x)) + } + for y in b { + assert!(set_b.insert(*y)) + } let mut i = 0; - f(&set_a, &set_b, &mut |&x| { - assert_eq!(x, expected[i]); - i += 1; - true - }); + f(&set_a, + &set_b, + &mut |&x| { + assert_eq!(x, expected[i]); + i += 1; + true + }); assert_eq!(i, expected.len()); } @@ -82,9 +88,7 @@ fn test_difference() { check_difference(&[], &[], &[]); check_difference(&[1, 12], &[], &[1, 12]); check_difference(&[], &[1, 2, 3, 9], &[]); - check_difference(&[1, 3, 5, 9, 11], - &[3, 9], - &[1, 5, 11]); + check_difference(&[1, 3, 5, 9, 11], &[3, 9], &[1, 5, 11]); check_difference(&[-5, 11, 22, 33, 40, 42], &[-12, -5, 14, 23, 34, 38, 39, 50], &[11, 22, 33, 40, 42]); @@ -245,10 +249,18 @@ fn test_recovery() { fn test_variance() { use std::collections::btree_set::{IntoIter, Iter, Range}; - fn set<'new>(v: BTreeSet<&'static str>) -> BTreeSet<&'new str> { v } - fn iter<'a, 'new>(v: Iter<'a, &'static str>) -> Iter<'a, &'new str> { v } - fn into_iter<'new>(v: IntoIter<&'static str>) -> IntoIter<&'new str> { v } - fn range<'a, 'new>(v: Range<'a, &'static str>) -> Range<'a, &'new str> { v } + fn set<'new>(v: BTreeSet<&'static str>) -> BTreeSet<&'new str> { + v + } + fn iter<'a, 'new>(v: Iter<'a, &'static str>) -> Iter<'a, &'new str> { + v + } + fn into_iter<'new>(v: IntoIter<&'static str>) -> IntoIter<&'new str> { + v + } + fn range<'a, 'new>(v: Range<'a, &'static str>) -> Range<'a, &'new str> { + v + } } #[test] @@ -277,9 +289,7 @@ fn test_append() { fn rand_data(len: usize) -> Vec<u32> { let mut rng = DeterministicRng::new(); - Vec::from_iter( - (0..len).map(|_| rng.next()) - ) + Vec::from_iter((0..len).map(|_| rng.next())) } #[test] diff --git a/src/libcollectionstest/lib.rs b/src/libcollectionstest/lib.rs index 88fb6540a9a..5d3e03c2dee 100644 --- a/src/libcollectionstest/lib.rs +++ b/src/libcollectionstest/lib.rs @@ -36,7 +36,9 @@ extern crate rustc_unicode; use std::hash::{Hash, Hasher}; use std::collections::hash_map::DefaultHasher; -#[cfg(test)] #[macro_use] mod bench; +#[cfg(test)] +#[macro_use] +mod bench; mod binary_heap; mod btree; diff --git a/src/libcollectionstest/slice.rs b/src/libcollectionstest/slice.rs index 130c16d7c15..a6230ef471c 100644 --- a/src/libcollectionstest/slice.rs +++ b/src/libcollectionstest/slice.rs @@ -420,12 +420,12 @@ fn test_sort_stability() { // number this element is, i.e. the second elements // will occur in sorted order. let mut v: Vec<_> = (0..len) - .map(|_| { - let n = thread_rng().gen::<usize>() % 10; - counts[n] += 1; - (n, counts[n]) - }) - .collect(); + .map(|_| { + let n = thread_rng().gen::<usize>() % 10; + counts[n] += 1; + (n, counts[n]) + }) + .collect(); // only sort on the first element, so an unstable sort // may mix up the counts. @@ -1116,13 +1116,13 @@ fn test_box_slice_clone_panics() { }; spawn(move || { - // When xs is dropped, +5. - let xs = vec![canary.clone(), canary.clone(), canary.clone(), panic, canary] - .into_boxed_slice(); + // When xs is dropped, +5. + let xs = vec![canary.clone(), canary.clone(), canary.clone(), panic, canary] + .into_boxed_slice(); - // When panic is cloned, +3. - xs.clone(); - }) + // When panic is cloned, +3. + xs.clone(); + }) .join() .unwrap_err(); @@ -1374,8 +1374,8 @@ mod bench { let mut rng = thread_rng(); b.iter(|| { let mut v = rng.gen_iter::<BigSortable>() - .take(5) - .collect::<Vec<BigSortable>>(); + .take(5) + .collect::<Vec<BigSortable>>(); v.sort(); }); b.bytes = 5 * mem::size_of::<BigSortable>() as u64; @@ -1386,8 +1386,8 @@ mod bench { let mut rng = thread_rng(); b.iter(|| { let mut v = rng.gen_iter::<BigSortable>() - .take(100) - .collect::<Vec<BigSortable>>(); + .take(100) + .collect::<Vec<BigSortable>>(); v.sort(); }); b.bytes = 100 * mem::size_of::<BigSortable>() as u64; @@ -1398,8 +1398,8 @@ mod bench { let mut rng = thread_rng(); b.iter(|| { let mut v = rng.gen_iter::<BigSortable>() - .take(10000) - .collect::<Vec<BigSortable>>(); + .take(10000) + .collect::<Vec<BigSortable>>(); v.sort(); }); b.bytes = 10000 * mem::size_of::<BigSortable>() as u64; diff --git a/src/libcollectionstest/vec.rs b/src/libcollectionstest/vec.rs index 9a04673d1da..3bc1321d756 100644 --- a/src/libcollectionstest/vec.rs +++ b/src/libcollectionstest/vec.rs @@ -607,8 +607,12 @@ fn test_from_cow() { #[allow(dead_code)] fn assert_covariance() { - fn drain<'new>(d: Drain<'static, &'static str>) -> Drain<'new, &'new str> { d } - fn into_iter<'new>(i: IntoIter<&'static str>) -> IntoIter<&'new str> { i } + fn drain<'new>(d: Drain<'static, &'static str>) -> Drain<'new, &'new str> { + d + } + fn into_iter<'new>(i: IntoIter<&'static str>) -> IntoIter<&'new str> { + i + } } #[bench] diff --git a/src/libcollectionstest/vec_deque.rs b/src/libcollectionstest/vec_deque.rs index 9dfd3430268..f1ea85a6c5b 100644 --- a/src/libcollectionstest/vec_deque.rs +++ b/src/libcollectionstest/vec_deque.rs @@ -686,9 +686,9 @@ fn test_show() { assert_eq!(format!("{:?}", ringbuf), "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]"); let ringbuf: VecDeque<_> = vec!["just", "one", "test", "more"] - .iter() - .cloned() - .collect(); + .iter() + .cloned() + .collect(); assert_eq!(format!("{:?}", ringbuf), "[\"just\", \"one\", \"test\", \"more\"]"); } @@ -1003,5 +1003,7 @@ fn test_contains() { #[allow(dead_code)] fn assert_covariance() { - fn drain<'new>(d: Drain<'static, &'static str>) -> Drain<'new, &'new str> { d } + fn drain<'new>(d: Drain<'static, &'static str>) -> Drain<'new, &'new str> { + d + } }