Skip to content

Commit cecef13

Browse files
committed
Simplify ResultsHandle.
The `Borrowed` variant is no longer used. This commit removes it, along with the `as_results_cursor` method that produces it, and renames `as_results_cursor_mut` as `as_results_cursor`.
1 parent 9f2f690 commit cecef13

File tree

4 files changed

+4
-18
lines changed

4 files changed

+4
-18
lines changed

compiler/rustc_mir_dataflow/src/framework/cursor.rs

-5
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ pub enum ResultsHandle<'a, 'tcx, A>
1515
where
1616
A: Analysis<'tcx>,
1717
{
18-
Borrowed(&'a Results<'tcx, A>),
1918
BorrowedMut(&'a mut Results<'tcx, A>),
2019
Owned(Results<'tcx, A>),
2120
}
@@ -28,7 +27,6 @@ where
2827

2928
fn deref(&self) -> &Results<'tcx, A> {
3029
match self {
31-
ResultsHandle::Borrowed(borrowed) => borrowed,
3230
ResultsHandle::BorrowedMut(borrowed) => borrowed,
3331
ResultsHandle::Owned(owned) => owned,
3432
}
@@ -41,9 +39,6 @@ where
4139
{
4240
fn deref_mut(&mut self) -> &mut Results<'tcx, A> {
4341
match self {
44-
ResultsHandle::Borrowed(_borrowed) => {
45-
panic!("tried to deref_mut a `ResultsHandle::Borrowed")
46-
}
4742
ResultsHandle::BorrowedMut(borrowed) => borrowed,
4843
ResultsHandle::Owned(owned) => owned,
4944
}

compiler/rustc_mir_dataflow/src/framework/graphviz.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ where
5151
style: OutputStyle,
5252
) -> Self {
5353
let reachable = mir::traversal::reachable_as_bitset(body);
54-
Formatter { cursor: results.as_results_cursor_mut(body).into(), style, reachable }
54+
Formatter { cursor: results.as_results_cursor(body).into(), style, reachable }
5555
}
5656

5757
fn body(&self) -> &'mir Body<'tcx> {

compiler/rustc_mir_dataflow/src/framework/results.rs

+2-11
Original file line numberDiff line numberDiff line change
@@ -37,18 +37,9 @@ impl<'tcx, A> Results<'tcx, A>
3737
where
3838
A: Analysis<'tcx>,
3939
{
40-
/// Creates a `ResultsCursor` that can inspect these `Results`. Immutably borrows the `Results`,
41-
/// which is appropriate when the `Results` is used outside the cursor.
40+
/// Creates a `ResultsCursor` that mutably borrows the `Results`, which is appropriate when the
41+
/// `Results` is also used outside the cursor.
4242
pub fn as_results_cursor<'mir>(
43-
&'mir self,
44-
body: &'mir mir::Body<'tcx>,
45-
) -> ResultsCursor<'mir, 'tcx, A> {
46-
ResultsCursor::new(body, ResultsHandle::Borrowed(self))
47-
}
48-
49-
/// Creates a `ResultsCursor` that can mutate these `Results`. Mutably borrows the `Results`,
50-
/// which is appropriate when the `Results` is used outside the cursor.
51-
pub fn as_results_cursor_mut<'mir>(
5243
&'mir mut self,
5344
body: &'mir mir::Body<'tcx>,
5445
) -> ResultsCursor<'mir, 'tcx, A> {

compiler/rustc_mir_transform/src/coroutine.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -680,7 +680,7 @@ fn locals_live_across_suspend_points<'tcx>(
680680
let mut requires_storage_results =
681681
MaybeRequiresStorage::new(borrowed_locals_results.into_results_cursor(body))
682682
.iterate_to_fixpoint(tcx, body, None);
683-
let mut requires_storage_cursor = requires_storage_results.as_results_cursor_mut(body);
683+
let mut requires_storage_cursor = requires_storage_results.as_results_cursor(body);
684684

685685
// Calculate the liveness of MIR locals ignoring borrows.
686686
let mut liveness =

0 commit comments

Comments
 (0)