Skip to content

Commit 0da37c5

Browse files
authored
Auto merge of #37212 - srinivasreddy:libcollectionstest, r=nrc
run rustfmt on libcollectionstest
2 parents 5530030 + e820a86 commit 0da37c5

File tree

8 files changed

+80
-62
lines changed

8 files changed

+80
-62
lines changed

src/libcollectionstest/binary_heap.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -299,5 +299,7 @@ fn test_extend_specialization() {
299299

300300
#[allow(dead_code)]
301301
fn assert_covariance() {
302-
fn drain<'new>(d: Drain<'static, &'static str>) -> Drain<'new, &'new str> { d }
302+
fn drain<'new>(d: Drain<'static, &'static str>) -> Drain<'new, &'new str> {
303+
d
304+
}
303305
}

src/libcollectionstest/btree/map.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -533,9 +533,7 @@ create_append_test!(test_append_1700, 1700);
533533

534534
fn rand_data(len: usize) -> Vec<(u32, u32)> {
535535
let mut rng = DeterministicRng::new();
536-
Vec::from_iter(
537-
(0..len).map(|_| (rng.next(), rng.next()))
538-
)
536+
Vec::from_iter((0..len).map(|_| (rng.next(), rng.next())))
539537
}
540538

541539
#[test]

src/libcollectionstest/btree/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ impl DeterministicRng {
2525
x: 0x193a6754,
2626
y: 0xa8a7d469,
2727
z: 0x97830e05,
28-
w: 0x113ba7bb
28+
w: 0x113ba7bb,
2929
}
3030
}
3131

src/libcollectionstest/btree/set.rs

+42-32
Original file line numberDiff line numberDiff line change
@@ -15,45 +15,51 @@ use super::DeterministicRng;
1515

1616
#[test]
1717
fn test_clone_eq() {
18-
let mut m = BTreeSet::new();
18+
let mut m = BTreeSet::new();
1919

20-
m.insert(1);
21-
m.insert(2);
20+
m.insert(1);
21+
m.insert(2);
2222

23-
assert!(m.clone() == m);
23+
assert!(m.clone() == m);
2424
}
2525

2626
#[test]
2727
fn test_hash() {
28-
let mut x = BTreeSet::new();
29-
let mut y = BTreeSet::new();
28+
let mut x = BTreeSet::new();
29+
let mut y = BTreeSet::new();
3030

31-
x.insert(1);
32-
x.insert(2);
33-
x.insert(3);
31+
x.insert(1);
32+
x.insert(2);
33+
x.insert(3);
3434

35-
y.insert(3);
36-
y.insert(2);
37-
y.insert(1);
35+
y.insert(3);
36+
y.insert(2);
37+
y.insert(1);
3838

39-
assert!(::hash(&x) == ::hash(&y));
39+
assert!(::hash(&x) == ::hash(&y));
4040
}
4141

42-
fn check<F>(a: &[i32], b: &[i32], expected: &[i32], f: F) where
43-
F: FnOnce(&BTreeSet<i32>, &BTreeSet<i32>, &mut FnMut(&i32) -> bool) -> bool,
42+
fn check<F>(a: &[i32], b: &[i32], expected: &[i32], f: F)
43+
where F: FnOnce(&BTreeSet<i32>, &BTreeSet<i32>, &mut FnMut(&i32) -> bool) -> bool
4444
{
4545
let mut set_a = BTreeSet::new();
4646
let mut set_b = BTreeSet::new();
4747

48-
for x in a { assert!(set_a.insert(*x)) }
49-
for y in b { assert!(set_b.insert(*y)) }
48+
for x in a {
49+
assert!(set_a.insert(*x))
50+
}
51+
for y in b {
52+
assert!(set_b.insert(*y))
53+
}
5054

5155
let mut i = 0;
52-
f(&set_a, &set_b, &mut |&x| {
53-
assert_eq!(x, expected[i]);
54-
i += 1;
55-
true
56-
});
56+
f(&set_a,
57+
&set_b,
58+
&mut |&x| {
59+
assert_eq!(x, expected[i]);
60+
i += 1;
61+
true
62+
});
5763
assert_eq!(i, expected.len());
5864
}
5965

@@ -82,9 +88,7 @@ fn test_difference() {
8288
check_difference(&[], &[], &[]);
8389
check_difference(&[1, 12], &[], &[1, 12]);
8490
check_difference(&[], &[1, 2, 3, 9], &[]);
85-
check_difference(&[1, 3, 5, 9, 11],
86-
&[3, 9],
87-
&[1, 5, 11]);
91+
check_difference(&[1, 3, 5, 9, 11], &[3, 9], &[1, 5, 11]);
8892
check_difference(&[-5, 11, 22, 33, 40, 42],
8993
&[-12, -5, 14, 23, 34, 38, 39, 50],
9094
&[11, 22, 33, 40, 42]);
@@ -245,10 +249,18 @@ fn test_recovery() {
245249
fn test_variance() {
246250
use std::collections::btree_set::{IntoIter, Iter, Range};
247251

248-
fn set<'new>(v: BTreeSet<&'static str>) -> BTreeSet<&'new str> { v }
249-
fn iter<'a, 'new>(v: Iter<'a, &'static str>) -> Iter<'a, &'new str> { v }
250-
fn into_iter<'new>(v: IntoIter<&'static str>) -> IntoIter<&'new str> { v }
251-
fn range<'a, 'new>(v: Range<'a, &'static str>) -> Range<'a, &'new str> { v }
252+
fn set<'new>(v: BTreeSet<&'static str>) -> BTreeSet<&'new str> {
253+
v
254+
}
255+
fn iter<'a, 'new>(v: Iter<'a, &'static str>) -> Iter<'a, &'new str> {
256+
v
257+
}
258+
fn into_iter<'new>(v: IntoIter<&'static str>) -> IntoIter<&'new str> {
259+
v
260+
}
261+
fn range<'a, 'new>(v: Range<'a, &'static str>) -> Range<'a, &'new str> {
262+
v
263+
}
252264
}
253265

