Skip to content

Commit ed2f22c

Browse files
committed
rename PanicInfo -> AssertKind
1 parent 7e7d1c3 commit ed2f22c

File tree

12 files changed

+41
-41
lines changed

12 files changed

+41
-41
lines changed

src/librustc/mir/mod.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -1155,7 +1155,7 @@ pub enum TerminatorKind<'tcx> {
11551155

11561156
/// Information about an assertion failure.
11571157
#[derive(Clone, RustcEncodable, RustcDecodable, HashStable, PartialEq)]
1158-
pub enum PanicInfo<O> {
1158+
pub enum AssertKind<O> {
11591159
BoundsCheck { len: O, index: O },
11601160
Overflow(BinOp),
11611161
OverflowNeg,
@@ -1166,7 +1166,7 @@ pub enum PanicInfo<O> {
11661166
}
11671167

11681168
/// Type for MIR `Assert` terminator error messages.
1169-
pub type AssertMessage<'tcx> = PanicInfo<Operand<'tcx>>;
1169+
pub type AssertMessage<'tcx> = AssertKind<Operand<'tcx>>;
11701170

11711171
pub type Successors<'a> =
11721172
iter::Chain<option::IntoIter<&'a BasicBlock>, slice::Iter<'a, BasicBlock>>;
@@ -1397,12 +1397,12 @@ impl<'tcx> BasicBlockData<'tcx> {
13971397
}
13981398
}
13991399

1400-
impl<O> PanicInfo<O> {
1400+
impl<O> AssertKind<O> {
14011401
/// Getting a description does not require `O` to be printable, and does not
14021402
/// require allocation.
14031403
/// The caller is expected to handle `BoundsCheck` separately.
14041404
pub fn description(&self) -> &'static str {
1405-
use PanicInfo::*;
1405+
use AssertKind::*;
14061406
match self {
14071407
Overflow(BinOp::Add) => "attempt to add with overflow",
14081408
Overflow(BinOp::Sub) => "attempt to subtract with overflow",
@@ -1419,14 +1419,14 @@ impl<O> PanicInfo<O> {
14191419
ResumedAfterReturn(GeneratorKind::Async(_)) => "`async fn` resumed after completion",
14201420
ResumedAfterPanic(GeneratorKind::Gen) => "generator resumed after panicking",
14211421
ResumedAfterPanic(GeneratorKind::Async(_)) => "`async fn` resumed after panicking",
1422-
BoundsCheck { .. } => bug!("Unexpected PanicInfo"),
1422+
BoundsCheck { .. } => bug!("Unexpected AssertKind"),
14231423
}
14241424
}
14251425
}
14261426

1427-
impl<O: fmt::Debug> fmt::Debug for PanicInfo<O> {
1427+
impl<O: fmt::Debug> fmt::Debug for AssertKind<O> {
14281428
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1429-
use PanicInfo::*;
1429+
use AssertKind::*;
14301430
match self {
14311431
BoundsCheck { ref len, ref index } => {
14321432
write!(f, "index out of bounds: the len is {:?} but the index is {:?}", len, index)
@@ -2719,7 +2719,7 @@ impl<'tcx> TypeFoldable<'tcx> for Terminator<'tcx> {
27192719
}
27202720
}
27212721
Assert { ref cond, expected, ref msg, target, cleanup } => {
2722-
use PanicInfo::*;
2722+
use AssertKind::*;
27232723
let msg = match msg {
27242724
BoundsCheck { ref len, ref index } => {
27252725
BoundsCheck { len: len.fold_with(folder), index: index.fold_with(folder) }
@@ -2768,7 +2768,7 @@ impl<'tcx> TypeFoldable<'tcx> for Terminator<'tcx> {
27682768
}
27692769
Assert { ref cond, ref msg, .. } => {
27702770
if cond.visit_with(visitor) {
2771-
use PanicInfo::*;
2771+
use AssertKind::*;
27722772
match msg {
27732773
BoundsCheck { ref len, ref index } => {
27742774
len.visit_with(visitor) || index.visit_with(visitor)

src/librustc/mir/visit.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,7 @@ macro_rules! make_mir_visitor {
533533
fn super_assert_message(&mut self,
534534
msg: & $($mutability)? AssertMessage<'tcx>,
535535
location: Location) {
536-
use crate::mir::PanicInfo::*;
536+
use crate::mir::AssertKind::*;
537537
match msg {
538538
BoundsCheck { len, index } => {
539539
self.visit_operand(len, location);

src/librustc_codegen_ssa/mir/block.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use crate::MemFlags;
1111

1212
use rustc::middle::lang_items;
1313
use rustc::mir;
14-
use rustc::mir::PanicInfo;
14+
use rustc::mir::AssertKind;
1515
use rustc::ty::layout::{self, FnAbiExt, HasTyCtxt, LayoutOf};
1616
use rustc::ty::{self, Instance, Ty, TypeFoldable};
1717
use rustc_index::vec::Idx;
@@ -378,7 +378,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
378378
// checked operation, just a comparison with the minimum
379379
// value, so we have to check for the assert message.
380380
if !bx.check_overflow() {
381-
if let PanicInfo::OverflowNeg = *msg {
381+
if let AssertKind::OverflowNeg = *msg {
382382
const_cond = Some(expected);
383383
}
384384
}
@@ -412,7 +412,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
412412

413413
// Put together the arguments to the panic entry point.
414414
let (lang_item, args) = match msg {
415-
PanicInfo::BoundsCheck { ref len, ref index } => {
415+
AssertKind::BoundsCheck { ref len, ref index } => {
416416
let len = self.codegen_operand(&mut bx, len).immediate();
417417
let index = self.codegen_operand(&mut bx, index).immediate();
418418
(lang_items::PanicBoundsCheckFnLangItem, vec![location, index, len])

src/librustc_mir/borrow_check/invalidation.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,8 @@ impl<'cx, 'tcx> Visitor<'tcx> for InvalidationGenerator<'cx, 'tcx> {
153153
}
154154
TerminatorKind::Assert { ref cond, expected: _, ref msg, target: _, cleanup: _ } => {
155155
self.consume_operand(location, cond);
156-
use rustc::mir::PanicInfo;
157-
if let PanicInfo::BoundsCheck { ref len, ref index } = *msg {
156+
use rustc::mir::AssertKind;
157+
if let AssertKind::BoundsCheck { ref len, ref index } = *msg {
158158
self.consume_operand(location, len);
159159
self.consume_operand(location, index);
160160
}

src/librustc_mir/borrow_check/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -654,8 +654,8 @@ impl<'cx, 'tcx> dataflow::generic::ResultsVisitor<'cx, 'tcx> for MirBorrowckCtxt
654654
}
655655
TerminatorKind::Assert { ref cond, expected: _, ref msg, target: _, cleanup: _ } => {
656656
self.consume_operand(loc, (cond, span), flow_state);
657-
use rustc::mir::PanicInfo;
658-
if let PanicInfo::BoundsCheck { ref len, ref index } = *msg {
657+
use rustc::mir::AssertKind;
658+
if let AssertKind::BoundsCheck { ref len, ref index } = *msg {
659659
self.consume_operand(loc, (len, span), flow_state);
660660
self.consume_operand(loc, (index, span), flow_state);
661661
}

src/librustc_mir/borrow_check/type_check/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use rustc::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
1111
use rustc::infer::{InferCtxt, InferOk, LateBoundRegionConversionTime, NLLRegionVariableOrigin};
1212
use rustc::mir::tcx::PlaceTy;
1313
use rustc::mir::visit::{NonMutatingUseContext, PlaceContext, Visitor};
14-
use rustc::mir::PanicInfo;
14+
use rustc::mir::AssertKind;
1515
use rustc::mir::*;
1616
use rustc::traits::query::type_op;
1717
use rustc::traits::query::type_op::custom::CustomTypeOp;
@@ -1563,7 +1563,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
15631563
span_mirbug!(self, term, "bad Assert ({:?}, not bool", cond_ty);
15641564
}
15651565

1566-
if let PanicInfo::BoundsCheck { ref len, ref index } = *msg {
1566+
if let AssertKind::BoundsCheck { ref len, ref index } = *msg {
15671567
if len.ty(body, tcx) != tcx.types.usize {
15681568
span_mirbug!(self, len, "bounds-check length non-usize {:?}", len)
15691569
}

src/librustc_mir/const_eval/error.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::error::Error;
22
use std::fmt;
33

4-
use rustc::mir::PanicInfo;
4+
use rustc::mir::AssertKind;
55
use rustc_span::Symbol;
66

77
use super::InterpCx;
@@ -12,7 +12,7 @@ use crate::interpret::{ConstEvalErr, InterpError, InterpErrorInfo, Machine};
1212
pub enum ConstEvalErrKind {
1313
NeedsRfc(String),
1414
ConstAccessesStatic,
15-
AssertFailure(PanicInfo<u64>),
15+
AssertFailure(AssertKind<u64>),
1616
Panic { msg: Symbol, line: u32, col: u32, file: Symbol },
1717
}
1818

src/librustc_mir/const_eval/machine.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -281,8 +281,8 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for CompileTimeInterpreter<'mir,
281281
msg: &AssertMessage<'tcx>,
282282
_unwind: Option<mir::BasicBlock>,
283283
) -> InterpResult<'tcx> {
284-
use rustc::mir::PanicInfo::*;
285-
// Convert `PanicInfo<Operand>` to `PanicInfo<u64>`.
284+
use rustc::mir::AssertKind::*;
285+
// Convert `AssertKind<Operand>` to `AssertKind<u64>`.
286286
let err = match msg {
287287
BoundsCheck { ref len, ref index } => {
288288
let len = ecx

src/librustc_mir/transform/const_prop.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ use rustc::mir::visit::{
99
MutVisitor, MutatingUseContext, NonMutatingUseContext, PlaceContext, Visitor,
1010
};
1111
use rustc::mir::{
12-
read_only, AggregateKind, BasicBlock, BinOp, Body, BodyAndCache, ClearCrossCrate, Constant,
13-
Local, LocalDecl, LocalKind, Location, Operand, PanicInfo, Place, ReadOnlyBodyAndCache, Rvalue,
12+
read_only, AggregateKind, AssertKind, BasicBlock, BinOp, Body, BodyAndCache, ClearCrossCrate,
13+
Constant, Local, LocalDecl, LocalKind, Location, Operand, Place, ReadOnlyBodyAndCache, Rvalue,
1414
SourceInfo, SourceScope, SourceScopeData, Statement, StatementKind, Terminator, TerminatorKind,
1515
UnOp, RETURN_PLACE,
1616
};
@@ -501,7 +501,7 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
501501
}
502502
}
503503

504-
fn report_panic_as_lint(&self, source_info: SourceInfo, panic: PanicInfo<u64>) -> Option<()> {
504+
fn report_panic_as_lint(&self, source_info: SourceInfo, panic: AssertKind<u64>) -> Option<()> {
505505
// Somewhat convoluted way to re-use the CTFE error reporting code.
506506
let lint_root = self.lint_root(source_info)?;
507507
let error = InterpError::MachineStop(Box::new(format!("{:?}", panic)));
@@ -530,7 +530,7 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
530530
// `AssertKind` only has an `OverflowNeg` variant, to make sure that is
531531
// appropriate to use.
532532
assert_eq!(op, UnOp::Neg, "Neg is the only UnOp that can overflow");
533-
self.report_panic_as_lint(source_info, PanicInfo::OverflowNeg)?;
533+
self.report_panic_as_lint(source_info, AssertKind::OverflowNeg)?;
534534
}
535535

536536
Some(())
@@ -572,7 +572,7 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
572572
let (_res, overflow, _ty) = this.ecx.overflowing_binary_op(op, l, r)?;
573573
Ok(overflow)
574574
})? {
575-
self.report_panic_as_lint(source_info, PanicInfo::Overflow(op))?;
575+
self.report_panic_as_lint(source_info, AssertKind::Overflow(op))?;
576576
}
577577

578578
Some(())
@@ -910,11 +910,11 @@ impl<'mir, 'tcx> MutVisitor<'tcx> for ConstPropagator<'mir, 'tcx> {
910910
span,
911911
|lint| {
912912
let msg = match msg {
913-
PanicInfo::Overflow(_)
914-
| PanicInfo::OverflowNeg
915-
| PanicInfo::DivisionByZero
916-
| PanicInfo::RemainderByZero => msg.description().to_owned(),
917-
PanicInfo::BoundsCheck { ref len, ref index } => {
913+
AssertKind::Overflow(_)
914+
| AssertKind::OverflowNeg
915+
| AssertKind::DivisionByZero
916+
| AssertKind::RemainderByZero => msg.description().to_owned(),
917+
AssertKind::BoundsCheck { ref len, ref index } => {
918918
let len = self
919919
.eval_operand(len, source_info)
920920
.expect("len must be const");

src/librustc_mir/transform/generator.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1022,7 +1022,7 @@ fn create_generator_resume_function<'tcx>(
10221022

10231023
let mut cases = create_cases(body, &transform, Operation::Resume);
10241024

1025-
use rustc::mir::PanicInfo::{ResumedAfterPanic, ResumedAfterReturn};
1025+
use rustc::mir::AssertKind::{ResumedAfterPanic, ResumedAfterReturn};
10261026

10271027
// Jump to the entry point on the unresumed
10281028
cases.insert(0, (UNRESUMED, BasicBlock::new(0)));

src/librustc_mir_build/build/expr/as_place.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use crate::build::ForGuard::{OutsideGuard, RefWithinGuard};
55
use crate::build::{BlockAnd, BlockAndExtension, Builder};
66
use crate::hair::*;
77
use rustc::middle::region;
8-
use rustc::mir::PanicInfo::BoundsCheck;
8+
use rustc::mir::AssertKind::BoundsCheck;
99
use rustc::mir::*;
1010
use rustc::ty::{self, CanonicalUserTypeAnnotation, Ty, TyCtxt, Variance};
1111
use rustc_span::Span;

src/librustc_mir_build/build/expr/as_rvalue.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use crate::build::expr::category::{Category, RvalueFunc};
66
use crate::build::{BlockAnd, BlockAndExtension, Builder};
77
use crate::hair::*;
88
use rustc::middle::region;
9-
use rustc::mir::PanicInfo;
9+
use rustc::mir::AssertKind;
1010
use rustc::mir::*;
1111
use rustc::ty::{self, Ty, UpvarSubsts};
1212
use rustc_span::Span;
@@ -86,7 +86,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
8686
block,
8787
Operand::Move(is_min),
8888
false,
89-
PanicInfo::OverflowNeg,
89+
AssertKind::OverflowNeg,
9090
expr_span,
9191
);
9292
}
@@ -294,7 +294,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
294294
let val = tcx.mk_place_field(result_value.clone(), val_fld, ty);
295295
let of = tcx.mk_place_field(result_value, of_fld, bool_ty);
296296

297-
let err = PanicInfo::Overflow(op);
297+
let err = AssertKind::Overflow(op);
298298

299299
block = self.assert(block, Operand::Move(of), false, err, span);
300300

@@ -305,11 +305,11 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
305305
// and 2. there are two possible failure cases, divide-by-zero and overflow.
306306

307307
let zero_err = if op == BinOp::Div {
308-
PanicInfo::DivisionByZero
308+
AssertKind::DivisionByZero
309309
} else {
310-
PanicInfo::RemainderByZero
310+
AssertKind::RemainderByZero
311311
};
312-
let overflow_err = PanicInfo::Overflow(op);
312+
let overflow_err = AssertKind::Overflow(op);
313313

314314
// Check for / 0
315315
let is_zero = self.temp(bool_ty, span);

0 commit comments

Comments
 (0)