Skip to content

Commit 20899db

Browse files
Initialize the cursor with an empty state
1 parent c68d710 commit 20899db

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/librustc_mir/dataflow/framework/cursor.rs

+10-4
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,20 @@ where
4141
A: Analysis<'tcx>,
4242
R: Borrow<Results<'tcx, A>>,
4343
{
44-
/// Returns a new cursor for `results` that points to the entry of the `START_BLOCK`.
44+
/// Returns a new cursor that can inspect `results`.
4545
pub fn new(body: &'mir mir::Body<'tcx>, results: R) -> Self {
46+
let bits_per_block = results.borrow().entry_set_for_block(mir::START_BLOCK).domain_size();
47+
4648
ResultsCursor {
4749
body,
48-
pos: CursorPosition::block_entry(mir::START_BLOCK),
49-
state: results.borrow().entry_set_for_block(mir::START_BLOCK).clone(),
50-
state_needs_reset: false,
5150
results,
51+
52+
// Initialize to an empty `BitSet` and set `state_needs_reset` to tell the cursor that
53+
// it needs to reset to block entry before the first seek. The cursor position is
54+
// immaterial.
55+
state_needs_reset: true,
56+
state: BitSet::new_empty(bits_per_block),
57+
pos: CursorPosition::block_entry(mir::START_BLOCK),
5258
}
5359
}
5460

0 commit comments

Comments
 (0)