Skip to content

Commit 818ec8e

Browse files
committed
give some unwind-related terminators a more clear name
1 parent c0b6ffa commit 818ec8e

File tree

39 files changed

+123
-117
lines changed

39 files changed

+123
-117
lines changed

compiler/rustc_borrowck/src/invalidation.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,9 @@ impl<'cx, 'tcx> Visitor<'tcx> for InvalidationGenerator<'cx, 'tcx> {
159159

160160
self.mutate_place(location, *resume_arg, Deep);
161161
}
162-
TerminatorKind::Resume | TerminatorKind::Return | TerminatorKind::GeneratorDrop => {
162+
TerminatorKind::UnwindResume
163+
| TerminatorKind::Return
164+
| TerminatorKind::GeneratorDrop => {
163165
// Invalidate all borrows of local places
164166
let borrow_set = self.borrow_set;
165167
let start = self.location_table.start_index(location);
@@ -200,7 +202,7 @@ impl<'cx, 'tcx> Visitor<'tcx> for InvalidationGenerator<'cx, 'tcx> {
200202
}
201203
}
202204
TerminatorKind::Goto { target: _ }
203-
| TerminatorKind::Terminate
205+
| TerminatorKind::UnwindTerminate
204206
| TerminatorKind::Unreachable
205207
| TerminatorKind::FalseEdge { real_target: _, imaginary_target: _ }
206208
| TerminatorKind::FalseUnwind { real_target: _, unwind: _ } => {

compiler/rustc_borrowck/src/lib.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -770,9 +770,9 @@ impl<'cx, 'tcx, R> rustc_mir_dataflow::ResultsVisitor<'cx, 'tcx, R> for MirBorro
770770
}
771771

772772
TerminatorKind::Goto { target: _ }
773-
| TerminatorKind::Terminate
773+
| TerminatorKind::UnwindTerminate
774774
| TerminatorKind::Unreachable
775-
| TerminatorKind::Resume
775+
| TerminatorKind::UnwindResume
776776
| TerminatorKind::Return
777777
| TerminatorKind::GeneratorDrop
778778
| TerminatorKind::FalseEdge { real_target: _, imaginary_target: _ }
@@ -803,7 +803,9 @@ impl<'cx, 'tcx, R> rustc_mir_dataflow::ResultsVisitor<'cx, 'tcx, R> for MirBorro
803803
}
804804
}
805805

806-
TerminatorKind::Resume | TerminatorKind::Return | TerminatorKind::GeneratorDrop => {
806+
TerminatorKind::UnwindResume
807+
| TerminatorKind::Return
808+
| TerminatorKind::GeneratorDrop => {
807809
// Returning from the function implicitly kills storage for all locals and statics.
808810
// Often, the storage will already have been killed by an explicit
809811
// StorageDead, but we don't always emit those (notably on unwind paths),
@@ -815,7 +817,7 @@ impl<'cx, 'tcx, R> rustc_mir_dataflow::ResultsVisitor<'cx, 'tcx, R> for MirBorro
815817
}
816818
}
817819

818-
TerminatorKind::Terminate
820+
TerminatorKind::UnwindTerminate
819821
| TerminatorKind::Assert { .. }
820822
| TerminatorKind::Call { .. }
821823
| TerminatorKind::Drop { .. }

