Skip to content

Commit f69a099

Browse files
committed
Remove IdxSet::elems
1 parent 89d1247 commit f69a099

File tree

3 files changed

+11
-39
lines changed

3 files changed

+11
-39
lines changed

src/librustc_data_structures/indexed_set.rs

-26
Original file line numberDiff line numberDiff line change
@@ -224,32 +224,6 @@ impl<T: Idx> IdxSet<T> {
224224
_pd: PhantomData,
225225
}
226226
}
227-
228-
pub fn elems(&self, universe_size: usize) -> Elems<T> {
229-
Elems { i: 0, set: self, universe_size: universe_size }
230-
}
231-
}
232-
233-
pub struct Elems<'a, T: Idx> { i: usize, set: &'a IdxSet<T>, universe_size: usize }
234-
235-
impl<'a, T: Idx> Iterator for Elems<'a, T> {
236-
type Item = T;
237-
fn next(&mut self) -> Option<T> {
238-
if self.i >= self.universe_size { return None; }
239-
let mut i = self.i;
240-
loop {
241-
if i >= self.universe_size {
242-
self.i = i; // (mark iteration as complete.)
243-
return None;
244-
}
245-
if self.set.contains(&T::new(i)) {
246-
self.i = i + 1; // (next element to start at.)
247-
return Some(T::new(i));
248-
}
249-
i = i + 1;
250-
}
251-
}
252-
}
253227
}
254228

255229
pub struct Iter<'a, T: Idx> {

src/librustc_mir/borrow_check/mod.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,7 @@ impl<'cx, 'gcx, 'tcx> DataflowResultsConsumer<'cx, 'tcx> for MirBorrowckCtxt<'cx
555555
// Look for any active borrows to locals
556556
let domain = flow_state.borrows.operator();
557557
let data = domain.borrows();
558-
flow_state.borrows.with_elems_outgoing(|borrows| {
558+
flow_state.borrows.with_iter_outgoing(|borrows| {
559559
for i in borrows {
560560
let borrow = &data[i.borrow_index()];
561561
self.check_for_local_borrow(borrow, span);
@@ -571,7 +571,7 @@ impl<'cx, 'gcx, 'tcx> DataflowResultsConsumer<'cx, 'tcx> for MirBorrowckCtxt<'cx
571571
// so this "extra check" serves as a kind of backup.
572572
let domain = flow_state.borrows.operator();
573573
let data = domain.borrows();
574-
flow_state.borrows.with_elems_outgoing(|borrows| {
574+
flow_state.borrows.with_iter_outgoing(|borrows| {
575575
for i in borrows {
576576
let borrow = &data[i.borrow_index()];
577577
let context = ContextKind::StorageDead.new(loc);
@@ -1310,7 +1310,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
13101310
place
13111311
);
13121312

1313-
for i in flow_state.ever_inits.elems_incoming() {
1313+
for i in flow_state.ever_inits.iter_incoming() {
13141314
let init = self.move_data.inits[i];
13151315
let init_place = &self.move_data.move_paths[init.path].place;
13161316
if self.places_conflict(&init_place, place, Deep) {
@@ -2155,8 +2155,8 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
21552155

21562156
// check for loan restricting path P being used. Accounts for
21572157
// borrows of P, P.a.b, etc.
2158-
let mut elems_incoming = flow_state.borrows.elems_incoming();
2159-
while let Some(i) = elems_incoming.next() {
2158+
let mut iter_incoming = flow_state.borrows.iter_incoming();
2159+
while let Some(i) = iter_incoming.next() {
21602160
let borrowed = &data[i.borrow_index()];
21612161

21622162
if self.places_conflict(&borrowed.borrowed_place, place, access) {

src/librustc_mir/dataflow/at_location.rs

+6-8
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
//! locations.
1313
1414
use rustc::mir::{BasicBlock, Location};
15-
use rustc_data_structures::indexed_set::{self, IdxSetBuf};
15+
use rustc_data_structures::indexed_set::{IdxSetBuf, Iter};
1616
use rustc_data_structures::indexed_vec::Idx;
1717

1818
use dataflow::{BitDenotation, BlockSets, DataflowResults};
@@ -117,23 +117,21 @@ where
117117
}
118118

119119
/// Returns an iterator over the elements present in the current state.
120-
pub fn elems_incoming(&self) -> iter::Peekable<indexed_set::Elems<BD::Idx>> {
121-
let univ = self.base_results.sets().bits_per_block();
122-
self.curr_state.elems(univ).peekable()
120+
pub fn iter_incoming(&self) -> iter::Peekable<Iter<BD::Idx>> {
121+
self.curr_state.iter().peekable()
123122
}
124123

125124
/// Creates a clone of the current state and applies the local
126125
/// effects to the clone (leaving the state of self intact).
127126
/// Invokes `f` with an iterator over the resulting state.
128-
pub fn with_elems_outgoing<F>(&self, f: F)
127+
pub fn with_iter_outgoing<F>(&self, f: F)
129128
where
130-
F: FnOnce(indexed_set::Elems<BD::Idx>),
129+
F: FnOnce(Iter<BD::Idx>),
131130
{
132131
let mut curr_state = self.curr_state.clone();
133132
curr_state.union(&self.stmt_gen);
134133
curr_state.subtract(&self.stmt_kill);
135-
let univ = self.base_results.sets().bits_per_block();
136-
f(curr_state.elems(univ));
134+
f(curr_state.iter());
137135
}
138136
}
139137

0 commit comments

Comments
 (0)