summaryrefslogtreecommitdiff
path: root/compiler/rustc_mir_dataflow
diff options
context:
space:
mode:
authorGary Guo <gary@garyguo.net>2022-10-08 23:47:59 +0100
committerGary Guo <gary@garyguo.net>2023-04-06 09:34:16 +0100
commitdaeb844e0ccddb9e058128974b290f2022e88be7 (patch)
tree2d0be78154d1f2748841b79cded649158b2a012a /compiler/rustc_mir_dataflow
parent7f6edd3f15f75f0df70027edee2a520820d14217 (diff)
downloadrust-daeb844e0ccddb9e058128974b290f2022e88be7.tar.gz
Refactor unwind from Option to a new enum
Diffstat (limited to 'compiler/rustc_mir_dataflow')
-rw-r--r--compiler/rustc_mir_dataflow/src/elaborate_drops.rs16
-rw-r--r--compiler/rustc_mir_dataflow/src/framework/direction.rs14
-rw-r--r--compiler/rustc_mir_dataflow/src/framework/tests.rs4
-rw-r--r--compiler/rustc_mir_dataflow/src/move_paths/builder.rs4
4 files changed, 19 insertions, 19 deletions
diff --git a/compiler/rustc_mir_dataflow/src/elaborate_drops.rs b/compiler/rustc_mir_dataflow/src/elaborate_drops.rs
index 7ef3d41ac48..70ed0c22640 100644
--- a/compiler/rustc_mir_dataflow/src/elaborate_drops.rs
+++ b/compiler/rustc_mir_dataflow/src/elaborate_drops.rs
@@ -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)
}
diff --git a/compiler/rustc_mir_dataflow/src/framework/direction.rs b/compiler/rustc_mir_dataflow/src/framework/direction.rs
index a40c38aa4c3..a078c6b550e 100644
--- a/compiler/rustc_mir_dataflow/src/framework/direction.rs
+++ b/compiler/rustc_mir_dataflow/src/framework/direction.rs
@@ -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);
}
diff --git a/compiler/rustc_mir_dataflow/src/framework/tests.rs b/compiler/rustc_mir_dataflow/src/framework/tests.rs
index 17102454a88..60679b17d6c 100644
--- a/compiler/rustc_mir_dataflow/src/framework/tests.rs
+++ b/compiler/rustc_mir_dataflow/src/framework/tests.rs
@@ -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,
},
diff --git a/compiler/rustc_mir_dataflow/src/move_paths/builder.rs b/compiler/rustc_mir_dataflow/src/move_paths/builder.rs
index d9ceac1154f..9f9a5c94b56 100644
--- a/compiler/rustc_mir_dataflow/src/move_paths/builder.rs
+++ b/compiler/rustc_mir_dataflow/src/move_paths/builder.rs
@@ -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 {