compiler/rustc_borrowck/src/type_check/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1333,8 +1333,8 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
13331333
debug!("terminator kind: {:?}", term.kind);
13341334
match &term.kind {
13351335
TerminatorKind::Goto { .. }
1336-
| TerminatorKind::Resume
1337-
| TerminatorKind::Terminate
1336+
| TerminatorKind::UnwindResume
1337+
| TerminatorKind::UnwindTerminate
13381338
| TerminatorKind::Return
13391339
| TerminatorKind::GeneratorDrop
13401340
| TerminatorKind::Unreachable
@@ -1608,12 +1608,12 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
16081608
self.assert_iscleanup(body, block_data, *target, is_cleanup);
16091609
}
16101610
}
1611-
TerminatorKind::Resume => {
1611+
TerminatorKind::UnwindResume => {
16121612
if !is_cleanup {
16131613
span_mirbug!(self, block_data, "resume on non-cleanup block!")
16141614
}
16151615
}
1616-
TerminatorKind::Terminate => {
1616+
TerminatorKind::UnwindTerminate => {
16171617
if !is_cleanup {
16181618
span_mirbug!(self, block_data, "abort on non-cleanup block!")
16191619
}

compiler/rustc_codegen_cranelift/src/base.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -474,10 +474,10 @@ fn codegen_fn_body(fx: &mut FunctionCx<'_, '_, '_>, start_block: Block) {
474474
*destination,
475475
);
476476
}
477-
TerminatorKind::Terminate => {
477+
TerminatorKind::UnwindTerminate => {
478478
codegen_panic_cannot_unwind(fx, source_info);
479479
}
480-
TerminatorKind::Resume => {
480+
TerminatorKind::UnwindResume => {
481481
// FIXME implement unwinding
482482
fx.bcx.ins().trap(TrapCode::UnreachableCodeReached);
483483
}

compiler/rustc_codegen_cranelift/src/constant.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -550,8 +550,8 @@ pub(crate) fn mir_operand_get_const_val<'tcx>(
550550
match &bb_data.terminator().kind {
551551
TerminatorKind::Goto { .. }
552552
| TerminatorKind::SwitchInt { .. }
553-
| TerminatorKind::Resume
554-
| TerminatorKind::Terminate
553+
| TerminatorKind::UnwindResume
554+
| TerminatorKind::UnwindTerminate
555555
| TerminatorKind::Return
556556
| TerminatorKind::Unreachable
557557
| TerminatorKind::Drop { .. }

compiler/rustc_codegen_ssa/src/mir/analyze.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -284,8 +284,8 @@ pub fn cleanup_kinds(mir: &mir::Body<'_>) -> IndexVec<mir::BasicBlock, CleanupKi
284284
for (bb, data) in mir.basic_blocks.iter_enumerated() {
285285
match data.terminator().kind {
286286
TerminatorKind::Goto { .. }
287-
| TerminatorKind::Resume
288-
| TerminatorKind::Terminate
287+
| TerminatorKind::UnwindResume
288+
| TerminatorKind::UnwindTerminate
289289
| TerminatorKind::Return
290290
| TerminatorKind::GeneratorDrop
291291
| TerminatorKind::Unreachable

compiler/rustc_codegen_ssa/src/mir/block.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1224,12 +1224,12 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
12241224

12251225
self.set_debug_loc(bx, terminator.source_info);
12261226
match terminator.kind {
1227-
mir::TerminatorKind::Resume => {
1227+
mir::TerminatorKind::UnwindResume => {
12281228
self.codegen_resume_terminator(helper, bx);
12291229
MergingSucc::False
12301230
}
12311231

1232-
mir::TerminatorKind::Terminate => {
1232+
mir::TerminatorKind::UnwindTerminate => {
12331233
self.codegen_terminate_terminator(helper, bx, terminator);
12341234
MergingSucc::False
12351235
}

compiler/rustc_const_eval/src/interpret/terminator.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,15 +196,15 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
196196
}
197197
}
198198

199-
Terminate => {
199+
UnwindTerminate => {
200200
// FIXME: maybe should call `panic_no_unwind` lang item instead.
201201
M::abort(self, "panic in a function that cannot unwind".to_owned())?;
202202
}
203203

204204
// When we encounter Resume, we've finished unwinding
205205
// cleanup for the current stack frame. We pop it in order
206206
// to continue unwinding the next frame
207-
Resume => {
207+
UnwindResume => {
208208
trace!("unwinding: resuming from cleanup");
209209
// By definition, a Resume terminator means
210210
// that we're unwinding

compiler/rustc_const_eval/src/transform/check_consts/check.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1037,7 +1037,7 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> {
10371037
self.check_op(ops::Generator(hir::GeneratorKind::Gen))
10381038
}
10391039

1040-
TerminatorKind::Terminate => {
1040+
TerminatorKind::UnwindTerminate => {
10411041
// Cleanup blocks are skipped for const checking (see `visit_basic_block_data`).
10421042
span_bug!(self.span, "`Terminate` terminator outside of cleanup block")
10431043
}
@@ -1046,7 +1046,7 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> {
10461046
| TerminatorKind::FalseEdge { .. }
10471047
| TerminatorKind::FalseUnwind { .. }
10481048
| TerminatorKind::Goto { .. }
1049-
| TerminatorKind::Resume
1049+
| TerminatorKind::UnwindResume
10501050
| TerminatorKind::Return
10511051
| TerminatorKind::SwitchInt { .. }
10521052
| TerminatorKind::Unreachable => {}

compiler/rustc_const_eval/src/transform/check_consts/post_drop_elaboration.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,15 +106,15 @@ impl<'tcx> Visitor<'tcx> for CheckLiveDrops<'_, 'tcx> {
106106
}
107107
}
108108

109-
mir::TerminatorKind::Terminate
109+
mir::TerminatorKind::UnwindTerminate
110110
| mir::TerminatorKind::Call { .. }
111111
| mir::TerminatorKind::Assert { .. }
112112
| mir::TerminatorKind::FalseEdge { .. }
113113
| mir::TerminatorKind::FalseUnwind { .. }
114114
| mir::TerminatorKind::GeneratorDrop
115115
| mir::TerminatorKind::Goto { .. }
116116
| mir::TerminatorKind::InlineAsm { .. }
117-
| mir::TerminatorKind::Resume
117+
| mir::TerminatorKind::UnwindResume
118118
| mir::TerminatorKind::Return
119119
| mir::TerminatorKind::SwitchInt { .. }
120120
| mir::TerminatorKind::Unreachable

compiler/rustc_const_eval/src/transform/validate.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -492,19 +492,19 @@ impl<'a, 'tcx> Visitor<'tcx> for CfgChecker<'a, 'tcx> {
492492
);
493493
}
494494
}
495-
TerminatorKind::Resume => {
495+
TerminatorKind::UnwindResume => {
496496
let bb = location.block;
497497
if !self.body.basic_blocks[bb].is_cleanup {
498-
self.fail(location, "Cannot `Resume` from non-cleanup basic block")
498+
self.fail(location, "Cannot `UnwindResume` from non-cleanup basic block")
499499
}
500500
if !self.can_unwind {
501-
self.fail(location, "Cannot `Resume` in a function that cannot unwind")
501+
self.fail(location, "Cannot `UnwindResume` in a function that cannot unwind")
502502
}
503503
}
504-
TerminatorKind::Terminate => {
504+
TerminatorKind::UnwindTerminate => {
505505
let bb = location.block;
506506
if !self.body.basic_blocks[bb].is_cleanup {
507-
self.fail(location, "Cannot `Terminate` from non-cleanup basic block")
507+
self.fail(location, "Cannot `UnwindTerminate` from non-cleanup basic block")
508508
}
509509
}
510510
TerminatorKind::Return => {
@@ -1232,8 +1232,8 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
12321232
| TerminatorKind::FalseUnwind { .. }
12331233
| TerminatorKind::InlineAsm { .. }
12341234
| TerminatorKind::GeneratorDrop
1235-
| TerminatorKind::Resume
1236-
| TerminatorKind::Terminate
1235+
| TerminatorKind::UnwindResume
1236+
| TerminatorKind::UnwindTerminate
12371237
| TerminatorKind::Return
12381238
| TerminatorKind::Unreachable => {}
12391239
}

compiler/rustc_middle/src/mir/patch.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ impl<'tcx> MirPatch<'tcx> {
3535

3636
for (bb, block) in body.basic_blocks.iter_enumerated() {
3737
// Check if we already have a resume block
38-
if let TerminatorKind::Resume = block.terminator().kind && block.statements.is_empty() {
38+
if let TerminatorKind::UnwindResume = block.terminator().kind && block.statements.is_empty() {
3939
result.resume_block = Some(bb);
4040
continue;
4141
}
@@ -50,7 +50,7 @@ impl<'tcx> MirPatch<'tcx> {
5050
}
5151

5252
// Check if we already have a terminate block
53-
if let TerminatorKind::Terminate = block.terminator().kind && block.statements.is_empty() {
53+
if let TerminatorKind::UnwindTerminate = block.terminator().kind && block.statements.is_empty() {
5454
result.terminate_block = Some(bb);
5555
continue;
5656
}
@@ -68,7 +68,7 @@ impl<'tcx> MirPatch<'tcx> {
6868
statements: vec![],
6969
terminator: Some(Terminator {
7070
source_info: SourceInfo::outermost(self.body_span),
71-
kind: TerminatorKind::Resume,
71+
kind: TerminatorKind::UnwindResume,
7272
}),
7373
is_cleanup: true,
7474
});
@@ -102,7 +102,7 @@ impl<'tcx> MirPatch<'tcx> {
102102
statements: vec![],
103103
terminator: Some(Terminator {
104104
source_info: SourceInfo::outermost(self.body_span),
105-
kind: TerminatorKind::Terminate,
105+
kind: TerminatorKind::UnwindTerminate,
106106
}),
107107
is_cleanup: true,
108108
});

compiler/rustc_middle/src/mir/spanview.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,8 +262,8 @@ pub fn terminator_kind_name(term: &Terminator<'_>) -> &'static str {
262262
match term.kind {
263263
Goto { .. } => "Goto",
264264
SwitchInt { .. } => "SwitchInt",
265-
Resume => "Resume",
266-
Terminate => "Terminate",
265+
UnwindResume => "Resume",
266+
UnwindTerminate => "Terminate",
267267
Return => "Return",
268268
Unreachable => "Unreachable",
269269
Drop { .. } => "Drop",

compiler/rustc_middle/src/mir/syntax.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -593,13 +593,13 @@ pub enum TerminatorKind<'tcx> {
593593
///
594594
/// Only permitted in cleanup blocks. `Resume` is not permitted with `-C unwind=abort` after
595595
/// deaggregation runs.
596-
Resume,
596+
UnwindResume,
597597

598598
/// Indicates that the landing pad is finished and that the process should terminate.
599599
///
600600
/// Used to prevent unwinding for foreign items or with `-C unwind=abort`. Only permitted in
601601
/// cleanup blocks.
602-
Terminate,
602+
UnwindTerminate,
603603

604604
/// Returns from the function.
605605
///
@@ -790,8 +790,8 @@ impl TerminatorKind<'_> {
790790
match self {
791791
TerminatorKind::Goto { .. } => "Goto",
792792
TerminatorKind::SwitchInt { .. } => "SwitchInt",
793-
TerminatorKind::Resume => "Resume",
794-
TerminatorKind::Terminate => "Terminate",
793+
TerminatorKind::UnwindResume => "Resume",
794+
TerminatorKind::UnwindTerminate => "Terminate",
795795
TerminatorKind::Return => "Return",
796796
TerminatorKind::Unreachable => "Unreachable",
797797
TerminatorKind::Drop { .. } => "Drop",

compiler/rustc_middle/src/mir/terminator.rs

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,8 @@ impl<'tcx> TerminatorKind<'tcx> {
155155
| InlineAsm { destination: Some(t), unwind: _, .. } => {
156156
Some(t).into_iter().chain((&[]).into_iter().copied())
157157
}
158-
Resume
159-
| Terminate
158+
UnwindResume
159+
| UnwindTerminate
160160
| GeneratorDrop
161161
| Return
162162
| Unreachable
@@ -197,8 +197,8 @@ impl<'tcx> TerminatorKind<'tcx> {
197197
| InlineAsm { destination: Some(ref mut t), unwind: _, .. } => {
198198
Some(t).into_iter().chain(&mut [])
199199
}
200-
Resume
201-
| Terminate
200+
UnwindResume
201+
| UnwindTerminate
202202
| GeneratorDrop
203203
| Return
204204
| Unreachable
@@ -214,8 +214,8 @@ impl<'tcx> TerminatorKind<'tcx> {
214214
pub fn unwind(&self) -> Option<&UnwindAction> {
215215
match *self {
216216
TerminatorKind::Goto { .. }
217-
| TerminatorKind::Resume
218-
| TerminatorKind::Terminate
217+
| TerminatorKind::UnwindResume
218+
| TerminatorKind::UnwindTerminate
219219
| TerminatorKind::Return
220220
| TerminatorKind::Unreachable
221221
| TerminatorKind::GeneratorDrop
@@ -233,8 +233,8 @@ impl<'tcx> TerminatorKind<'tcx> {
233233
pub fn unwind_mut(&mut self) -> Option<&mut UnwindAction> {
234234
match *self {
235235
TerminatorKind::Goto { .. }
236-
| TerminatorKind::Resume
237-
| TerminatorKind::Terminate
236+
| TerminatorKind::UnwindResume
237+
| TerminatorKind::UnwindTerminate
238238
| TerminatorKind::Return
239239
| TerminatorKind::Unreachable
240240
| TerminatorKind::GeneratorDrop
@@ -311,8 +311,8 @@ impl<'tcx> TerminatorKind<'tcx> {
311311
SwitchInt { discr, .. } => write!(fmt, "switchInt({discr:?})"),
312312
Return => write!(fmt, "return"),
313313
GeneratorDrop => write!(fmt, "generator_drop"),
314-
Resume => write!(fmt, "resume"),
315-
Terminate => write!(fmt, "abort"),
314+
UnwindResume => write!(fmt, "resume"),
315+
UnwindTerminate => write!(fmt, "abort"),
316316
Yield { value, resume_arg, .. } => write!(fmt, "{resume_arg:?} = yield({value:?})"),
317317
Unreachable => write!(fmt, "unreachable"),
318318
Drop { place, .. } => write!(fmt, "drop({place:?})"),
@@ -391,7 +391,7 @@ impl<'tcx> TerminatorKind<'tcx> {
391391
pub fn fmt_successor_labels(&self) -> Vec<Cow<'static, str>> {
392392
use self::TerminatorKind::*;
393393
match *self {
394-
Return | Resume | Terminate | Unreachable | GeneratorDrop => vec![],
394+
Return | UnwindResume | UnwindTerminate | Unreachable | GeneratorDrop => vec![],
395395
Goto { .. } => vec!["".into()],
396396
SwitchInt { ref targets, .. } => targets
397397
.values
@@ -486,7 +486,9 @@ impl<'tcx> TerminatorKind<'tcx> {
486486
pub fn edges(&self) -> TerminatorEdges<'_, 'tcx> {
487487
use TerminatorKind::*;
488488
match *self {
489-
Return | Resume | Terminate | GeneratorDrop | Unreachable => TerminatorEdges::None,
489+
Return | UnwindResume | UnwindTerminate | GeneratorDrop | Unreachable => {
490+
TerminatorEdges::None
491+
}
490492

491493
Goto { target } => TerminatorEdges::Single(target),
492494

compiler/rustc_middle/src/mir/visit.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -469,8 +469,8 @@ macro_rules! make_mir_visitor {
469469
self.visit_source_info(source_info);
470470
match kind {
471471
TerminatorKind::Goto { .. } |
472-
TerminatorKind::Resume |
473-
TerminatorKind::Terminate |
472+
TerminatorKind::UnwindResume |
473+
TerminatorKind::UnwindTerminate |
474474
TerminatorKind::GeneratorDrop |
475475
TerminatorKind::Unreachable |
476476
TerminatorKind::FalseEdge { .. } |

0 commit comments

Comments
 (0)