Refactor unwind from Option to a new enum
This commit is contained in:
@@ -171,7 +171,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
||||
args: vec![Operand::Move(size), Operand::Move(align)],
|
||||
destination: storage,
|
||||
target: Some(success),
|
||||
cleanup: None,
|
||||
unwind: UnwindAction::Continue,
|
||||
from_hir_call: false,
|
||||
fn_span: expr_span,
|
||||
},
|
||||
@@ -702,7 +702,11 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
||||
this.cfg.terminate(
|
||||
block,
|
||||
outer_source_info,
|
||||
TerminatorKind::Drop { place: to_drop, target: success, unwind: None },
|
||||
TerminatorKind::Drop {
|
||||
place: to_drop,
|
||||
target: success,
|
||||
unwind: UnwindAction::Continue,
|
||||
},
|
||||
);
|
||||
this.diverge_from(block);
|
||||
block = success;
|
||||
|
||||
@@ -228,7 +228,10 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
||||
this.cfg.terminate(
|
||||
loop_block,
|
||||
source_info,
|
||||
TerminatorKind::FalseUnwind { real_target: body_block, unwind: None },
|
||||
TerminatorKind::FalseUnwind {
|
||||
real_target: body_block,
|
||||
unwind: UnwindAction::Continue,
|
||||
},
|
||||
);
|
||||
this.diverge_from(loop_block);
|
||||
|
||||
@@ -264,7 +267,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
||||
TerminatorKind::Call {
|
||||
func: fun,
|
||||
args,
|
||||
cleanup: None,
|
||||
unwind: UnwindAction::Continue,
|
||||
destination,
|
||||
// The presence or absence of a return edge affects control-flow sensitive
|
||||
// MIR checks and ultimately whether code is accepted or not. We can only
|
||||
@@ -466,7 +469,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
||||
} else {
|
||||
Some(destination_block)
|
||||
},
|
||||
cleanup: None,
|
||||
unwind: UnwindAction::Continue,
|
||||
},
|
||||
);
|
||||
if options.contains(InlineAsmOptions::MAY_UNWIND) {
|
||||
|
||||
@@ -263,7 +263,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
||||
args: vec![Operand::Move(ref_string)],
|
||||
destination: ref_str,
|
||||
target: Some(eq_block),
|
||||
cleanup: None,
|
||||
unwind: UnwindAction::Continue,
|
||||
from_hir_call: false,
|
||||
fn_span: source_info.span
|
||||
}
|
||||
@@ -466,7 +466,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
||||
args: vec![val, expect],
|
||||
destination: eq_result,
|
||||
target: Some(eq_block),
|
||||
cleanup: None,
|
||||
unwind: UnwindAction::Continue,
|
||||
from_hir_call: false,
|
||||
fn_span: source_info.span,
|
||||
},
|
||||
|
||||
@@ -369,7 +369,7 @@ impl DropTree {
|
||||
let terminator = TerminatorKind::Drop {
|
||||
target: blocks[drop_data.1].unwrap(),
|
||||
// The caller will handle this if needed.
|
||||
unwind: None,
|
||||
unwind: UnwindAction::Continue,
|
||||
place: drop_data.0.local.into(),
|
||||
};
|
||||
cfg.terminate(block, drop_data.0.source_info, terminator);
|
||||
@@ -1141,7 +1141,11 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
||||
self.cfg.terminate(
|
||||
block,
|
||||
source_info,
|
||||
TerminatorKind::Drop { place, target: assign, unwind: Some(assign_unwind) },
|
||||
TerminatorKind::Drop {
|
||||
place,
|
||||
target: assign,
|
||||
unwind: UnwindAction::Cleanup(assign_unwind),
|
||||
},
|
||||
);
|
||||
self.diverge_from(block);
|
||||
|
||||
@@ -1165,7 +1169,13 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
||||
self.cfg.terminate(
|
||||
block,
|
||||
source_info,
|
||||
TerminatorKind::Assert { cond, expected, msg, target: success_block, cleanup: None },
|
||||
TerminatorKind::Assert {
|
||||
cond,
|
||||
expected,
|
||||
msg,
|
||||
target: success_block,
|
||||
unwind: UnwindAction::Continue,
|
||||
},
|
||||
);
|
||||
self.diverge_from(block);
|
||||
|
||||
@@ -1244,7 +1254,11 @@ fn build_scope_drops<'tcx>(
|
||||
cfg.terminate(
|
||||
block,
|
||||
source_info,
|
||||
TerminatorKind::Drop { place: local.into(), target: next, unwind: None },
|
||||
TerminatorKind::Drop {
|
||||
place: local.into(),
|
||||
target: next,
|
||||
unwind: UnwindAction::Continue,
|
||||
},
|
||||
);
|
||||
block = next;
|
||||
}
|
||||
@@ -1432,10 +1446,10 @@ impl<'tcx> DropTreeBuilder<'tcx> for Unwind {
|
||||
}
|
||||
}
|
||||
TerminatorKind::FalseUnwind { unwind, .. }
|
||||
| TerminatorKind::Call { cleanup: unwind, .. }
|
||||
| TerminatorKind::Assert { cleanup: unwind, .. }
|
||||
| TerminatorKind::InlineAsm { cleanup: unwind, .. } => {
|
||||
*unwind = Some(to);
|
||||
| TerminatorKind::Call { unwind, .. }
|
||||
| TerminatorKind::Assert { unwind, .. }
|
||||
| TerminatorKind::InlineAsm { unwind, .. } => {
|
||||
*unwind = UnwindAction::Cleanup(to);
|
||||
}
|
||||
TerminatorKind::Goto { .. }
|
||||
| TerminatorKind::SwitchInt { .. }
|
||||
|
||||
Reference in New Issue
Block a user