Skip to content

Commit e3f2edc

Browse files
committed
Rename Abort terminator to Terminate
Unify terminology used in unwind action and terminator, and reflect the fact that a nounwind panic is triggered instead of an immediate abort is triggered for this terminator.
1 parent 0a5dac3 commit e3f2edc

File tree

36 files changed

+112
-67
lines changed

36 files changed

+112
-67
lines changed

compiler/rustc_borrowck/src/invalidation.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ impl<'cx, 'tcx> Visitor<'tcx> for InvalidationGenerator<'cx, 'tcx> {
198198
}
199199
}
200200
TerminatorKind::Goto { target: _ }
201-
| TerminatorKind::Abort
201+
| TerminatorKind::Terminate
202202
| TerminatorKind::Unreachable
203203
| TerminatorKind::FalseEdge { real_target: _, imaginary_target: _ }
204204
| TerminatorKind::FalseUnwind { real_target: _, unwind: _ } => {

compiler/rustc_borrowck/src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -801,7 +801,7 @@ impl<'cx, 'tcx> rustc_mir_dataflow::ResultsVisitor<'cx, 'tcx> for MirBorrowckCtx
801801
}
802802

803803
TerminatorKind::Goto { target: _ }
804-
| TerminatorKind::Abort
804+
| TerminatorKind::Terminate
805805
| TerminatorKind::Unreachable
806806
| TerminatorKind::Resume
807807
| TerminatorKind::Return
@@ -845,7 +845,7 @@ impl<'cx, 'tcx> rustc_mir_dataflow::ResultsVisitor<'cx, 'tcx> for MirBorrowckCtx
845845
}
846846
}
847847

848-
TerminatorKind::Abort
848+
TerminatorKind::Terminate
849849
| TerminatorKind::Assert { .. }
850850
| TerminatorKind::Call { .. }
851851
| TerminatorKind::Drop { .. }

