Refactor unwind from Option to a new enum
This commit is contained in:
parent
7f6edd3f15
commit
daeb844e0c
39 changed files with 328 additions and 250 deletions
|
@ -11,7 +11,7 @@ use crate::{
|
|||
};
|
||||
use rustc_data_structures::fx::FxIndexSet;
|
||||
use rustc_middle::mir::visit::{MirVisitable, PlaceContext, Visitor};
|
||||
use rustc_middle::mir::{Body, Local, Location};
|
||||
use rustc_middle::mir::{self, Body, Local, Location};
|
||||
use rustc_middle::ty::{RegionVid, TyCtxt};
|
||||
|
||||
pub(crate) fn find<'tcx>(
|
||||
|
@ -70,7 +70,10 @@ impl<'cx, 'tcx> UseFinder<'cx, 'tcx> {
|
|||
block_data
|
||||
.terminator()
|
||||
.successors()
|
||||
.filter(|&bb| Some(&Some(bb)) != block_data.terminator().unwind())
|
||||
.filter(|&bb| {
|
||||
Some(&mir::UnwindAction::Cleanup(bb))
|
||||
!= block_data.terminator().unwind()
|
||||
})
|
||||
.map(|bb| Location { statement_index: 0, block: bb }),
|
||||
);
|
||||
}
|
||||
|
|
|
@ -125,7 +125,7 @@ impl<'cx, 'tcx> Visitor<'tcx> for InvalidationGenerator<'cx, 'tcx> {
|
|||
args,
|
||||
destination,
|
||||
target: _,
|
||||
cleanup: _,
|
||||
unwind: _,
|
||||
from_hir_call: _,
|
||||
fn_span: _,
|
||||
} => {
|
||||
|
@ -135,7 +135,7 @@ impl<'cx, 'tcx> Visitor<'tcx> for InvalidationGenerator<'cx, 'tcx> {
|
|||
}
|
||||
self.mutate_place(location, *destination, Deep);
|
||||
}
|
||||
TerminatorKind::Assert { cond, expected: _, msg, target: _, cleanup: _ } => {
|
||||
TerminatorKind::Assert { cond, expected: _, msg, target: _, unwind: _ } => {
|
||||
self.consume_operand(location, cond);
|
||||
use rustc_middle::mir::AssertKind;
|
||||
if let AssertKind::BoundsCheck { len, index } = msg {
|
||||
|
@ -173,7 +173,7 @@ impl<'cx, 'tcx> Visitor<'tcx> for InvalidationGenerator<'cx, 'tcx> {
|
|||
options: _,
|
||||
line_spans: _,
|
||||
destination: _,
|
||||
cleanup: _,
|
||||
unwind: _,
|
||||
} => {
|
||||
for op in operands {
|
||||
match op {
|
||||
|
|
|
@ -740,7 +740,7 @@ impl<'cx, 'tcx> rustc_mir_dataflow::ResultsVisitor<'cx, 'tcx> for MirBorrowckCtx
|
|||
args,
|
||||
destination,
|
||||
target: _,
|
||||
cleanup: _,
|
||||
unwind: _,
|
||||
from_hir_call: _,
|
||||
fn_span: _,
|
||||
} => {
|
||||
|
@ -750,7 +750,7 @@ impl<'cx, 'tcx> rustc_mir_dataflow::ResultsVisitor<'cx, 'tcx> for MirBorrowckCtx
|
|||
}
|
||||
self.mutate_place(loc, (*destination, span), Deep, flow_state);
|
||||
}
|
||||
TerminatorKind::Assert { cond, expected: _, msg, target: _, cleanup: _ } => {
|
||||
TerminatorKind::Assert { cond, expected: _, msg, target: _, unwind: _ } => {
|
||||
self.consume_operand(loc, (cond, span), flow_state);
|
||||
use rustc_middle::mir::AssertKind;
|
||||
if let AssertKind::BoundsCheck { len, index } = msg {
|
||||
|
@ -770,7 +770,7 @@ impl<'cx, 'tcx> rustc_mir_dataflow::ResultsVisitor<'cx, 'tcx> for MirBorrowckCtx
|
|||
options: _,
|
||||
line_spans: _,
|
||||
destination: _,
|
||||
cleanup: _,
|
||||
unwind: _,
|
||||
} => {
|
||||
for op in operands {
|
||||
match op {
|
||||
|
|
|
@ -1610,20 +1610,20 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
|
|||
}
|
||||
TerminatorKind::Unreachable => {}
|
||||
TerminatorKind::Drop { target, unwind, .. }
|
||||
| TerminatorKind::Assert { target, cleanup: unwind, .. } => {
|
||||
| TerminatorKind::Assert { target, unwind, .. } => {
|
||||
self.assert_iscleanup(body, block_data, target, is_cleanup);
|
||||
if let Some(unwind) = unwind {
|
||||
if let UnwindAction::Cleanup(unwind) = unwind {
|
||||
if is_cleanup {
|
||||
span_mirbug!(self, block_data, "unwind on cleanup block")
|
||||
}
|
||||
self.assert_iscleanup(body, block_data, unwind, true);
|
||||
}
|
||||
}
|
||||
TerminatorKind::Call { ref target, cleanup, .. } => {
|
||||
TerminatorKind::Call { ref target, unwind, .. } => {
|
||||
if let &Some(target) = target {
|
||||
self.assert_iscleanup(body, block_data, target, is_cleanup);
|
||||
}
|
||||
if let Some(cleanup) = cleanup {
|
||||
if let UnwindAction::Cleanup(cleanup) = unwind {
|
||||
if is_cleanup {
|
||||
span_mirbug!(self, block_data, "cleanup on cleanup block")
|
||||
}
|
||||
|
@ -1636,18 +1636,18 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
|
|||
}
|
||||
TerminatorKind::FalseUnwind { real_target, unwind } => {
|
||||
self.assert_iscleanup(body, block_data, real_target, is_cleanup);
|
||||
if let Some(unwind) = unwind {
|
||||
if let UnwindAction::Cleanup(unwind) = unwind {
|
||||
if is_cleanup {
|
||||
span_mirbug!(self, block_data, "cleanup in cleanup block via false unwind");
|
||||
}
|
||||
self.assert_iscleanup(body, block_data, unwind, true);
|
||||
}
|
||||
}
|
||||
TerminatorKind::InlineAsm { destination, cleanup, .. } => {
|
||||
TerminatorKind::InlineAsm { destination, unwind, .. } => {
|
||||
if let Some(target) = destination {
|
||||
self.assert_iscleanup(body, block_data, target, is_cleanup);
|
||||
}
|
||||
if let Some(cleanup) = cleanup {
|
||||
if let UnwindAction::Cleanup(cleanup) = unwind {
|
||||
if is_cleanup {
|
||||
span_mirbug!(self, block_data, "cleanup on cleanup block")
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue