1
Fork 0

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`.
This commit is contained in:
Nicholas Nethercote 2024-12-02 10:58:27 +11:00
parent 9f2f6906ff
commit cecef131a2
4 changed files with 4 additions and 18 deletions

View file

@ -15,7 +15,6 @@ pub enum ResultsHandle<'a, 'tcx, A>
where where
A: Analysis<'tcx>, A: Analysis<'tcx>,
{ {
Borrowed(&'a Results<'tcx, A>),
BorrowedMut(&'a mut Results<'tcx, A>), BorrowedMut(&'a mut Results<'tcx, A>),
Owned(Results<'tcx, A>), Owned(Results<'tcx, A>),
} }
@ -28,7 +27,6 @@ where
fn deref(&self) -> &Results<'tcx, A> { fn deref(&self) -> &Results<'tcx, A> {
match self { match self {
ResultsHandle::Borrowed(borrowed) => borrowed,
ResultsHandle::BorrowedMut(borrowed) => borrowed, ResultsHandle::BorrowedMut(borrowed) => borrowed,
ResultsHandle::Owned(owned) => owned, ResultsHandle::Owned(owned) => owned,
} }
@ -41,9 +39,6 @@ where
{ {
fn deref_mut(&mut self) -> &mut Results<'tcx, A> { fn deref_mut(&mut self) -> &mut Results<'tcx, A> {
match self { match self {
ResultsHandle::Borrowed(_borrowed) => {
panic!("tried to deref_mut a `ResultsHandle::Borrowed")
}
ResultsHandle::BorrowedMut(borrowed) => borrowed, ResultsHandle::BorrowedMut(borrowed) => borrowed,
ResultsHandle::Owned(owned) => owned, ResultsHandle::Owned(owned) => owned,
} }

View file

@ -51,7 +51,7 @@ where
style: OutputStyle, style: OutputStyle,
) -> Self { ) -> Self {
let reachable = mir::traversal::reachable_as_bitset(body); let reachable = mir::traversal::reachable_as_bitset(body);
Formatter { cursor: results.as_results_cursor_mut(body).into(), style, reachable } Formatter { cursor: results.as_results_cursor(body).into(), style, reachable }
} }
fn body(&self) -> &'mir Body<'tcx> { fn body(&self) -> &'mir Body<'tcx> {

View file

@ -37,18 +37,9 @@ impl<'tcx, A> Results<'tcx, A>
where where
A: Analysis<'tcx>, A: Analysis<'tcx>,
{ {
/// Creates a `ResultsCursor` that can inspect these `Results`. Immutably borrows the `Results`, /// Creates a `ResultsCursor` that mutably borrows the `Results`, which is appropriate when the
/// which is appropriate when the `Results` is used outside the cursor. /// `Results` is also used outside the cursor.
pub fn as_results_cursor<'mir>( pub fn as_results_cursor<'mir>(
&'mir self,
body: &'mir mir::Body<'tcx>,
) -> ResultsCursor<'mir, 'tcx, A> {
ResultsCursor::new(body, ResultsHandle::Borrowed(self))
}
/// Creates a `ResultsCursor` that can mutate these `Results`. Mutably borrows the `Results`,
/// which is appropriate when the `Results` is used outside the cursor.
pub fn as_results_cursor_mut<'mir>(
&'mir mut self, &'mir mut self,
body: &'mir mir::Body<'tcx>, body: &'mir mir::Body<'tcx>,
) -> ResultsCursor<'mir, 'tcx, A> { ) -> ResultsCursor<'mir, 'tcx, A> {

View file

@ -680,7 +680,7 @@ fn locals_live_across_suspend_points<'tcx>(
let mut requires_storage_results = let mut requires_storage_results =
MaybeRequiresStorage::new(borrowed_locals_results.into_results_cursor(body)) MaybeRequiresStorage::new(borrowed_locals_results.into_results_cursor(body))
.iterate_to_fixpoint(tcx, body, None); .iterate_to_fixpoint(tcx, body, None);
let mut requires_storage_cursor = requires_storage_results.as_results_cursor_mut(body); let mut requires_storage_cursor = requires_storage_results.as_results_cursor(body);
// Calculate the liveness of MIR locals ignoring borrows. // Calculate the liveness of MIR locals ignoring borrows.
let mut liveness = let mut liveness =