give some unwind-related terminators a more clear name
This commit is contained in:
parent
c0b6ffaaea
commit
818ec8e23a
@ -159,7 +159,9 @@ fn visit_terminator(&mut self, terminator: &Terminator<'tcx>, location: Location
|
||||
|
||||
self.mutate_place(location, *resume_arg, Deep);
|
||||
}
|
||||
TerminatorKind::Resume | TerminatorKind::Return | TerminatorKind::GeneratorDrop => {
|
||||
TerminatorKind::UnwindResume
|
||||
| TerminatorKind::Return
|
||||
| TerminatorKind::GeneratorDrop => {
|
||||
// Invalidate all borrows of local places
|
||||
let borrow_set = self.borrow_set;
|
||||
let start = self.location_table.start_index(location);
|
||||
@ -200,7 +202,7 @@ fn visit_terminator(&mut self, terminator: &Terminator<'tcx>, location: Location
|
||||
}
|
||||
}
|
||||
TerminatorKind::Goto { target: _ }
|
||||
| TerminatorKind::Terminate
|
||||
| TerminatorKind::UnwindTerminate
|
||||
| TerminatorKind::Unreachable
|
||||
| TerminatorKind::FalseEdge { real_target: _, imaginary_target: _ }
|
||||
| TerminatorKind::FalseUnwind { real_target: _, unwind: _ } => {
|
||||
|
@ -770,9 +770,9 @@ fn visit_terminator_before_primary_effect(
|
||||
}
|
||||
|
||||
TerminatorKind::Goto { target: _ }
|
||||
| TerminatorKind::Terminate
|
||||
| TerminatorKind::UnwindTerminate
|
||||
| TerminatorKind::Unreachable
|
||||
| TerminatorKind::Resume
|
||||
| TerminatorKind::UnwindResume
|
||||
| TerminatorKind::Return
|
||||
| TerminatorKind::GeneratorDrop
|
||||
| TerminatorKind::FalseEdge { real_target: _, imaginary_target: _ }
|
||||
@ -803,7 +803,9 @@ fn visit_terminator_after_primary_effect(
|
||||
}
|
||||
}
|
||||
|
||||
TerminatorKind::Resume | TerminatorKind::Return | TerminatorKind::GeneratorDrop => {
|
||||
TerminatorKind::UnwindResume
|
||||
| TerminatorKind::Return
|
||||
| TerminatorKind::GeneratorDrop => {
|
||||
// Returning from the function implicitly kills storage for all locals and statics.
|
||||
// Often, the storage will already have been killed by an explicit
|
||||
// StorageDead, but we don't always emit those (notably on unwind paths),
|
||||
@ -815,7 +817,7 @@ fn visit_terminator_after_primary_effect(
|
||||
}
|
||||
}
|
||||
|
||||
TerminatorKind::Terminate
|
||||
TerminatorKind::UnwindTerminate
|
||||
| TerminatorKind::Assert { .. }
|
||||
| TerminatorKind::Call { .. }
|
||||
| TerminatorKind::Drop { .. }
|
||||
|
@ -1333,8 +1333,8 @@ fn check_terminator(
|
||||
debug!("terminator kind: {:?}", term.kind);
|
||||
match &term.kind {
|
||||
TerminatorKind::Goto { .. }
|
||||
| TerminatorKind::Resume
|
||||
| TerminatorKind::Terminate
|
||||
| TerminatorKind::UnwindResume
|
||||
| TerminatorKind::UnwindTerminate
|
||||
| TerminatorKind::Return
|
||||
| TerminatorKind::GeneratorDrop
|
||||
| TerminatorKind::Unreachable
|
||||
@ -1608,12 +1608,12 @@ fn check_iscleanup(&mut self, body: &Body<'tcx>, block_data: &BasicBlockData<'tc
|
||||
self.assert_iscleanup(body, block_data, *target, is_cleanup);
|
||||
}
|
||||
}
|
||||
TerminatorKind::Resume => {
|
||||
TerminatorKind::UnwindResume => {
|
||||
if !is_cleanup {
|
||||
span_mirbug!(self, block_data, "resume on non-cleanup block!")
|
||||
}
|
||||
}
|
||||
TerminatorKind::Terminate => {
|
||||
TerminatorKind::UnwindTerminate => {
|
||||
if !is_cleanup {
|
||||
span_mirbug!(self, block_data, "abort on non-cleanup block!")
|
||||
}
|
||||
|
@ -474,10 +474,10 @@ fn codegen_fn_body(fx: &mut FunctionCx<'_, '_, '_>, start_block: Block) {
|
||||
*destination,
|
||||
);
|
||||
}
|
||||
TerminatorKind::Terminate => {
|
||||
TerminatorKind::UnwindTerminate => {
|
||||
codegen_panic_cannot_unwind(fx, source_info);
|
||||
}
|
||||
TerminatorKind::Resume => {
|
||||
TerminatorKind::UnwindResume => {
|
||||
// FIXME implement unwinding
|
||||
fx.bcx.ins().trap(TrapCode::UnreachableCodeReached);
|
||||
}
|
||||
|
@ -550,8 +550,8 @@ pub(crate) fn mir_operand_get_const_val<'tcx>(
|
||||
match &bb_data.terminator().kind {
|
||||
TerminatorKind::Goto { .. }
|
||||
| TerminatorKind::SwitchInt { .. }
|
||||
| TerminatorKind::Resume
|
||||
| TerminatorKind::Terminate
|
||||
| TerminatorKind::UnwindResume
|
||||
| TerminatorKind::UnwindTerminate
|
||||
| TerminatorKind::Return
|
||||
| TerminatorKind::Unreachable
|
||||
| TerminatorKind::Drop { .. }
|
||||
|
@ -284,8 +284,8 @@ fn discover_masters<'tcx>(
|
||||
for (bb, data) in mir.basic_blocks.iter_enumerated() {
|
||||
match data.terminator().kind {
|
||||
TerminatorKind::Goto { .. }
|
||||
| TerminatorKind::Resume
|
||||
| TerminatorKind::Terminate
|
||||
| TerminatorKind::UnwindResume
|
||||
| TerminatorKind::UnwindTerminate
|
||||
| TerminatorKind::Return
|
||||
| TerminatorKind::GeneratorDrop
|
||||
| TerminatorKind::Unreachable
|
||||
|
@ -1224,12 +1224,12 @@ fn codegen_terminator(
|
||||
|
||||
self.set_debug_loc(bx, terminator.source_info);
|
||||
match terminator.kind {
|
||||
mir::TerminatorKind::Resume => {
|
||||
mir::TerminatorKind::UnwindResume => {
|
||||
self.codegen_resume_terminator(helper, bx);
|
||||
MergingSucc::False
|
||||
}
|
||||
|
||||
mir::TerminatorKind::Terminate => {
|
||||
mir::TerminatorKind::UnwindTerminate => {
|
||||
self.codegen_terminate_terminator(helper, bx, terminator);
|
||||
MergingSucc::False
|
||||
}
|
||||
|
@ -196,7 +196,7 @@ pub(super) fn eval_terminator(
|
||||
}
|
||||
}
|
||||
|
||||
Terminate => {
|
||||
UnwindTerminate => {
|
||||
// FIXME: maybe should call `panic_no_unwind` lang item instead.
|
||||
M::abort(self, "panic in a function that cannot unwind".to_owned())?;
|
||||
}
|
||||
@ -204,7 +204,7 @@ pub(super) fn eval_terminator(
|
||||
// When we encounter Resume, we've finished unwinding
|
||||
// cleanup for the current stack frame. We pop it in order
|
||||
// to continue unwinding the next frame
|
||||
Resume => {
|
||||
UnwindResume => {
|
||||
trace!("unwinding: resuming from cleanup");
|
||||
// By definition, a Resume terminator means
|
||||
// that we're unwinding
|
||||
|
@ -1037,7 +1037,7 @@ fn visit_terminator(&mut self, terminator: &Terminator<'tcx>, location: Location
|
||||
self.check_op(ops::Generator(hir::GeneratorKind::Gen))
|
||||
}
|
||||
|
||||
TerminatorKind::Terminate => {
|
||||
TerminatorKind::UnwindTerminate => {
|
||||
// Cleanup blocks are skipped for const checking (see `visit_basic_block_data`).
|
||||
span_bug!(self.span, "`Terminate` terminator outside of cleanup block")
|
||||
}
|
||||
@ -1046,7 +1046,7 @@ fn visit_terminator(&mut self, terminator: &Terminator<'tcx>, location: Location
|
||||
| TerminatorKind::FalseEdge { .. }
|
||||
| TerminatorKind::FalseUnwind { .. }
|
||||
| TerminatorKind::Goto { .. }
|
||||
| TerminatorKind::Resume
|
||||
| TerminatorKind::UnwindResume
|
||||
| TerminatorKind::Return
|
||||
| TerminatorKind::SwitchInt { .. }
|
||||
| TerminatorKind::Unreachable => {}
|
||||
|
@ -106,7 +106,7 @@ fn visit_terminator(&mut self, terminator: &mir::Terminator<'tcx>, location: Loc
|
||||
}
|
||||
}
|
||||
|
||||
mir::TerminatorKind::Terminate
|
||||
mir::TerminatorKind::UnwindTerminate
|
||||
| mir::TerminatorKind::Call { .. }
|
||||
| mir::TerminatorKind::Assert { .. }
|
||||
| mir::TerminatorKind::FalseEdge { .. }
|
||||
@ -114,7 +114,7 @@ fn visit_terminator(&mut self, terminator: &mir::Terminator<'tcx>, location: Loc
|
||||
| mir::TerminatorKind::GeneratorDrop
|
||||
| mir::TerminatorKind::Goto { .. }
|
||||
| mir::TerminatorKind::InlineAsm { .. }
|
||||
| mir::TerminatorKind::Resume
|
||||
| mir::TerminatorKind::UnwindResume
|
||||
| mir::TerminatorKind::Return
|
||||
| mir::TerminatorKind::SwitchInt { .. }
|
||||
| mir::TerminatorKind::Unreachable
|
||||
|
@ -492,19 +492,19 @@ fn visit_terminator(&mut self, terminator: &Terminator<'tcx>, location: Location
|
||||
);
|
||||
}
|
||||
}
|
||||
TerminatorKind::Resume => {
|
||||
TerminatorKind::UnwindResume => {
|
||||
let bb = location.block;
|
||||
if !self.body.basic_blocks[bb].is_cleanup {
|
||||
self.fail(location, "Cannot `Resume` from non-cleanup basic block")
|
||||
self.fail(location, "Cannot `UnwindResume` from non-cleanup basic block")
|
||||
}
|
||||
if !self.can_unwind {
|
||||
self.fail(location, "Cannot `Resume` in a function that cannot unwind")
|
||||
self.fail(location, "Cannot `UnwindResume` in a function that cannot unwind")
|
||||
}
|
||||
}
|
||||
TerminatorKind::Terminate => {
|
||||
TerminatorKind::UnwindTerminate => {
|
||||
let bb = location.block;
|
||||
if !self.body.basic_blocks[bb].is_cleanup {
|
||||
self.fail(location, "Cannot `Terminate` from non-cleanup basic block")
|
||||
self.fail(location, "Cannot `UnwindTerminate` from non-cleanup basic block")
|
||||
}
|
||||
}
|
||||
TerminatorKind::Return => {
|
||||
@ -1232,8 +1232,8 @@ fn visit_terminator(&mut self, terminator: &Terminator<'tcx>, location: Location
|
||||
| TerminatorKind::FalseUnwind { .. }
|
||||
| TerminatorKind::InlineAsm { .. }
|
||||
| TerminatorKind::GeneratorDrop
|
||||
| TerminatorKind::Resume
|
||||
| TerminatorKind::Terminate
|
||||
| TerminatorKind::UnwindResume
|
||||
| TerminatorKind::UnwindTerminate
|
||||
| TerminatorKind::Return
|
||||
| TerminatorKind::Unreachable => {}
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ pub fn new(body: &Body<'tcx>) -> Self {
|
||||
|
||||
for (bb, block) in body.basic_blocks.iter_enumerated() {
|
||||
// Check if we already have a resume block
|
||||
if let TerminatorKind::Resume = block.terminator().kind && block.statements.is_empty() {
|
||||
if let TerminatorKind::UnwindResume = block.terminator().kind && block.statements.is_empty() {
|
||||
result.resume_block = Some(bb);
|
||||
continue;
|
||||
}
|
||||
@ -50,7 +50,7 @@ pub fn new(body: &Body<'tcx>) -> Self {
|
||||
}
|
||||
|
||||
// Check if we already have a terminate block
|
||||
if let TerminatorKind::Terminate = block.terminator().kind && block.statements.is_empty() {
|
||||
if let TerminatorKind::UnwindTerminate = block.terminator().kind && block.statements.is_empty() {
|
||||
result.terminate_block = Some(bb);
|
||||
continue;
|
||||
}
|
||||
@ -68,7 +68,7 @@ pub fn resume_block(&mut self) -> BasicBlock {
|
||||
statements: vec![],
|
||||
terminator: Some(Terminator {
|
||||
source_info: SourceInfo::outermost(self.body_span),
|
||||
kind: TerminatorKind::Resume,
|
||||
kind: TerminatorKind::UnwindResume,
|
||||
}),
|
||||
is_cleanup: true,
|
||||
});
|
||||
@ -102,7 +102,7 @@ pub fn terminate_block(&mut self) -> BasicBlock {
|
||||
statements: vec![],
|
||||
terminator: Some(Terminator {
|
||||
source_info: SourceInfo::outermost(self.body_span),
|
||||
kind: TerminatorKind::Terminate,
|
||||
kind: TerminatorKind::UnwindTerminate,
|
||||
}),
|
||||
is_cleanup: true,
|
||||
});
|
||||
|
@ -262,8 +262,8 @@ pub fn terminator_kind_name(term: &Terminator<'_>) -> &'static str {
|
||||
match term.kind {
|
||||
Goto { .. } => "Goto",
|
||||
SwitchInt { .. } => "SwitchInt",
|
||||
Resume => "Resume",
|
||||
Terminate => "Terminate",
|
||||
UnwindResume => "Resume",
|
||||
UnwindTerminate => "Terminate",
|
||||
Return => "Return",
|
||||
Unreachable => "Unreachable",
|
||||
Drop { .. } => "Drop",
|
||||
|
@ -593,13 +593,13 @@ pub enum TerminatorKind<'tcx> {
|
||||
///
|
||||
/// Only permitted in cleanup blocks. `Resume` is not permitted with `-C unwind=abort` after
|
||||
/// deaggregation runs.
|
||||
Resume,
|
||||
UnwindResume,
|
||||
|
||||
/// Indicates that the landing pad is finished and that the process should terminate.
|
||||
///
|
||||
/// Used to prevent unwinding for foreign items or with `-C unwind=abort`. Only permitted in
|
||||
/// cleanup blocks.
|
||||
Terminate,
|
||||
UnwindTerminate,
|
||||
|
||||
/// Returns from the function.
|
||||
///
|
||||
@ -790,8 +790,8 @@ pub const fn name(&self) -> &'static str {
|
||||
match self {
|
||||
TerminatorKind::Goto { .. } => "Goto",
|
||||
TerminatorKind::SwitchInt { .. } => "SwitchInt",
|
||||
TerminatorKind::Resume => "Resume",
|
||||
TerminatorKind::Terminate => "Terminate",
|
||||
TerminatorKind::UnwindResume => "Resume",
|
||||
TerminatorKind::UnwindTerminate => "Terminate",
|
||||
TerminatorKind::Return => "Return",
|
||||
TerminatorKind::Unreachable => "Unreachable",
|
||||
TerminatorKind::Drop { .. } => "Drop",
|
||||
|
@ -155,8 +155,8 @@ pub fn successors(&self) -> Successors<'_> {
|
||||
| InlineAsm { destination: Some(t), unwind: _, .. } => {
|
||||
Some(t).into_iter().chain((&[]).into_iter().copied())
|
||||
}
|
||||
Resume
|
||||
| Terminate
|
||||
UnwindResume
|
||||
| UnwindTerminate
|
||||
| GeneratorDrop
|
||||
| Return
|
||||
| Unreachable
|
||||
@ -197,8 +197,8 @@ pub fn successors_mut(&mut self) -> SuccessorsMut<'_> {
|
||||
| InlineAsm { destination: Some(ref mut t), unwind: _, .. } => {
|
||||
Some(t).into_iter().chain(&mut [])
|
||||
}
|
||||
Resume
|
||||
| Terminate
|
||||
UnwindResume
|
||||
| UnwindTerminate
|
||||
| GeneratorDrop
|
||||
| Return
|
||||
| Unreachable
|
||||
@ -214,8 +214,8 @@ pub fn successors_mut(&mut self) -> SuccessorsMut<'_> {
|
||||
pub fn unwind(&self) -> Option<&UnwindAction> {
|
||||
match *self {
|
||||
TerminatorKind::Goto { .. }
|
||||
| TerminatorKind::Resume
|
||||
| TerminatorKind::Terminate
|
||||
| TerminatorKind::UnwindResume
|
||||
| TerminatorKind::UnwindTerminate
|
||||
| TerminatorKind::Return
|
||||
| TerminatorKind::Unreachable
|
||||
| TerminatorKind::GeneratorDrop
|
||||
@ -233,8 +233,8 @@ pub fn unwind(&self) -> Option<&UnwindAction> {
|
||||
pub fn unwind_mut(&mut self) -> Option<&mut UnwindAction> {
|
||||
match *self {
|
||||
TerminatorKind::Goto { .. }
|
||||
| TerminatorKind::Resume
|
||||
| TerminatorKind::Terminate
|
||||
| TerminatorKind::UnwindResume
|
||||
| TerminatorKind::UnwindTerminate
|
||||
| TerminatorKind::Return
|
||||
| TerminatorKind::Unreachable
|
||||
| TerminatorKind::GeneratorDrop
|
||||
@ -311,8 +311,8 @@ pub fn fmt_head<W: Write>(&self, fmt: &mut W) -> fmt::Result {
|
||||
SwitchInt { discr, .. } => write!(fmt, "switchInt({discr:?})"),
|
||||
Return => write!(fmt, "return"),
|
||||
GeneratorDrop => write!(fmt, "generator_drop"),
|
||||
Resume => write!(fmt, "resume"),
|
||||
Terminate => write!(fmt, "abort"),
|
||||
UnwindResume => write!(fmt, "resume"),
|
||||
UnwindTerminate => write!(fmt, "abort"),
|
||||
Yield { value, resume_arg, .. } => write!(fmt, "{resume_arg:?} = yield({value:?})"),
|
||||
Unreachable => write!(fmt, "unreachable"),
|
||||
Drop { place, .. } => write!(fmt, "drop({place:?})"),
|
||||
@ -391,7 +391,7 @@ pub fn fmt_head<W: Write>(&self, fmt: &mut W) -> fmt::Result {
|
||||
pub fn fmt_successor_labels(&self) -> Vec<Cow<'static, str>> {
|
||||
use self::TerminatorKind::*;
|
||||
match *self {
|
||||
Return | Resume | Terminate | Unreachable | GeneratorDrop => vec![],
|
||||
Return | UnwindResume | UnwindTerminate | Unreachable | GeneratorDrop => vec![],
|
||||
Goto { .. } => vec!["".into()],
|
||||
SwitchInt { ref targets, .. } => targets
|
||||
.values
|
||||
@ -486,7 +486,9 @@ impl<'tcx> TerminatorKind<'tcx> {
|
||||
pub fn edges(&self) -> TerminatorEdges<'_, 'tcx> {
|
||||
use TerminatorKind::*;
|
||||
match *self {
|
||||
Return | Resume | Terminate | GeneratorDrop | Unreachable => TerminatorEdges::None,
|
||||
Return | UnwindResume | UnwindTerminate | GeneratorDrop | Unreachable => {
|
||||
TerminatorEdges::None
|
||||
}
|
||||
|
||||
Goto { target } => TerminatorEdges::Single(target),
|
||||
|
||||
|
@ -469,8 +469,8 @@ fn super_terminator(&mut self,
|
||||
self.visit_source_info(source_info);
|
||||
match kind {
|
||||
TerminatorKind::Goto { .. } |
|
||||
TerminatorKind::Resume |
|
||||
TerminatorKind::Terminate |
|
||||
TerminatorKind::UnwindResume |
|
||||
TerminatorKind::UnwindTerminate |
|
||||
TerminatorKind::GeneratorDrop |
|
||||
TerminatorKind::Unreachable |
|
||||
TerminatorKind::FalseEdge { .. } |
|
||||
|
@ -685,9 +685,9 @@ pub(crate) fn break_scope(
|
||||
drops.add_entry(block, drop_idx);
|
||||
|
||||
// `build_drop_trees` doesn't have access to our source_info, so we
|
||||
// create a dummy terminator now. `TerminatorKind::Resume` is used
|
||||
// create a dummy terminator now. `TerminatorKind::UnwindResume` is used
|
||||
// because MIR type checking will panic if it hasn't been overwritten.
|
||||
self.cfg.terminate(block, source_info, TerminatorKind::Resume);
|
||||
self.cfg.terminate(block, source_info, TerminatorKind::UnwindResume);
|
||||
|
||||
self.cfg.start_new_block().unit()
|
||||
}
|
||||
@ -717,9 +717,9 @@ pub(crate) fn break_for_else(
|
||||
drops.add_entry(block, drop_idx);
|
||||
|
||||
// `build_drop_trees` doesn't have access to our source_info, so we
|
||||
// create a dummy terminator now. `TerminatorKind::Resume` is used
|
||||
// create a dummy terminator now. `TerminatorKind::UnwindResume` is used
|
||||
// because MIR type checking will panic if it hasn't been overwritten.
|
||||
self.cfg.terminate(block, source_info, TerminatorKind::Resume);
|
||||
self.cfg.terminate(block, source_info, TerminatorKind::UnwindResume);
|
||||
}
|
||||
|
||||
// Add a dummy `Assign` statement to the CFG, with the span for the source code's `continue`
|
||||
@ -1441,7 +1441,7 @@ fn build_unwind_tree(
|
||||
blocks[ROOT_NODE] = *resume_block;
|
||||
drops.build_mir::<Unwind>(cfg, &mut blocks);
|
||||
if let (None, Some(resume)) = (*resume_block, blocks[ROOT_NODE]) {
|
||||
cfg.terminate(resume, SourceInfo::outermost(fn_span), TerminatorKind::Resume);
|
||||
cfg.terminate(resume, SourceInfo::outermost(fn_span), TerminatorKind::UnwindResume);
|
||||
|
||||
*resume_block = blocks[ROOT_NODE];
|
||||
}
|
||||
@ -1506,8 +1506,8 @@ fn add_entry(cfg: &mut CFG<'tcx>, from: BasicBlock, to: BasicBlock) {
|
||||
}
|
||||
TerminatorKind::Goto { .. }
|
||||
| TerminatorKind::SwitchInt { .. }
|
||||
| TerminatorKind::Resume
|
||||
| TerminatorKind::Terminate
|
||||
| TerminatorKind::UnwindResume
|
||||
| TerminatorKind::UnwindTerminate
|
||||
| TerminatorKind::Return
|
||||
| TerminatorKind::Unreachable
|
||||
| TerminatorKind::Yield { .. }
|
||||
|
@ -186,9 +186,9 @@ fn node_examined(
|
||||
|
||||
match self.body[bb].terminator().kind {
|
||||
// These terminators return control flow to the caller.
|
||||
TerminatorKind::Terminate
|
||||
TerminatorKind::UnwindTerminate
|
||||
| TerminatorKind::GeneratorDrop
|
||||
| TerminatorKind::Resume
|
||||
| TerminatorKind::UnwindResume
|
||||
| TerminatorKind::Return
|
||||
| TerminatorKind::Unreachable
|
||||
| TerminatorKind::Yield { .. } => ControlFlow::Break(NonRecursive),
|
||||
|
@ -131,7 +131,7 @@ fn visit_terminator(&mut self, terminator: &Terminator<'tcx>, location: Location
|
||||
}
|
||||
}
|
||||
|
||||
TerminatorKind::Terminate
|
||||
TerminatorKind::UnwindTerminate
|
||||
| TerminatorKind::Assert { .. }
|
||||
| TerminatorKind::Call { .. }
|
||||
| TerminatorKind::FalseEdge { .. }
|
||||
@ -139,7 +139,7 @@ fn visit_terminator(&mut self, terminator: &Terminator<'tcx>, location: Location
|
||||
| TerminatorKind::GeneratorDrop
|
||||
| TerminatorKind::Goto { .. }
|
||||
| TerminatorKind::InlineAsm { .. }
|
||||
| TerminatorKind::Resume
|
||||
| TerminatorKind::UnwindResume
|
||||
| TerminatorKind::Return
|
||||
| TerminatorKind::SwitchInt { .. }
|
||||
| TerminatorKind::Unreachable
|
||||
|
@ -291,14 +291,14 @@ fn before_terminator_effect(
|
||||
|
||||
// Nothing to do for these. Match exhaustively so this fails to compile when new
|
||||
// variants are added.
|
||||
TerminatorKind::Terminate
|
||||
TerminatorKind::UnwindTerminate
|
||||
| TerminatorKind::Assert { .. }
|
||||
| TerminatorKind::Drop { .. }
|
||||
| TerminatorKind::FalseEdge { .. }
|
||||
| TerminatorKind::FalseUnwind { .. }
|
||||
| TerminatorKind::GeneratorDrop
|
||||
| TerminatorKind::Goto { .. }
|
||||
| TerminatorKind::Resume
|
||||
| TerminatorKind::UnwindResume
|
||||
| TerminatorKind::Return
|
||||
| TerminatorKind::SwitchInt { .. }
|
||||
| TerminatorKind::Unreachable => {}
|
||||
@ -328,14 +328,14 @@ fn terminator_effect<'t>(
|
||||
// Nothing to do for these. Match exhaustively so this fails to compile when new
|
||||
// variants are added.
|
||||
TerminatorKind::Yield { .. }
|
||||
| TerminatorKind::Terminate
|
||||
| TerminatorKind::UnwindTerminate
|
||||
| TerminatorKind::Assert { .. }
|
||||
| TerminatorKind::Drop { .. }
|
||||
| TerminatorKind::FalseEdge { .. }
|
||||
| TerminatorKind::FalseUnwind { .. }
|
||||
| TerminatorKind::GeneratorDrop
|
||||
| TerminatorKind::Goto { .. }
|
||||
| TerminatorKind::Resume
|
||||
| TerminatorKind::UnwindResume
|
||||
| TerminatorKind::Return
|
||||
| TerminatorKind::SwitchInt { .. }
|
||||
| TerminatorKind::Unreachable => {}
|
||||
|
@ -370,8 +370,8 @@ fn gather_terminator(&mut self, term: &Terminator<'tcx>) {
|
||||
// this that could possibly access the return place, this doesn't
|
||||
// need recording.
|
||||
| TerminatorKind::Return
|
||||
| TerminatorKind::Resume
|
||||
| TerminatorKind::Terminate
|
||||
| TerminatorKind::UnwindResume
|
||||
| TerminatorKind::UnwindTerminate
|
||||
| TerminatorKind::GeneratorDrop
|
||||
| TerminatorKind::Unreachable
|
||||
| TerminatorKind::Drop { .. } => {}
|
||||
|
@ -269,8 +269,8 @@ fn super_terminator<'mir>(
|
||||
return self.handle_switch_int(discr, targets, state);
|
||||
}
|
||||
TerminatorKind::Goto { .. }
|
||||
| TerminatorKind::Resume
|
||||
| TerminatorKind::Terminate
|
||||
| TerminatorKind::UnwindResume
|
||||
| TerminatorKind::UnwindTerminate
|
||||
| TerminatorKind::Return
|
||||
| TerminatorKind::Unreachable
|
||||
| TerminatorKind::Assert { .. }
|
||||
|
@ -57,8 +57,8 @@ fn visit_terminator(&mut self, terminator: &Terminator<'tcx>, location: Location
|
||||
| TerminatorKind::Yield { .. }
|
||||
| TerminatorKind::Assert { .. }
|
||||
| TerminatorKind::GeneratorDrop
|
||||
| TerminatorKind::Resume
|
||||
| TerminatorKind::Terminate
|
||||
| TerminatorKind::UnwindResume
|
||||
| TerminatorKind::UnwindTerminate
|
||||
| TerminatorKind::Return
|
||||
| TerminatorKind::Unreachable
|
||||
| TerminatorKind::FalseEdge { .. }
|
||||
|
@ -678,8 +678,8 @@ fn visit_terminator(&mut self, terminator: &Terminator<'tcx>, location: Location
|
||||
}
|
||||
// None of these have Operands to const-propagate.
|
||||
TerminatorKind::Goto { .. }
|
||||
| TerminatorKind::Resume
|
||||
| TerminatorKind::Terminate
|
||||
| TerminatorKind::UnwindResume
|
||||
| TerminatorKind::UnwindTerminate
|
||||
| TerminatorKind::Return
|
||||
| TerminatorKind::Unreachable
|
||||
| TerminatorKind::Drop { .. }
|
||||
|
@ -116,7 +116,7 @@ fn compute_basic_coverage_blocks(
|
||||
|
||||
match term.kind {
|
||||
TerminatorKind::Return { .. }
|
||||
| TerminatorKind::Terminate
|
||||
| TerminatorKind::UnwindTerminate
|
||||
| TerminatorKind::Yield { .. }
|
||||
| TerminatorKind::SwitchInt { .. } => {
|
||||
// The `bb` has more than one _outgoing_ edge, or exits the function. Save the
|
||||
@ -146,7 +146,7 @@ fn compute_basic_coverage_blocks(
|
||||
// is as intended. (See Issue #78544 for a possible future option to support
|
||||
// coverage in test programs that panic.)
|
||||
TerminatorKind::Goto { .. }
|
||||
| TerminatorKind::Resume
|
||||
| TerminatorKind::UnwindResume
|
||||
| TerminatorKind::Unreachable
|
||||
| TerminatorKind::Drop { .. }
|
||||
| TerminatorKind::Call { .. }
|
||||
|
@ -867,8 +867,8 @@ pub(super) fn filtered_terminator_span(terminator: &Terminator<'_>) -> Option<Sp
|
||||
}
|
||||
|
||||
// Retain spans from all other terminators
|
||||
TerminatorKind::Resume
|
||||
| TerminatorKind::Terminate
|
||||
TerminatorKind::UnwindResume
|
||||
| TerminatorKind::UnwindTerminate
|
||||
| TerminatorKind::Return
|
||||
| TerminatorKind::Yield { .. }
|
||||
| TerminatorKind::GeneratorDrop
|
||||
|
@ -647,8 +647,8 @@ fn for_terminator<'tcx>(&mut self, terminator: &TerminatorKind<'tcx>) {
|
||||
}
|
||||
}
|
||||
TerminatorKind::Goto { .. }
|
||||
| TerminatorKind::Resume
|
||||
| TerminatorKind::Terminate
|
||||
| TerminatorKind::UnwindResume
|
||||
| TerminatorKind::UnwindTerminate
|
||||
| TerminatorKind::Return
|
||||
| TerminatorKind::Unreachable { .. } => (),
|
||||
TerminatorKind::Drop { .. } => {
|
||||
|
@ -470,7 +470,7 @@ fn drop_flags_for_locs(&mut self) {
|
||||
// drop elaboration should handle that by itself
|
||||
continue;
|
||||
}
|
||||
TerminatorKind::Resume => {
|
||||
TerminatorKind::UnwindResume => {
|
||||
// It is possible for `Resume` to be patched
|
||||
// (in particular it can be patched to be replaced with
|
||||
// a Goto; see `MirPatch::new`).
|
||||
|
@ -1239,7 +1239,7 @@ fn can_unwind<'tcx>(tcx: TyCtxt<'tcx>, body: &Body<'tcx>) -> bool {
|
||||
// These never unwind.
|
||||
TerminatorKind::Goto { .. }
|
||||
| TerminatorKind::SwitchInt { .. }
|
||||
| TerminatorKind::Terminate
|
||||
| TerminatorKind::UnwindTerminate
|
||||
| TerminatorKind::Return
|
||||
| TerminatorKind::Unreachable
|
||||
| TerminatorKind::GeneratorDrop
|
||||
@ -1248,7 +1248,7 @@ fn can_unwind<'tcx>(tcx: TyCtxt<'tcx>, body: &Body<'tcx>) -> bool {
|
||||
|
||||
// Resume will *continue* unwinding, but if there's no other unwinding terminator it
|
||||
// will never be reached.
|
||||
TerminatorKind::Resume => {}
|
||||
TerminatorKind::UnwindResume => {}
|
||||
|
||||
TerminatorKind::Yield { .. } => {
|
||||
unreachable!("`can_unwind` called before generator transform")
|
||||
@ -1279,14 +1279,14 @@ fn create_generator_resume_function<'tcx>(
|
||||
let source_info = SourceInfo::outermost(body.span);
|
||||
let poison_block = body.basic_blocks_mut().push(BasicBlockData {
|
||||
statements: vec![transform.set_discr(VariantIdx::new(POISONED), source_info)],
|
||||
terminator: Some(Terminator { source_info, kind: TerminatorKind::Resume }),
|
||||
terminator: Some(Terminator { source_info, kind: TerminatorKind::UnwindResume }),
|
||||
is_cleanup: true,
|
||||
});
|
||||
|
||||
for (idx, block) in body.basic_blocks_mut().iter_enumerated_mut() {
|
||||
let source_info = block.terminator().source_info;
|
||||
|
||||
if let TerminatorKind::Resume = block.terminator().kind {
|
||||
if let TerminatorKind::UnwindResume = block.terminator().kind {
|
||||
// An existing `Resume` terminator is redirected to jump to our dedicated
|
||||
// "poisoning block" above.
|
||||
if idx != poison_block {
|
||||
@ -1758,8 +1758,8 @@ fn visit_terminator(&mut self, terminator: &Terminator<'tcx>, location: Location
|
||||
TerminatorKind::Call { .. }
|
||||
| TerminatorKind::Goto { .. }
|
||||
| TerminatorKind::SwitchInt { .. }
|
||||
| TerminatorKind::Resume
|
||||
| TerminatorKind::Terminate
|
||||
| TerminatorKind::UnwindResume
|
||||
| TerminatorKind::UnwindTerminate
|
||||
| TerminatorKind::Return
|
||||
| TerminatorKind::Unreachable
|
||||
| TerminatorKind::Drop { .. }
|
||||
|
@ -839,7 +839,7 @@ fn visit_terminator(&mut self, terminator: &Terminator<'tcx>, _: Location) {
|
||||
self.cost += LANDINGPAD_PENALTY;
|
||||
}
|
||||
}
|
||||
TerminatorKind::Resume => self.cost += RESUME_PENALTY,
|
||||
TerminatorKind::UnwindResume => self.cost += RESUME_PENALTY,
|
||||
TerminatorKind::InlineAsm { unwind, .. } => {
|
||||
self.cost += INSTR_COST;
|
||||
if let UnwindAction::Cleanup(_) = unwind {
|
||||
@ -1017,15 +1017,15 @@ fn visit_terminator(&mut self, terminator: &mut Terminator<'tcx>, loc: Location)
|
||||
TerminatorKind::Unreachable
|
||||
}
|
||||
}
|
||||
TerminatorKind::Resume => {
|
||||
TerminatorKind::UnwindResume => {
|
||||
terminator.kind = match self.cleanup_block {
|
||||
UnwindAction::Cleanup(tgt) => TerminatorKind::Goto { target: tgt },
|
||||
UnwindAction::Continue => TerminatorKind::Resume,
|
||||
UnwindAction::Continue => TerminatorKind::UnwindResume,
|
||||
UnwindAction::Unreachable => TerminatorKind::Unreachable,
|
||||
UnwindAction::Terminate => TerminatorKind::Terminate,
|
||||
UnwindAction::Terminate => TerminatorKind::UnwindTerminate,
|
||||
};
|
||||
}
|
||||
TerminatorKind::Terminate => {}
|
||||
TerminatorKind::UnwindTerminate => {}
|
||||
TerminatorKind::Unreachable => {}
|
||||
TerminatorKind::FalseEdge { ref mut real_target, ref mut imaginary_target } => {
|
||||
*real_target = self.map_block(*real_target);
|
||||
|
@ -63,7 +63,7 @@ fn is_nop_landing_pad(
|
||||
let terminator = body[bb].terminator();
|
||||
match terminator.kind {
|
||||
TerminatorKind::Goto { .. }
|
||||
| TerminatorKind::Resume
|
||||
| TerminatorKind::UnwindResume
|
||||
| TerminatorKind::SwitchInt { .. }
|
||||
| TerminatorKind::FalseEdge { .. }
|
||||
| TerminatorKind::FalseUnwind { .. } => {
|
||||
@ -72,7 +72,7 @@ fn is_nop_landing_pad(
|
||||
TerminatorKind::GeneratorDrop
|
||||
| TerminatorKind::Yield { .. }
|
||||
| TerminatorKind::Return
|
||||
| TerminatorKind::Terminate
|
||||
| TerminatorKind::UnwindTerminate
|
||||
| TerminatorKind::Unreachable
|
||||
| TerminatorKind::Call { .. }
|
||||
| TerminatorKind::Assert { .. }
|
||||
@ -88,7 +88,7 @@ fn remove_nop_landing_pads(&self, body: &mut Body<'_>) {
|
||||
let has_resume = body
|
||||
.basic_blocks
|
||||
.iter_enumerated()
|
||||
.any(|(_bb, block)| matches!(block.terminator().kind, TerminatorKind::Resume));
|
||||
.any(|(_bb, block)| matches!(block.terminator().kind, TerminatorKind::UnwindResume));
|
||||
if !has_resume {
|
||||
debug!("remove_noop_landing_pads: no resume block in MIR");
|
||||
return;
|
||||
|
@ -108,13 +108,13 @@ pub fn separate_const_switch(body: &mut Body<'_>) -> usize {
|
||||
}
|
||||
|
||||
// The following terminators are not allowed
|
||||
TerminatorKind::Resume
|
||||
TerminatorKind::UnwindResume
|
||||
| TerminatorKind::Drop { .. }
|
||||
| TerminatorKind::Call { .. }
|
||||
| TerminatorKind::Assert { .. }
|
||||
| TerminatorKind::FalseUnwind { .. }
|
||||
| TerminatorKind::Yield { .. }
|
||||
| TerminatorKind::Terminate
|
||||
| TerminatorKind::UnwindTerminate
|
||||
| TerminatorKind::Return
|
||||
| TerminatorKind::Unreachable
|
||||
| TerminatorKind::InlineAsm { .. }
|
||||
@ -165,8 +165,8 @@ pub fn separate_const_switch(body: &mut Body<'_>) -> usize {
|
||||
});
|
||||
}
|
||||
|
||||
TerminatorKind::Resume
|
||||
| TerminatorKind::Terminate
|
||||
TerminatorKind::UnwindResume
|
||||
| TerminatorKind::UnwindTerminate
|
||||
| TerminatorKind::Return
|
||||
| TerminatorKind::Unreachable
|
||||
| TerminatorKind::GeneratorDrop
|
||||
|
@ -583,7 +583,7 @@ fn tuple_like_shim<I>(&mut self, dest: Place<'tcx>, src: Place<'tcx>, tys: I)
|
||||
I: IntoIterator<Item = Ty<'tcx>>,
|
||||
{
|
||||
self.block(vec![], TerminatorKind::Goto { target: self.block_index_offset(3) }, false);
|
||||
let unwind = self.block(vec![], TerminatorKind::Resume, true);
|
||||
let unwind = self.block(vec![], TerminatorKind::UnwindResume, true);
|
||||
let target = self.block(vec![], TerminatorKind::Return, false);
|
||||
|
||||
let _final_cleanup_block = self.clone_fields(dest, src, target, unwind, tys);
|
||||
@ -597,7 +597,7 @@ fn generator_shim(
|
||||
args: GeneratorArgs<'tcx>,
|
||||
) {
|
||||
self.block(vec![], TerminatorKind::Goto { target: self.block_index_offset(3) }, false);
|
||||
let unwind = self.block(vec![], TerminatorKind::Resume, true);
|
||||
let unwind = self.block(vec![], TerminatorKind::UnwindResume, true);
|
||||
// This will get overwritten with a switch once we know the target blocks
|
||||
let switch = self.block(vec![], TerminatorKind::Unreachable, false);
|
||||
let unwind = self.clone_fields(dest, src, switch, unwind, args.upvar_tys());
|
||||
@ -854,7 +854,7 @@ fn build_call_shim<'tcx>(
|
||||
);
|
||||
|
||||
// BB #4 - resume
|
||||
block(&mut blocks, vec![], TerminatorKind::Resume, true);
|
||||
block(&mut blocks, vec![], TerminatorKind::UnwindResume, true);
|
||||
}
|
||||
|
||||
let mut body =
|
||||
|
@ -776,7 +776,7 @@ fn visit_terminator(&mut self, terminator: &mir::Terminator<'tcx>, location: Loc
|
||||
self.output.push(create_fn_mono_item(tcx, instance, source));
|
||||
}
|
||||
}
|
||||
mir::TerminatorKind::Terminate { .. } => {
|
||||
mir::TerminatorKind::UnwindTerminate { .. } => {
|
||||
let instance = Instance::mono(
|
||||
tcx,
|
||||
tcx.require_lang_item(LangItem::PanicCannotUnwind, Some(source)),
|
||||
@ -787,7 +787,7 @@ fn visit_terminator(&mut self, terminator: &mir::Terminator<'tcx>, location: Loc
|
||||
}
|
||||
mir::TerminatorKind::Goto { .. }
|
||||
| mir::TerminatorKind::SwitchInt { .. }
|
||||
| mir::TerminatorKind::Resume
|
||||
| mir::TerminatorKind::UnwindResume
|
||||
| mir::TerminatorKind::Return
|
||||
| mir::TerminatorKind::Unreachable => {}
|
||||
mir::TerminatorKind::GeneratorDrop
|
||||
|
@ -780,8 +780,8 @@ fn stable(&self, tables: &mut Tables<'tcx>) -> Self::T {
|
||||
.collect(),
|
||||
otherwise: targets.otherwise().as_usize(),
|
||||
},
|
||||
Resume => Terminator::Resume,
|
||||
Terminate => Terminator::Abort,
|
||||
UnwindResume => Terminator::Resume,
|
||||
UnwindTerminate => Terminator::Abort,
|
||||
Return => Terminator::Return,
|
||||
Unreachable => Terminator::Unreachable,
|
||||
Drop { place, target, unwind, replace: _ } => Terminator::Drop {
|
||||
|
@ -291,8 +291,8 @@ fn check_terminator<'tcx>(
|
||||
| TerminatorKind::FalseUnwind { .. }
|
||||
| TerminatorKind::Goto { .. }
|
||||
| TerminatorKind::Return
|
||||
| TerminatorKind::Resume
|
||||
| TerminatorKind::Terminate
|
||||
| TerminatorKind::UnwindResume
|
||||
| TerminatorKind::UnwindTerminate
|
||||
| TerminatorKind::Unreachable => Ok(()),
|
||||
TerminatorKind::Drop { place, .. } => {
|
||||
if !is_ty_const_destruct(tcx, place.ty(&body.local_decls, tcx).ty, body) {
|
||||
|
@ -1057,7 +1057,7 @@ fn for_operand(op: &mut Operand, f: &mut impl FnMut(&mut Place)) {
|
||||
TerminatorKind::FalseEdge { .. }
|
||||
| TerminatorKind::FalseUnwind { .. }
|
||||
| TerminatorKind::Goto { .. }
|
||||
| TerminatorKind::Resume
|
||||
| TerminatorKind::UnwindResume
|
||||
| TerminatorKind::GeneratorDrop
|
||||
| TerminatorKind::Abort
|
||||
| TerminatorKind::Return
|
||||
|
@ -160,7 +160,7 @@ fn moved_out_of_ref(db: &dyn HirDatabase, body: &MirBody) -> Vec<MovedOutOfRef>
|
||||
TerminatorKind::FalseEdge { .. }
|
||||
| TerminatorKind::FalseUnwind { .. }
|
||||
| TerminatorKind::Goto { .. }
|
||||
| TerminatorKind::Resume
|
||||
| TerminatorKind::UnwindResume
|
||||
| TerminatorKind::GeneratorDrop
|
||||
| TerminatorKind::Abort
|
||||
| TerminatorKind::Return
|
||||
@ -280,7 +280,7 @@ fn dfs(
|
||||
let targets = match &terminator.kind {
|
||||
TerminatorKind::Goto { target } => vec![*target],
|
||||
TerminatorKind::SwitchInt { targets, .. } => targets.all_targets().to_vec(),
|
||||
TerminatorKind::Resume
|
||||
TerminatorKind::UnwindResume
|
||||
| TerminatorKind::Abort
|
||||
| TerminatorKind::Return
|
||||
| TerminatorKind::Unreachable => vec![],
|
||||
@ -371,7 +371,7 @@ fn mutability_of_locals(
|
||||
};
|
||||
match &terminator.kind {
|
||||
TerminatorKind::Goto { .. }
|
||||
| TerminatorKind::Resume
|
||||
| TerminatorKind::UnwindResume
|
||||
| TerminatorKind::Abort
|
||||
| TerminatorKind::Return
|
||||
| TerminatorKind::Unreachable
|
||||
|
@ -265,7 +265,7 @@ fn fill_body(&mut self, body: &mut MirBody) -> Result<(), MirLowerError> {
|
||||
self.fill_operand(discr)?;
|
||||
}
|
||||
TerminatorKind::Goto { .. }
|
||||
| TerminatorKind::Resume
|
||||
| TerminatorKind::UnwindResume
|
||||
| TerminatorKind::Abort
|
||||
| TerminatorKind::Return
|
||||
| TerminatorKind::Unreachable
|
||||
|
Loading…
Reference in New Issue
Block a user