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
|
@ -77,10 +77,10 @@ impl Unwind {
|
|||
}
|
||||
}
|
||||
|
||||
fn into_option(self) -> Option<BasicBlock> {
|
||||
fn into_action(self) -> UnwindAction {
|
||||
match self {
|
||||
Unwind::To(bb) => Some(bb),
|
||||
Unwind::InCleanup => None,
|
||||
Unwind::To(bb) => UnwindAction::Cleanup(bb),
|
||||
Unwind::InCleanup => UnwindAction::Continue,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -236,7 +236,7 @@ where
|
|||
TerminatorKind::Drop {
|
||||
place: self.place,
|
||||
target: self.succ,
|
||||
unwind: self.unwind.into_option(),
|
||||
unwind: self.unwind.into_action(),
|
||||
},
|
||||
);
|
||||
}
|
||||
|
@ -640,7 +640,7 @@ where
|
|||
args: vec![Operand::Move(Place::from(ref_place))],
|
||||
destination: unit_temp,
|
||||
target: Some(succ),
|
||||
cleanup: unwind.into_option(),
|
||||
unwind: unwind.into_action(),
|
||||
from_hir_call: true,
|
||||
fn_span: self.source_info.span,
|
||||
},
|
||||
|
@ -717,7 +717,7 @@ where
|
|||
TerminatorKind::Drop {
|
||||
place: tcx.mk_place_deref(ptr),
|
||||
target: loop_block,
|
||||
unwind: unwind.into_option(),
|
||||
unwind: unwind.into_action(),
|
||||
},
|
||||
);
|
||||
|
||||
|
@ -946,7 +946,7 @@ where
|
|||
args,
|
||||
destination: unit_temp,
|
||||
target: Some(target),
|
||||
cleanup: None,
|
||||
unwind: UnwindAction::Continue,
|
||||
from_hir_call: false,
|
||||
fn_span: self.source_info.span,
|
||||
}; // FIXME(#43234)
|
||||
|
@ -959,7 +959,7 @@ where
|
|||
|
||||
fn drop_block(&mut self, target: BasicBlock, unwind: Unwind) -> BasicBlock {
|
||||
let block =
|
||||
TerminatorKind::Drop { place: self.place, target, unwind: unwind.into_option() };
|
||||
TerminatorKind::Drop { place: self.place, target, unwind: unwind.into_action() };
|
||||
self.new_block(unwind, block)
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use rustc_middle::mir::{self, BasicBlock, Location, SwitchTargets};
|
||||
use rustc_middle::mir::{self, BasicBlock, Location, SwitchTargets, UnwindAction};
|
||||
use rustc_middle::ty::TyCtxt;
|
||||
use std::ops::RangeInclusive;
|
||||
|
||||
|
@ -478,10 +478,10 @@ impl Direction for Forward {
|
|||
|
||||
Goto { target } => propagate(target, exit_state),
|
||||
|
||||
Assert { target, cleanup: unwind, expected: _, msg: _, cond: _ }
|
||||
Assert { target, unwind, expected: _, msg: _, cond: _ }
|
||||
| Drop { target, unwind, place: _ }
|
||||
| FalseUnwind { real_target: target, unwind } => {
|
||||
if let Some(unwind) = unwind {
|
||||
if let UnwindAction::Cleanup(unwind) = unwind {
|
||||
propagate(unwind, exit_state);
|
||||
}
|
||||
|
||||
|
@ -503,7 +503,7 @@ impl Direction for Forward {
|
|||
}
|
||||
|
||||
Call {
|
||||
cleanup,
|
||||
unwind,
|
||||
destination,
|
||||
target,
|
||||
func: _,
|
||||
|
@ -511,7 +511,7 @@ impl Direction for Forward {
|
|||
from_hir_call: _,
|
||||
fn_span: _,
|
||||
} => {
|
||||
if let Some(unwind) = cleanup {
|
||||
if let UnwindAction::Cleanup(unwind) = unwind {
|
||||
propagate(unwind, exit_state);
|
||||
}
|
||||
|
||||
|
@ -533,9 +533,9 @@ impl Direction for Forward {
|
|||
options: _,
|
||||
line_spans: _,
|
||||
destination,
|
||||
cleanup,
|
||||
unwind,
|
||||
} => {
|
||||
if let Some(unwind) = cleanup {
|
||||
if let UnwindAction::Cleanup(unwind) = unwind {
|
||||
propagate(unwind, exit_state);
|
||||
}
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ fn mock_body<'tcx>() -> mir::Body<'tcx> {
|
|||
args: vec![],
|
||||
destination: dummy_place.clone(),
|
||||
target: Some(mir::START_BLOCK),
|
||||
cleanup: None,
|
||||
unwind: mir::UnwindAction::Continue,
|
||||
from_hir_call: false,
|
||||
fn_span: DUMMY_SP,
|
||||
},
|
||||
|
@ -53,7 +53,7 @@ fn mock_body<'tcx>() -> mir::Body<'tcx> {
|
|||
args: vec![],
|
||||
destination: dummy_place.clone(),
|
||||
target: Some(mir::START_BLOCK),
|
||||
cleanup: None,
|
||||
unwind: mir::UnwindAction::Continue,
|
||||
from_hir_call: false,
|
||||
fn_span: DUMMY_SP,
|
||||
},
|
||||
|
|
|
@ -398,7 +398,7 @@ impl<'b, 'a, 'tcx> Gatherer<'b, 'a, 'tcx> {
|
|||
ref args,
|
||||
destination,
|
||||
target,
|
||||
cleanup: _,
|
||||
unwind: _,
|
||||
from_hir_call: _,
|
||||
fn_span: _,
|
||||
} => {
|
||||
|
@ -417,7 +417,7 @@ impl<'b, 'a, 'tcx> Gatherer<'b, 'a, 'tcx> {
|
|||
options: _,
|
||||
line_spans: _,
|
||||
destination: _,
|
||||
cleanup: _,
|
||||
unwind: _,
|
||||
} => {
|
||||
for op in operands {
|
||||
match *op {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue