Skip to content

Commit 56be2af

Browse files
committed
Remove Iter and SparseIter in indexed_set.rs.
Because they're just thin wrappers around `BitIter` and `slice::Iter`.
1 parent b697409 commit 56be2af

File tree

3 files changed

+13
-40
lines changed

3 files changed

+13
-40
lines changed

src/librustc_data_structures/indexed_set.rs

+7-35
Original file line numberDiff line numberDiff line change
@@ -138,10 +138,8 @@ impl<T: Idx> IdxSet<T> {
138138
bitwise(self.words_mut(), other.words(), &Intersect)
139139
}
140140

141-
pub fn iter(&self) -> Iter<T> {
142-
Iter {
143-
iter: self.0.iter()
144-
}
141+
pub fn iter(&self) -> BitIter<T> {
142+
self.0.iter()
145143
}
146144
}
147145

@@ -157,18 +155,6 @@ impl<T: Idx> SubtractFromIdxSet<T> for IdxSet<T> {
157155
}
158156
}
159157

160-
pub struct Iter<'a, T: Idx> {
161-
iter: BitIter<'a, T>
162-
}
163-
164-
impl<'a, T: Idx> Iterator for Iter<'a, T> {
165-
type Item = T;
166-
167-
fn next(&mut self) -> Option<T> {
168-
self.iter.next()
169-
}
170-
}
171-
172158
const SPARSE_MAX: usize = 8;
173159

174160
/// A sparse index set with a maximum of SPARSE_MAX elements. Used by
@@ -221,10 +207,8 @@ impl<T: Idx> SparseIdxSet<T> {
221207
dense
222208
}
223209

224-
fn iter(&self) -> SparseIter<T> {
225-
SparseIter {
226-
iter: self.0.iter(),
227-
}
210+
fn iter(&self) -> slice::Iter<T> {
211+
self.0.iter()
228212
}
229213
}
230214

@@ -248,18 +232,6 @@ impl<T: Idx> SubtractFromIdxSet<T> for SparseIdxSet<T> {
248232
}
249233
}
250234

251-
pub struct SparseIter<'a, T: Idx> {
252-
iter: slice::Iter<'a, T>,
253-
}
254-
255-
impl<'a, T: Idx> Iterator for SparseIter<'a, T> {
256-
type Item = T;
257-
258-
fn next(&mut self) -> Option<T> {
259-
self.iter.next().map(|e| *e)
260-
}
261-
}
262-
263235
/// Like IdxSet, but with a hybrid representation: sparse when there are few
264236
/// elements in the set, but dense when there are many. It's especially
265237
/// efficient for sets that typically have a small number of elements, but a
@@ -370,16 +342,16 @@ impl<T: Idx> SubtractFromIdxSet<T> for HybridIdxSet<T> {
370342
}
371343

372344
pub enum HybridIter<'a, T: Idx> {
373-
Sparse(SparseIter<'a, T>),
374-
Dense(Iter<'a, T>),
345+
Sparse(slice::Iter<'a, T>),
346+
Dense(BitIter<'a, T>),
375347
}
376348

377349
impl<'a, T: Idx> Iterator for HybridIter<'a, T> {
378350
type Item = T;
379351

380352
fn next(&mut self) -> Option<T> {
381353
match self {
382-
HybridIter::Sparse(sparse) => sparse.next(),
354+
HybridIter::Sparse(sparse) => sparse.next().map(|e| *e),
383355
HybridIter::Dense(dense) => dense.next(),
384356
}
385357
}

src/librustc_mir/borrow_check/flows.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
1616
use rustc::mir::{BasicBlock, Location};
1717
use rustc::ty::RegionVid;
18-
use rustc_data_structures::indexed_set::Iter;
18+
use rustc_data_structures::bitvec::BitIter;
1919

2020
use borrow_check::location::LocationIndex;
2121

@@ -67,7 +67,7 @@ impl<'b, 'gcx, 'tcx> Flows<'b, 'gcx, 'tcx> {
6767
}
6868
}
6969

70-
crate fn with_outgoing_borrows(&self, op: impl FnOnce(Iter<BorrowIndex>)) {
70+
crate fn with_outgoing_borrows(&self, op: impl FnOnce(BitIter<BorrowIndex>)) {
7171
self.borrows.with_iter_outgoing(op)
7272
}
7373
}

src/librustc_mir/dataflow/at_location.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
//! locations.
1313
1414
use rustc::mir::{BasicBlock, Location};
15-
use rustc_data_structures::indexed_set::{HybridIdxSet, IdxSet, Iter};
15+
use rustc_data_structures::bitvec::BitIter;
16+
use rustc_data_structures::indexed_set::{HybridIdxSet, IdxSet};
1617

1718
use dataflow::{BitDenotation, BlockSets, DataflowResults};
1819
use dataflow::move_paths::{HasMoveData, MovePathIndex};
@@ -125,7 +126,7 @@ where
125126
}
126127

127128
/// Returns an iterator over the elements present in the current state.
128-
pub fn iter_incoming(&self) -> iter::Peekable<Iter<BD::Idx>> {
129+
pub fn iter_incoming(&self) -> iter::Peekable<BitIter<BD::Idx>> {
129130
self.curr_state.iter().peekable()
130131
}
131132

@@ -134,7 +135,7 @@ where
134135
/// Invokes `f` with an iterator over the resulting state.
135136
pub fn with_iter_outgoing<F>(&self, f: F)
136137
where
137-
F: FnOnce(Iter<BD::Idx>),
138+
F: FnOnce(BitIter<BD::Idx>),
138139
{
139140
let mut curr_state = self.curr_state.clone();
140141
curr_state.union(&self.stmt_gen);

0 commit comments

Comments
 (0)