Skip to content

Commit b059ea8

Browse files
committed
Rename EntrySets as EntryStates.
"Set" doesn't make much sense here, we refer to domain values as "state" everywhere else. (This name confused me for a while.)
1 parent 2298104 commit b059ea8

File tree

5 files changed

+22
-21
lines changed

5 files changed

+22
-21
lines changed

compiler/rustc_borrowck/src/lib.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ use rustc_mir_dataflow::impls::{
4343
use rustc_mir_dataflow::move_paths::{
4444
InitIndex, InitLocation, LookupResult, MoveData, MoveOutIndex, MovePathIndex,
4545
};
46-
use rustc_mir_dataflow::{Analysis, EntrySets, Results, ResultsVisitor, visit_results};
46+
use rustc_mir_dataflow::{Analysis, EntryStates, Results, ResultsVisitor, visit_results};
4747
use rustc_session::lint::builtin::UNUSED_MUT;
4848
use rustc_span::{Span, Symbol};
4949
use smallvec::SmallVec;
@@ -426,14 +426,14 @@ fn get_flow_results<'a, 'tcx>(
426426
ever_inits: ever_inits.analysis,
427427
};
428428

429-
assert_eq!(borrows.entry_sets.len(), uninits.entry_sets.len());
430-
assert_eq!(borrows.entry_sets.len(), ever_inits.entry_sets.len());
431-
let entry_sets: EntrySets<'_, Borrowck<'_, '_>> =
432-
itertools::izip!(borrows.entry_sets, uninits.entry_sets, ever_inits.entry_sets)
429+
assert_eq!(borrows.entry_states.len(), uninits.entry_states.len());
430+
assert_eq!(borrows.entry_states.len(), ever_inits.entry_states.len());
431+
let entry_states: EntryStates<'_, Borrowck<'_, '_>> =
432+
itertools::izip!(borrows.entry_states, uninits.entry_states, ever_inits.entry_states)
433433
.map(|(borrows, uninits, ever_inits)| BorrowckDomain { borrows, uninits, ever_inits })
434434
.collect();
435435

436-
Results { analysis, entry_sets }
436+
Results { analysis, entry_states }
437437
}
438438

439439
pub(crate) struct BorrowckInferCtxt<'tcx> {

compiler/rustc_mir_dataflow/src/framework/mod.rs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ mod visitor;
5656
pub use self::cursor::ResultsCursor;
5757
pub use self::direction::{Backward, Direction, Forward};
5858
pub use self::lattice::{JoinSemiLattice, MaybeReachable};
59-
pub use self::results::{EntrySets, Results};
59+
pub use self::results::{EntryStates, Results};
6060
pub use self::visitor::{ResultsVisitor, visit_results};
6161

