Skip to content

Commit 6a74615

Browse files
committed
Run rustfmt over bitvec.rs and region_infer/values.rs
1 parent aa3409c commit 6a74615

File tree

2 files changed

+52
-46
lines changed

2 files changed

+52
-46
lines changed

src/librustc_data_structures/bitvec.rs

+44-32
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ impl BitVector {
2727
#[inline]
2828
pub fn new(num_bits: usize) -> BitVector {
2929
let num_words = words(num_bits);
30-
BitVector { data: vec![0; num_words] }
30+
BitVector {
31+
data: vec![0; num_words],
32+
}
3133
}
3234

3335
#[inline]
@@ -133,7 +135,10 @@ impl<'a> Iterator for BitVectorIter<'a> {
133135
}
134136

135137
impl FromIterator<bool> for BitVector {
136-
fn from_iter<I>(iter: I) -> BitVector where I: IntoIterator<Item=bool> {
138+
fn from_iter<I>(iter: I) -> BitVector
139+
where
140+
I: IntoIterator<Item = bool>,
141+
{
137142
let iter = iter.into_iter();
138143
let (len, _) = iter.size_hint();
139144
// Make the minimum length for the bitvector WORD_BITS bits since that's
@@ -262,7 +267,11 @@ impl BitMatrix {
262267
}
263268

264269
#[derive(Clone, Debug)]
265-
pub struct SparseBitMatrix<R, C> where R: Idx, C: Idx {
270+
pub struct SparseBitMatrix<R, C>
271+
where
272+
R: Idx,
273+
C: Idx,
274+
{
266275
vector: IndexVec<R, SparseBitSet<C>>,
267276
}
268277

@@ -340,7 +349,7 @@ impl<I: Idx> SparseChunk<I> {
340349
SparseChunk {
341350
key,
342351
bits: 1 << (index % 128),
343-
_marker: PhantomData
352+
_marker: PhantomData,
344353
}
345354
}
346355

@@ -351,26 +360,28 @@ impl<I: Idx> SparseChunk<I> {
351360
pub fn iter(&self) -> impl Iterator<Item = I> {
352361
let base = self.key as usize * 128;
353362
let mut bits = self.bits;
354-
(0..128).map(move |i| {
355-
let current_bits = bits;
356-
bits >>= 1;
357-
(i, current_bits)
358-
}).take_while(|&(_, bits)| bits != 0)
359-
.filter_map(move |(i, bits)| {
360-
if (bits & 1) != 0 {
361-
Some(I::new(base + i))
362-
} else {
363-
None
364-
}
365-
})
363+
(0..128)
364+
.map(move |i| {
365+
let current_bits = bits;
366+
bits >>= 1;
367+
(i, current_bits)
368+
})
369+
.take_while(|&(_, bits)| bits != 0)
370+
.filter_map(move |(i, bits)| {
371+
if (bits & 1) != 0 {
372+
Some(I::new(base + i))
373+
} else {
374+
None
375+
}
376+
})
366377
}
367378
}
368379

369380
impl<I: Idx> SparseBitSet<I> {
370381
pub fn new() -> Self {
371382
SparseBitSet {
372383
chunk_bits: BTreeMap::new(),
373-
_marker: PhantomData
384+
_marker: PhantomData,
374385
}
375386
}
376387

@@ -380,7 +391,9 @@ impl<I: Idx> SparseBitSet<I> {
380391

381392
pub fn contains_chunk(&self, chunk: SparseChunk<I>) -> SparseChunk<I> {
382393
SparseChunk {
383-
bits: self.chunk_bits.get(&chunk.key).map_or(0, |bits| bits & chunk.bits),
394+
bits: self.chunk_bits
395+
.get(&chunk.key)
396+
.map_or(0, |bits| bits & chunk.bits),
384397
..chunk
385398
}
386399
}
@@ -415,7 +428,7 @@ impl<I: Idx> SparseBitSet<I> {
415428
}
416429
new_bits ^ old_bits
417430
}
418-
Entry::Vacant(_) => 0
431+
Entry::Vacant(_) => 0,
419432
};
420433
SparseChunk {
421434
bits: changed,
@@ -428,12 +441,10 @@ impl<I: Idx> SparseBitSet<I> {
428441
}
429442

430443
pub fn chunks<'a>(&'a self) -> impl Iterator<Item = SparseChunk<I>> + 'a {
431-
self.chunk_bits.iter().map(|(&key, &bits)| {
432-
SparseChunk {
433-
key,
434-
bits,
435-
_marker: PhantomData
436-
}
444+
self.chunk_bits.iter().map(|(&key, &bits)| SparseChunk {
445+
key,
446+
bits,
447+
_marker: PhantomData,
437448
})
438449
}
439450

@@ -478,11 +489,12 @@ fn bitvec_iter_works() {
478489
bitvec.insert(65);
479490
bitvec.insert(66);
480491
bitvec.insert(99);
481-
assert_eq!(bitvec.iter().collect::<Vec<_>>(),
482-
[1, 10, 19, 62, 63, 64, 65, 66, 99]);
492+
assert_eq!(
493+
bitvec.iter().collect::<Vec<_>>(),
494+
[1, 10, 19, 62, 63, 64, 65, 66, 99]
495+
);
483496
}
484497

485-
486498
#[test]
487499
fn bitvec_iter_works_2() {
488500
let mut bitvec = BitVector::new(319);
@@ -514,24 +526,24 @@ fn union_two_vecs() {
514526
#[test]
515527
fn grow() {
516528
let mut vec1 = BitVector::new(65);
517-
for index in 0 .. 65 {
529+
for index in 0..65 {
518530
assert!(vec1.insert(index));
519531
assert!(!vec1.insert(index));
520532
}
521533
vec1.grow(128);
522534

523535
// Check if the bits set before growing are still set
524-
for index in 0 .. 65 {
536+
for index in 0..65 {
525537
assert!(vec1.contains(index));
526538
}
527539

528540
// Check if the new bits are all un-set
529-
for index in 65 .. 128 {
541+
for index in 65..128 {
530542
assert!(!vec1.contains(index));
531543
}
532544

533545
// Check that we can set all new bits without running out of bounds
534-
for index in 65 .. 128 {
546+
for index in 65..128 {
535547
assert!(vec1.insert(index));
536548
assert!(!vec1.insert(index));
537549
}

src/librustc_mir/borrow_check/nll/region_infer/values.rs

+8-14
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,7 @@ impl RegionValueElements {
6969

7070
/// Iterates over the `RegionElementIndex` for all points in the CFG.
7171
pub(super) fn all_point_indices<'a>(&'a self) -> impl Iterator<Item = RegionElementIndex> + 'a {
72-
(0..self.num_points).map(move |i| {
73-
RegionElementIndex::new(i + self.num_universal_regions)
74-
})
72+
(0..self.num_points).map(move |i| RegionElementIndex::new(i + self.num_universal_regions))
7573
}
7674

7775
/// Iterates over the `RegionElementIndex` for all points in the CFG.
@@ -154,7 +152,6 @@ pub(super) enum RegionElement {
154152
UniversalRegion(RegionVid),
155153
}
156154

157-
158155
pub(super) trait ToElementIndex {
159156
fn to_element_index(self, elements: &RegionValueElements) -> RegionElementIndex;
160157
}
@@ -214,8 +211,10 @@ impl RegionValues {
214211

215212
Self {
216213
elements: elements.clone(),
217-
matrix: SparseBitMatrix::new(RegionVid::new(num_region_variables),
218-
RegionElementIndex::new(elements.num_elements())),
214+
matrix: SparseBitMatrix::new(
215+
RegionVid::new(num_region_variables),
216+
RegionElementIndex::new(elements.num_elements()),
217+
),
219218
causes: if track_causes.0 {
220219
Some(CauseMap::default())
221220
} else {
@@ -295,8 +294,7 @@ impl RegionValues {
295294
// complicate causal tracking though.
296295
debug!(
297296
"add_universal_regions_outlived_by(from_region={:?}, to_region={:?})",
298-
from_region,
299-
to_region
297+
from_region, to_region
300298
);
301299
let mut changed = false;
302300
for elem in self.elements.all_universal_region_indices() {
@@ -326,9 +324,7 @@ impl RegionValues {
326324
&'a self,
327325
r: RegionVid,
328326
) -> impl Iterator<Item = RegionElementIndex> + 'a {
329-
self.matrix
330-
.iter(r)
331-
.map(move |i| i)
327+
self.matrix.iter(r).map(move |i| i)
332328
}
333329

334330
/// Returns just the universal regions that are contained in a given region's value.
@@ -416,9 +412,7 @@ impl RegionValues {
416412
assert_eq!(location1.block, location2.block);
417413
str.push_str(&format!(
418414
"{:?}[{}..={}]",
419-
location1.block,
420-
location1.statement_index,
421-
location2.statement_index
415+
location1.block, location1.statement_index, location2.statement_index
422416
));
423417
}
424418
}

0 commit comments

Comments
 (0)