254266
#[test]
@@ -277,9 +289,7 @@ fn test_append() {
277289

278290
fn rand_data(len: usize) -> Vec<u32> {
279291
let mut rng = DeterministicRng::new();
280-
Vec::from_iter(
281-
(0..len).map(|_| rng.next())
282-
)
292+
Vec::from_iter((0..len).map(|_| rng.next()))
283293
}
284294

285295
#[test]

src/libcollectionstest/lib.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ extern crate rustc_unicode;
3636
use std::hash::{Hash, Hasher};
3737
use std::collections::hash_map::DefaultHasher;
3838

39-
#[cfg(test)] #[macro_use] mod bench;
39+
#[cfg(test)]
40+
#[macro_use]
41+
mod bench;
4042

4143
mod binary_heap;
4244
mod btree;

src/libcollectionstest/slice.rs

+18-18
Original file line numberDiff line numberDiff line change
@@ -420,12 +420,12 @@ fn test_sort_stability() {
420420
// number this element is, i.e. the second elements
421421
// will occur in sorted order.
422422
let mut v: Vec<_> = (0..len)
423-
.map(|_| {
424-
let n = thread_rng().gen::<usize>() % 10;
425-
counts[n] += 1;
426-
(n, counts[n])
427-
})
428-
.collect();
423+
.map(|_| {
424+
let n = thread_rng().gen::<usize>() % 10;
425+
counts[n] += 1;
426+
(n, counts[n])
427+
})
428+
.collect();
429429

430430
// only sort on the first element, so an unstable sort
431431
// may mix up the counts.
@@ -1116,13 +1116,13 @@ fn test_box_slice_clone_panics() {
11161116
};
11171117

11181118
spawn(move || {
1119-
// When xs is dropped, +5.
1120-
let xs = vec![canary.clone(), canary.clone(), canary.clone(), panic, canary]
1121-
.into_boxed_slice();
1119+
// When xs is dropped, +5.
1120+
let xs = vec![canary.clone(), canary.clone(), canary.clone(), panic, canary]
1121+
.into_boxed_slice();
11221122

1123-
// When panic is cloned, +3.
1124-
xs.clone();
1125-
})
1123+
// When panic is cloned, +3.
1124+
xs.clone();
1125+
})
11261126
.join()
11271127
.unwrap_err();
11281128

@@ -1374,8 +1374,8 @@ mod bench {
13741374
let mut rng = thread_rng();
13751375
b.iter(|| {
13761376
let mut v = rng.gen_iter::<BigSortable>()
1377-
.take(5)
1378-
.collect::<Vec<BigSortable>>();
1377+
.take(5)
1378+
.collect::<Vec<BigSortable>>();
13791379
v.sort();
13801380
});
13811381
b.bytes = 5 * mem::size_of::<BigSortable>() as u64;
@@ -1386,8 +1386,8 @@ mod bench {
13861386
let mut rng = thread_rng();
13871387
b.iter(|| {
13881388
let mut v = rng.gen_iter::<BigSortable>()
1389-
.take(100)
1390-
.collect::<Vec<BigSortable>>();
1389+
.take(100)
1390+
.collect::<Vec<BigSortable>>();
13911391
v.sort();
13921392
});
13931393
b.bytes = 100 * mem::size_of::<BigSortable>() as u64;
@@ -1398,8 +1398,8 @@ mod bench {
13981398
let mut rng = thread_rng();
13991399
b.iter(|| {
14001400
let mut v = rng.gen_iter::<BigSortable>()
1401-
.take(10000)
1402-
.collect::<Vec<BigSortable>>();
1401+
.take(10000)
1402+
.collect::<Vec<BigSortable>>();
14031403
v.sort();
14041404
});
14051405
b.bytes = 10000 * mem::size_of::<BigSortable>() as u64;

src/libcollectionstest/vec.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -607,8 +607,12 @@ fn test_from_cow() {
607607

608608
#[allow(dead_code)]
609609
fn assert_covariance() {
610-
fn drain<'new>(d: Drain<'static, &'static str>) -> Drain<'new, &'new str> { d }
611-
fn into_iter<'new>(i: IntoIter<&'static str>) -> IntoIter<&'new str> { i }
610+
fn drain<'new>(d: Drain<'static, &'static str>) -> Drain<'new, &'new str> {
611+
d
612+
}
613+
fn into_iter<'new>(i: IntoIter<&'static str>) -> IntoIter<&'new str> {
614+
i
615+
}
612616
}
613617

614618
#[bench]

src/libcollectionstest/vec_deque.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -686,9 +686,9 @@ fn test_show() {
686686
assert_eq!(format!("{:?}", ringbuf), "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]");
687687

688688
let ringbuf: VecDeque<_> = vec!["just", "one", "test", "more"]
689-
.iter()
690-
.cloned()
691-
.collect();
689+
.iter()
690+
.cloned()
691+
.collect();
692692
assert_eq!(format!("{:?}", ringbuf),
693693
"[\"just\", \"one\", \"test\", \"more\"]");
694694
}
@@ -1003,5 +1003,7 @@ fn test_contains() {
10031003

10041004
#[allow(dead_code)]
10051005
fn assert_covariance() {
1006-
fn drain<'new>(d: Drain<'static, &'static str>) -> Drain<'new, &'new str> { d }
1006+
fn drain<'new>(d: Drain<'static, &'static str>) -> Drain<'new, &'new str> {
1007+
d
1008+
}
10071009
}

0 commit comments

Comments
 (0)