6262
/// Analysis domains are all bitsets of various kinds. This trait holds
@@ -234,11 +234,12 @@ pub trait Analysis<'tcx> {
234234
Self: Sized,
235235
Self::Domain: DebugWithContext<Self>,
236236
{
237-
let mut entry_sets =
237+
let mut entry_states =
238238
IndexVec::from_fn_n(|_| self.bottom_value(body), body.basic_blocks.len());
239-
self.initialize_start_block(body, &mut entry_sets[mir::START_BLOCK]);
239+
self.initialize_start_block(body, &mut entry_states[mir::START_BLOCK]);
240240

241-
if Self::Direction::IS_BACKWARD && entry_sets[mir::START_BLOCK] != self.bottom_value(body) {
241+
if Self::Direction::IS_BACKWARD && entry_states[mir::START_BLOCK] != self.bottom_value(body)
242+
{
242243
bug!("`initialize_start_block` is not yet supported for backward dataflow analyses");
243244
}
244245

@@ -262,9 +263,9 @@ pub trait Analysis<'tcx> {
262263
let mut state = self.bottom_value(body);
263264
while let Some(bb) = dirty_queue.pop() {
264265
// Set the state to the entry state of the block.
265-
// This is equivalent to `state = entry_sets[bb].clone()`,
266+
// This is equivalent to `state = entry_states[bb].clone()`,
266267
// but it saves an allocation, thus improving compile times.
267-
state.clone_from(&entry_sets[bb]);
268+
state.clone_from(&entry_states[bb]);
268269

269270
Self::Direction::apply_effects_in_block(
270271
&mut self,
@@ -273,15 +274,15 @@ pub trait Analysis<'tcx> {
273274
bb,
274275
&body[bb],
275276
|target: BasicBlock, state: &Self::Domain| {
276-
let set_changed = entry_sets[target].join(state);
277+
let set_changed = entry_states[target].join(state);
277278
if set_changed {
278279
dirty_queue.insert(target);
279280
}
280281
},
281282
);
282283
}
283284

284-
let mut results = Results { analysis: self, entry_sets };
285+
let mut results = Results { analysis: self, entry_states };
285286

286287
if tcx.sess.opts.unstable_opts.dump_mir_dataflow {
287288
let res = write_graphviz_results(tcx, body, &mut results, pass_name);

compiler/rustc_mir_dataflow/src/framework/results.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use crate::errors::{
1919
};
2020
use crate::framework::cursor::ResultsHandle;
2121

22-
pub type EntrySets<'tcx, A> = IndexVec<BasicBlock, <A as Analysis<'tcx>>::Domain>;
22+
pub type EntryStates<'tcx, A> = IndexVec<BasicBlock, <A as Analysis<'tcx>>::Domain>;
2323

2424
/// A dataflow analysis that has converged to fixpoint. It only holds the domain values at the
2525
/// entry of each basic block. Domain values in other parts of the block are recomputed on the fly
@@ -30,7 +30,7 @@ where
3030
A: Analysis<'tcx>,
3131
{
3232
pub analysis: A,
33-
pub entry_sets: EntrySets<'tcx, A>,
33+
pub entry_states: EntryStates<'tcx, A>,
3434
}
3535

3636
impl<'tcx, A> Results<'tcx, A>
@@ -56,7 +56,7 @@ where
5656

5757
/// Gets the dataflow state for the given block.
5858
pub fn entry_set_for_block(&self, block: BasicBlock) -> &A::Domain {
59-
&self.entry_sets[block]
59+
&self.entry_states[block]
6060
}
6161

6262
pub fn visit_with<'mir>(

compiler/rustc_mir_dataflow/src/framework/tests.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ fn mock_body<'tcx>() -> mir::Body<'tcx> {
7373
///
7474
/// The `102` in the block's entry set is derived from the basic block index and ensures that the
7575
/// expected state is unique across all basic blocks. Remember, it is generated by
76-
/// `mock_entry_sets`, not from actually running `MockAnalysis` to fixpoint.
76+
/// `mock_entry_states`, not from actually running `MockAnalysis` to fixpoint.
7777
struct MockAnalysis<'tcx, D> {
7878
body: &'tcx mir::Body<'tcx>,
7979
dir: PhantomData<D>,
@@ -90,7 +90,7 @@ impl<D: Direction> MockAnalysis<'_, D> {
9090
ret
9191
}
9292

93-
fn mock_entry_sets(&self) -> IndexVec<BasicBlock, BitSet<usize>> {
93+
fn mock_entry_states(&self) -> IndexVec<BasicBlock, BitSet<usize>> {
9494
let empty = self.bottom_value(self.body);
9595
let mut ret = IndexVec::from_elem(empty, &self.body.basic_blocks);
9696

@@ -249,7 +249,7 @@ fn test_cursor<D: Direction>(analysis: MockAnalysis<'_, D>) {
249249
let body = analysis.body;
250250

251251
let mut cursor =
252-
Results { entry_sets: analysis.mock_entry_sets(), analysis }.into_results_cursor(body);
252+
Results { entry_states: analysis.mock_entry_states(), analysis }.into_results_cursor(body);
253253

254254
cursor.allow_unreachable();
255255

compiler/rustc_mir_dataflow/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ pub use self::drop_flag_effects::{
1818
move_path_children_matching, on_all_children_bits, on_lookup_result_bits,
1919
};
2020
pub use self::framework::{
21-
Analysis, Backward, Direction, EntrySets, Forward, GenKill, JoinSemiLattice, MaybeReachable,
21+
Analysis, Backward, Direction, EntryStates, Forward, GenKill, JoinSemiLattice, MaybeReachable,
2222
Results, ResultsCursor, ResultsVisitor, SwitchIntEdgeEffects, fmt, graphviz, lattice,
2323
visit_results,
2424
};

0 commit comments

Comments
 (0)