Skip to content

Commit 979aaaf

Browse files
committed
Auto merge of #32056 - nikomatsakis:rustfmt-data-structures, r=alexcrichton
2 parents 72d588a + 2529b73 commit 979aaaf

File tree

16 files changed

+453
-370
lines changed

16 files changed

+453
-370
lines changed

src/librustc_data_structures/bitvec.rs

+21-15
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
/// A very simple BitVector type.
1212
pub struct BitVector {
13-
data: Vec<u64>
13+
data: Vec<u64>,
1414
}
1515

1616
impl BitVector {
@@ -40,7 +40,9 @@ impl BitVector {
4040
for (i, j) in self.data.iter_mut().zip(&all.data) {
4141
let value = *i;
4242
*i = value | *j;
43-
if value != *i { changed = true; }
43+
if value != *i {
44+
changed = true;
45+
}
4446
}
4547
changed
4648
}
@@ -56,15 +58,15 @@ impl BitVector {
5658
BitVectorIter {
5759
iter: self.data.iter(),
5860
current: 0,
59-
idx: 0
61+
idx: 0,
6062
}
6163
}
6264
}
6365

6466
pub struct BitVectorIter<'a> {
6567
iter: ::std::slice::Iter<'a, u64>,
6668
current: u64,
67-
idx: usize
69+
idx: usize,
6870
}
6971

7072
impl<'a> Iterator for BitVectorIter<'a> {
@@ -108,7 +110,7 @@ impl BitMatrix {
108110
let u64s_per_elem = u64s(elements);
109111
BitMatrix {
110112
elements: elements,
111-
vector: vec![0; elements * u64s_per_elem]
113+
vector: vec![0; elements * u64s_per_elem],
112114
}
113115
}
114116

@@ -123,9 +125,9 @@ impl BitMatrix {
123125
let (start, _) = self.range(source);
124126
let (word, mask) = word_mask(target);
125127
let mut vector = &mut self.vector[..];
126-
let v1 = vector[start+word];
128+
let v1 = vector[start + word];
127129
let v2 = v1 | mask;
128-
vector[start+word] = v2;
130+
vector[start + word] = v2;
129131
v1 != v2
130132
}
131133

@@ -136,7 +138,7 @@ impl BitMatrix {
136138
pub fn contains(&self, source: usize, target: usize) -> bool {
137139
let (start, _) = self.range(source);
138140
let (word, mask) = word_mask(target);
139-
(self.vector[start+word] & mask) != 0
141+
(self.vector[start + word] & mask) != 0
140142
}
141143

142144
/// Returns those indices that are reachable from both `a` and
@@ -150,8 +152,12 @@ impl BitMatrix {
150152
for (base, (i, j)) in (a_start..a_end).zip(b_start..b_end).enumerate() {
151153
let mut v = self.vector[i] & self.vector[j];
152154
for bit in 0..64 {
153-
if v == 0 { break; }
154-
if v & 0x1 != 0 { result.push(base*64 + bit); }
155+
if v == 0 {
156+
break;
157+
}
158+
if v & 0x1 != 0 {
159+
result.push(base * 64 + bit);
160+
}
155161
v >>= 1;
156162
}
157163
}
@@ -170,9 +176,7 @@ impl BitMatrix {
170176
let (write_start, write_end) = self.range(write);
171177
let vector = &mut self.vector[..];
172178
let mut changed = false;
173-
for (read_index, write_index) in
174-
(read_start..read_end).zip(write_start..write_end)
175-
{
179+
for (read_index, write_index) in (read_start..read_end).zip(write_start..write_end) {
176180
let v1 = vector[write_index];
177181
let v2 = v1 | vector[read_index];
178182
vector[write_index] = v2;
@@ -204,7 +208,8 @@ fn bitvec_iter_works() {
204208
bitvec.insert(65);
205209
bitvec.insert(66);
206210
bitvec.insert(99);
207-
assert_eq!(bitvec.iter().collect::<Vec<_>>(), [1, 10, 19, 62, 63, 64, 65, 66, 99]);
211+
assert_eq!(bitvec.iter().collect::<Vec<_>>(),
212+
[1, 10, 19, 62, 63, 64, 65, 66, 99]);
208213
}
209214

210215
#[test]
@@ -217,7 +222,8 @@ fn bitvec_iter_works_2() {
217222
bitvec.insert(66);
218223
bitvec.insert(99);
219224
bitvec.insert(299);
220-
assert_eq!(bitvec.iter().collect::<Vec<_>>(), [1, 10, 19, 62, 66, 99, 299]);
225+
assert_eq!(bitvec.iter().collect::<Vec<_>>(),
226+
[1, 10, 19, 62, 66, 99, 299]);
221227

222228
}
223229

src/librustc_data_structures/fnv.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ pub struct FnvHasher(u64);
3636

3737
impl Default for FnvHasher {
3838
#[inline]
39-
fn default() -> FnvHasher { FnvHasher(0xcbf29ce484222325) }
39+
fn default() -> FnvHasher {
40+
FnvHasher(0xcbf29ce484222325)
41+
}
4042
}
4143

4244
impl Hasher for FnvHasher {
@@ -51,5 +53,7 @@ impl Hasher for FnvHasher {
5153
}
5254

5355
#[inline]
54-
fn finish(&self) -> u64 { self.0 }
56+
fn finish(&self) -> u64 {
57+
self.0
58+
}
5559
}

0 commit comments

Comments
 (0)