compiler/rustc_borrowck/src/type_check/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1300,7 +1300,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
13001300
match &term.kind {
13011301
TerminatorKind::Goto { .. }
13021302
| TerminatorKind::Resume
1303-
| TerminatorKind::Abort
1303+
| TerminatorKind::Terminate
13041304
| TerminatorKind::Return
13051305
| TerminatorKind::GeneratorDrop
13061306
| TerminatorKind::Unreachable
@@ -1584,7 +1584,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
15841584
span_mirbug!(self, block_data, "resume on non-cleanup block!")
15851585
}
15861586
}
1587-
TerminatorKind::Abort => {
1587+
TerminatorKind::Terminate => {
15881588
if !is_cleanup {
15891589
span_mirbug!(self, block_data, "abort on non-cleanup block!")
15901590
}

compiler/rustc_codegen_cranelift/src/base.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,7 @@ fn codegen_fn_body(fx: &mut FunctionCx<'_, '_, '_>, start_block: Block) {
488488
*destination,
489489
);
490490
}
491-
TerminatorKind::Abort => {
491+
TerminatorKind::Terminate => {
492492
codegen_panic_cannot_unwind(fx, source_info);
493493
}
494494
TerminatorKind::Resume => {

compiler/rustc_codegen_cranelift/src/constant.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,7 @@ pub(crate) fn mir_operand_get_const_val<'tcx>(
549549
TerminatorKind::Goto { .. }
550550
| TerminatorKind::SwitchInt { .. }
551551
| TerminatorKind::Resume
552-
| TerminatorKind::Abort
552+
| TerminatorKind::Terminate
553553
| TerminatorKind::Return
554554
| TerminatorKind::Unreachable
555555
| TerminatorKind::Drop { .. }

compiler/rustc_codegen_ssa/src/mir/analyze.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ pub fn cleanup_kinds(mir: &mir::Body<'_>) -> IndexVec<mir::BasicBlock, CleanupKi
284284
match data.terminator().kind {
285285
TerminatorKind::Goto { .. }
286286
| TerminatorKind::Resume
287-
| TerminatorKind::Abort
287+
| TerminatorKind::Terminate
288288
| TerminatorKind::Return
289289
| TerminatorKind::GeneratorDrop
290290
| TerminatorKind::Unreachable

compiler/rustc_codegen_ssa/src/mir/block.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -630,7 +630,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
630630
MergingSucc::False
631631
}
632632

633-
fn codegen_abort_terminator(
633+
fn codegen_terminate_terminator(
634634
&mut self,
635635
helper: TerminatorCodegenHelper<'tcx>,
636636
bx: &mut Bx,
@@ -1263,8 +1263,8 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
12631263
MergingSucc::False
12641264
}
12651265

1266-
mir::TerminatorKind::Abort => {
1267-
self.codegen_abort_terminator(helper, bx, terminator);
1266+
mir::TerminatorKind::Terminate => {
1267+
self.codegen_terminate_terminator(helper, bx, terminator);
12681268
MergingSucc::False
12691269
}
12701270

compiler/rustc_codegen_ssa/src/mir/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ pub struct FunctionCx<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> {
7373
/// Cached unreachable block
7474
unreachable_block: Option<Bx::BasicBlock>,
7575

76-
/// Cached double unwind guarding block
76+
/// Cached terminate upon unwinding block
7777
terminate_block: Option<Bx::BasicBlock>,
7878

7979
/// The location where each MIR arg/var/tmp/ret is stored. This is

compiler/rustc_const_eval/src/interpret/machine.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ pub trait Machine<'mir, 'tcx>: Sized {
218218
unwind: mir::UnwindAction,
219219
) -> InterpResult<'tcx>;
220220

221-
/// Called to evaluate `Abort` MIR terminator.
221+
/// Called to abort evaluation.
222222
fn abort(_ecx: &mut InterpCx<'mir, 'tcx, Self>, _msg: String) -> InterpResult<'tcx, !> {
223223
throw_unsup_format!("aborting execution is not supported")
224224
}

compiler/rustc_const_eval/src/interpret/terminator.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
144144
}
145145
}
146146

147-
Abort => {
147+
Terminate => {
148148
M::abort(self, "the program aborted execution".to_owned())?;
149149
}
150150

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -1031,9 +1031,9 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> {
10311031
self.check_op(ops::Generator(hir::GeneratorKind::Gen))
10321032
}
10331033

1034-
TerminatorKind::Abort => {
1034+
TerminatorKind::Terminate => {
10351035
// Cleanup blocks are skipped for const checking (see `visit_basic_block_data`).
1036-
span_bug!(self.span, "`Abort` terminator outside of cleanup block")
1036+
span_bug!(self.span, "`Terminate` terminator outside of cleanup block")
10371037
}
10381038

10391039
TerminatorKind::Assert { .. }

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ impl<'tcx> Visitor<'tcx> for CheckLiveDrops<'_, 'tcx> {
104104
}
105105
}
106106

107-
mir::TerminatorKind::Abort
107+
mir::TerminatorKind::Terminate
108108
| mir::TerminatorKind::Call { .. }
109109
| mir::TerminatorKind::Assert { .. }
110110
| mir::TerminatorKind::FalseEdge { .. }

compiler/rustc_const_eval/src/transform/validate.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -1015,10 +1015,13 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
10151015
);
10161016
}
10171017
}
1018-
TerminatorKind::Resume | TerminatorKind::Abort => {
1018+
TerminatorKind::Resume | TerminatorKind::Terminate => {
10191019
let bb = location.block;
10201020
if !self.body.basic_blocks[bb].is_cleanup {
1021-
self.fail(location, "Cannot `Resume` or `Abort` from non-cleanup basic block")
1021+
self.fail(
1022+
location,
1023+
"Cannot `Resume` or `Terminate` from non-cleanup basic block",
1024+
)
10221025
}
10231026
}
10241027
TerminatorKind::Return => {

compiler/rustc_middle/src/mir/patch.rs

+47-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,19 @@ impl<'tcx> MirPatch<'tcx> {
3737
// Check if we already have a resume block
3838
if let TerminatorKind::Resume = block.terminator().kind && block.statements.is_empty() {
3939
result.resume_block = Some(bb);
40-
break;
40+
continue;
41+
}
42+
43+
// Check if we already have an unreachable block
44+
if let TerminatorKind::Unreachable = block.terminator().kind && block.statements.is_empty() {
45+
result.unreachable_block = Some(bb);
46+
continue;
47+
}
48+
49+
// Check if we already have a terminate block
50+
if let TerminatorKind::Terminate = block.terminator().kind && block.statements.is_empty() {
51+
result.terminate_block = Some(bb);
52+
continue;
4153
}
4254
}
4355

@@ -61,6 +73,40 @@ impl<'tcx> MirPatch<'tcx> {
6173
bb
6274
}
6375

76+
pub fn unreachable_block(&mut self) -> BasicBlock {
77+
if let Some(bb) = self.unreachable_block {
78+
return bb;
79+
}
80+
81+
let bb = self.new_block(BasicBlockData {
82+
statements: vec![],
83+
terminator: Some(Terminator {
84+
source_info: SourceInfo::outermost(self.body_span),
85+
kind: TerminatorKind::Unreachable,
86+
}),
87+
is_cleanup: true,
88+
});
89+
self.unreachable_block = Some(bb);
90+
bb
91+
}
92+
93+
pub fn terminate_block(&mut self) -> BasicBlock {
94+
if let Some(bb) = self.terminate_block {
95+
return bb;
96+
}
97+
98+
let bb = self.new_block(BasicBlockData {
99+
statements: vec![],
100+
terminator: Some(Terminator {
101+
source_info: SourceInfo::outermost(self.body_span),
102+
kind: TerminatorKind::Terminate,
103+
}),
104+
is_cleanup: true,
105+
});
106+
self.terminate_block = Some(bb);
107+
bb
108+
}
109+
64110
pub fn is_patched(&self, bb: BasicBlock) -> bool {
65111
self.patch_map[bb].is_some()
66112
}

compiler/rustc_middle/src/mir/spanview.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ pub fn terminator_kind_name(term: &Terminator<'_>) -> &'static str {
262262
Goto { .. } => "Goto",
263263
SwitchInt { .. } => "SwitchInt",
264264
Resume => "Resume",
265-
Abort => "Abort",
265+
Terminate => "Terminate",
266266
Return => "Return",
267267
Unreachable => "Unreachable",
268268
Drop { .. } => "Drop",

compiler/rustc_middle/src/mir/syntax.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -522,8 +522,8 @@ pub struct CopyNonOverlapping<'tcx> {
522522
///
523523
/// The basic block pointed to by a `Cleanup` unwind action must have its `cleanup` flag set.
524524
/// `cleanup` basic blocks have a couple restrictions:
525-
/// 1. All `unwind` fields in them must be `UnwindAction::Continue`.
526-
/// 2. `Return` terminators are not allowed in them. `Abort` and `Unwind` terminators are.
525+
/// 1. All `unwind` fields in them must be `UnwindAction::Terminate` or `UnwindAction::Unreachable`.
526+
/// 2. `Return` terminators are not allowed in them. `Terminate` and `Unwind` terminators are.
527527
/// 3. All other basic blocks (in the current body) that are reachable from `cleanup` basic blocks
528528
/// must also be `cleanup`. This is a part of the type system and checked statically, so it is
529529
/// still an error to have such an edge in the CFG even if it's known that it won't be taken at
@@ -565,11 +565,11 @@ pub enum TerminatorKind<'tcx> {
565565
/// deaggregation runs.
566566
Resume,
567567

568-
/// Indicates that the landing pad is finished and that the process should abort.
568+
/// Indicates that the landing pad is finished and that the process should terminate.
569569
///
570570
/// Used to prevent unwinding for foreign items or with `-C unwind=abort`. Only permitted in
571571
/// cleanup blocks.
572-
Abort,
572+
Terminate,
573573

574574
/// Returns from the function.
575575
///

compiler/rustc_middle/src/mir/terminator.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ impl<'tcx> TerminatorKind<'tcx> {
155155
Some(t).into_iter().chain((&[]).into_iter().copied())
156156
}
157157
Resume
158-
| Abort
158+
| Terminate
159159
| GeneratorDrop
160160
| Return
161161
| Unreachable
@@ -197,7 +197,7 @@ impl<'tcx> TerminatorKind<'tcx> {
197197
Some(t).into_iter().chain(&mut [])
198198
}
199199
Resume
200-
| Abort
200+
| Terminate
201201
| GeneratorDrop
202202
| Return
203203
| Unreachable
@@ -214,7 +214,7 @@ impl<'tcx> TerminatorKind<'tcx> {
214214
match *self {
215215
TerminatorKind::Goto { .. }
216216
| TerminatorKind::Resume
217-
| TerminatorKind::Abort
217+
| TerminatorKind::Terminate
218218
| TerminatorKind::Return
219219
| TerminatorKind::Unreachable
220220
| TerminatorKind::GeneratorDrop
@@ -233,7 +233,7 @@ impl<'tcx> TerminatorKind<'tcx> {
233233
match *self {
234234
TerminatorKind::Goto { .. }
235235
| TerminatorKind::Resume
236-
| TerminatorKind::Abort
236+
| TerminatorKind::Terminate
237237
| TerminatorKind::Return
238238
| TerminatorKind::Unreachable
239239
| TerminatorKind::GeneratorDrop
@@ -310,7 +310,7 @@ impl<'tcx> TerminatorKind<'tcx> {
310310
Return => write!(fmt, "return"),
311311
GeneratorDrop => write!(fmt, "generator_drop"),
312312
Resume => write!(fmt, "resume"),
313-
Abort => write!(fmt, "abort"),
313+
Terminate => write!(fmt, "abort"),
314314
Yield { value, resume_arg, .. } => write!(fmt, "{:?} = yield({:?})", resume_arg, value),
315315
Unreachable => write!(fmt, "unreachable"),
316316
Drop { place, .. } => write!(fmt, "drop({:?})", place),
@@ -389,7 +389,7 @@ impl<'tcx> TerminatorKind<'tcx> {
389389
pub fn fmt_successor_labels(&self) -> Vec<Cow<'static, str>> {
390390
use self::TerminatorKind::*;
391391
match *self {
392-
Return | Resume | Abort | Unreachable | GeneratorDrop => vec![],
392+
Return | Resume | Terminate | Unreachable | GeneratorDrop => vec![],
393393
Goto { .. } => vec!["".into()],
394394
SwitchInt { ref targets, .. } => targets
395395
.values

compiler/rustc_middle/src/mir/visit.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,7 @@ macro_rules! make_mir_visitor {
462462
match kind {
463463
TerminatorKind::Goto { .. } |
464464
TerminatorKind::Resume |
465-
TerminatorKind::Abort |
465+
TerminatorKind::Terminate |
466466
TerminatorKind::GeneratorDrop |
467467
TerminatorKind::Unreachable |
468468
TerminatorKind::FalseEdge { .. } |

compiler/rustc_mir_build/src/build/scope.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1454,7 +1454,7 @@ impl<'tcx> DropTreeBuilder<'tcx> for Unwind {
14541454
TerminatorKind::Goto { .. }
14551455
| TerminatorKind::SwitchInt { .. }
14561456
| TerminatorKind::Resume
1457-
| TerminatorKind::Abort
1457+
| TerminatorKind::Terminate
14581458
| TerminatorKind::Return
14591459
| TerminatorKind::Unreachable
14601460
| TerminatorKind::Yield { .. }

compiler/rustc_mir_build/src/lints.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ impl<'mir, 'tcx> TriColorVisitor<BasicBlocks<'tcx>> for Search<'mir, 'tcx> {
108108

109109
match self.body[bb].terminator().kind {
110110
// These terminators return control flow to the caller.
111-
TerminatorKind::Abort
111+
TerminatorKind::Terminate
112112
| TerminatorKind::GeneratorDrop
113113
| TerminatorKind::Resume
114114
| TerminatorKind::Return

compiler/rustc_mir_dataflow/src/framework/direction.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,7 @@ impl Direction for Forward {
474474
{
475475
use mir::TerminatorKind::*;
476476
match bb_data.terminator().kind {
477-
Return | Resume | Abort | GeneratorDrop | Unreachable => {}
477+
Return | Resume | Terminate | GeneratorDrop | Unreachable => {}
478478

479479
Goto { target } => propagate(target, exit_state),
480480

compiler/rustc_mir_dataflow/src/impls/borrowed_locals.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ where
125125
}
126126
}
127127

128-
TerminatorKind::Abort
128+
TerminatorKind::Terminate
129129
| TerminatorKind::Assert { .. }
130130
| TerminatorKind::Call { .. }
131131
| TerminatorKind::FalseEdge { .. }

compiler/rustc_mir_dataflow/src/impls/storage_liveness.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ impl<'mir, 'tcx> crate::GenKillAnalysis<'tcx> for MaybeRequiresStorage<'mir, 'tc
200200

201201
// Nothing to do for these. Match exhaustively so this fails to compile when new
202202
// variants are added.
203-
TerminatorKind::Abort
203+
TerminatorKind::Terminate
204204
| TerminatorKind::Assert { .. }
205205
| TerminatorKind::Drop { .. }
206206
| TerminatorKind::FalseEdge { .. }
@@ -237,7 +237,7 @@ impl<'mir, 'tcx> crate::GenKillAnalysis<'tcx> for MaybeRequiresStorage<'mir, 'tc
237237
// Nothing to do for these. Match exhaustively so this fails to compile when new
238238
// variants are added.
239239
TerminatorKind::Yield { .. }
240-
| TerminatorKind::Abort
240+
| TerminatorKind::Terminate
241241
| TerminatorKind::Assert { .. }
242242
| TerminatorKind::Drop { .. }
243243
| TerminatorKind::FalseEdge { .. }

compiler/rustc_mir_dataflow/src/move_paths/builder.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ impl<'b, 'a, 'tcx> Gatherer<'b, 'a, 'tcx> {
375375
// need recording.
376376
| TerminatorKind::Return
377377
| TerminatorKind::Resume
378-
| TerminatorKind::Abort
378+
| TerminatorKind::Terminate
379379
| TerminatorKind::GeneratorDrop
380380
| TerminatorKind::Unreachable
381381
| TerminatorKind::Drop { .. } => {}

compiler/rustc_mir_transform/src/check_unsafety.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ impl<'tcx> Visitor<'tcx> for UnsafetyChecker<'_, 'tcx> {
5757
| TerminatorKind::Assert { .. }
5858
| TerminatorKind::GeneratorDrop
5959
| TerminatorKind::Resume
60-
| TerminatorKind::Abort
60+
| TerminatorKind::Terminate
6161
| TerminatorKind::Return
6262
| TerminatorKind::Unreachable
6363
| TerminatorKind::FalseEdge { .. }

compiler/rustc_mir_transform/src/const_prop.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -959,7 +959,7 @@ impl<'tcx> MutVisitor<'tcx> for ConstPropagator<'_, 'tcx> {
959959
// None of these have Operands to const-propagate.
960960
TerminatorKind::Goto { .. }
961961
| TerminatorKind::Resume
962-
| TerminatorKind::Abort
962+
| TerminatorKind::Terminate
963963
| TerminatorKind::Return
964964
| TerminatorKind::Unreachable
965965
| TerminatorKind::Drop { .. }

0 commit comments

Comments
 (0)