Skip to content

Commit 3730ed9

Browse files
committed
renames EvalErrorPanic to PanicMessage
1 parent 90426ed commit 3730ed9

File tree

16 files changed

+70
-75
lines changed

16 files changed

+70
-75
lines changed

src/librustc/mir/interpret/error.rs

+17-17
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ impl<'tcx> From<InterpError<'tcx, u64>> for InterpErrorInfo<'tcx> {
229229
pub type AssertMessage<'tcx> = InterpError<'tcx, mir::Operand<'tcx>>;
230230

231231
#[derive(Clone, RustcEncodable, RustcDecodable, HashStable)]
232-
pub enum EvalErrorPanic<O> {
232+
pub enum PanicMessage<O> {
233233
Panic {
234234
msg: Symbol,
235235
line: u32,
@@ -311,7 +311,7 @@ pub enum InterpError<'tcx, O> {
311311
HeapAllocZeroBytes,
312312
HeapAllocNonPowerOfTwoAlignment(u64),
313313
Unreachable,
314-
Panic(EvalErrorPanic<O>),
314+
Panic(PanicMessage<O>),
315315
ReadFromReturnPointer,
316316
PathNotFound(Vec<String>),
317317
UnimplementedTraitSelection,
@@ -428,31 +428,31 @@ impl<'tcx, O> InterpError<'tcx, O> {
428428
two",
429429
Unreachable =>
430430
"entered unreachable code",
431-
Panic(EvalErrorPanic::Panic{..}) =>
431+
Panic(PanicMessage::Panic{..}) =>
432432
"the evaluated program panicked",
433-
Panic(EvalErrorPanic::BoundsCheck{..}) =>
433+
Panic(PanicMessage::BoundsCheck{..}) =>
434434
"array index out of bounds",
435-
Panic(EvalErrorPanic::Overflow(mir::BinOp::Add)) =>
435+
Panic(PanicMessage::Overflow(mir::BinOp::Add)) =>
436436
"attempt to add with overflow",
437-
Panic(EvalErrorPanic::Overflow(mir::BinOp::Sub)) =>
437+
Panic(PanicMessage::Overflow(mir::BinOp::Sub)) =>
438438
"attempt to subtract with overflow",
439-
Panic(EvalErrorPanic::Overflow(mir::BinOp::Mul)) =>
439+
Panic(PanicMessage::Overflow(mir::BinOp::Mul)) =>
440440
"attempt to multiply with overflow",
441-
Panic(EvalErrorPanic::Overflow(mir::BinOp::Div)) =>
441+
Panic(PanicMessage::Overflow(mir::BinOp::Div)) =>
442442
"attempt to divide with overflow",
443-
Panic(EvalErrorPanic::Overflow(mir::BinOp::Rem)) =>
443+
Panic(PanicMessage::Overflow(mir::BinOp::Rem)) =>
444444
"attempt to calculate the remainder with overflow",
445-
Panic(EvalErrorPanic::OverflowNeg) =>
445+
Panic(PanicMessage::OverflowNeg) =>
446446
"attempt to negate with overflow",
447-
Panic(EvalErrorPanic::Overflow(mir::BinOp::Shr)) =>
447+
Panic(PanicMessage::Overflow(mir::BinOp::Shr)) =>
448448
"attempt to shift right with overflow",
449-
Panic(EvalErrorPanic::Overflow(mir::BinOp::Shl)) =>
449+
Panic(PanicMessage::Overflow(mir::BinOp::Shl)) =>
450450
"attempt to shift left with overflow",
451-
Panic(EvalErrorPanic::Overflow(op)) =>
451+
Panic(PanicMessage::Overflow(op)) =>
452452
bug!("{:?} cannot overflow", op),
453-
Panic(EvalErrorPanic::DivisionByZero) =>
453+
Panic(PanicMessage::DivisionByZero) =>
454454
"attempt to divide by zero",
455-
Panic(EvalErrorPanic::RemainderByZero) =>
455+
Panic(PanicMessage::RemainderByZero) =>
456456
"attempt to calculate the remainder with a divisor of zero",
457457
ReadFromReturnPointer =>
458458
"tried to read from the return pointer",
@@ -535,9 +535,9 @@ impl<'tcx, O: fmt::Debug> fmt::Debug for InterpError<'tcx, O> {
535535
write!(f, "incorrect alloc info: expected size {} and align {}, \
536536
got size {} and align {}",
537537
size.bytes(), align.bytes(), size2.bytes(), align2.bytes()),
538-
Panic(EvalErrorPanic::Panic { ref msg, line, col, ref file }) =>
538+
Panic(PanicMessage::Panic { ref msg, line, col, ref file }) =>
539539
write!(f, "the evaluated program panicked at '{}', {}:{}:{}", msg, file, line, col),
540-
Panic(EvalErrorPanic::BoundsCheck { ref len, ref index }) =>
540+
Panic(PanicMessage::BoundsCheck { ref len, ref index }) =>
541541
write!(f, "index out of bounds: the len is {:?} but the index is {:?}", len, index),
542542
InvalidDiscriminant(val) =>
543543
write!(f, "encountered invalid enum discriminant {}", val),

src/librustc/mir/interpret/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ mod pointer;
1212

1313
pub use self::error::{
1414
InterpErrorInfo, InterpResult, InterpError, AssertMessage, ConstEvalErr, struct_error,
15-
FrameInfo, ConstEvalRawResult, ConstEvalResult, ErrorHandled, EvalErrorPanic
15+
FrameInfo, ConstEvalRawResult, ConstEvalResult, ErrorHandled, PanicMessage
1616
};
1717

1818
pub use self::value::{Scalar, ScalarMaybeUndef, RawConst, ConstValue};

src/librustc/mir/interpret/pointer.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use crate::ty::layout::{self, HasDataLayout, Size};
55
use rustc_macros::HashStable;
66

77
use super::{
8-
AllocId, InterpResult, EvalErrorPanic
8+
AllocId, InterpResult, PanicMessage
99
};
1010

1111
/// Used by `check_in_alloc` to indicate context of check
@@ -76,13 +76,13 @@ pub trait PointerArithmetic: layout::HasDataLayout {
7676
#[inline]
7777
fn offset<'tcx>(&self, val: u64, i: u64) -> InterpResult<'tcx, u64> {
7878
let (res, over) = self.overflowing_offset(val, i);
79-
if over { err!(Panic(EvalErrorPanic::Overflow(mir::BinOp::Add))) } else { Ok(res) }
79+
if over { err!(Panic(PanicMessage::Overflow(mir::BinOp::Add))) } else { Ok(res) }
8080
}
8181

8282
#[inline]
8383
fn signed_offset<'tcx>(&self, val: u64, i: i64) -> InterpResult<'tcx, u64> {
8484
let (res, over) = self.overflowing_signed_offset(val, i128::from(i));
85-
if over { err!(Panic(EvalErrorPanic::Overflow(mir::BinOp::Add))) } else { Ok(res) }
85+
if over { err!(Panic(PanicMessage::Overflow(mir::BinOp::Add))) } else { Ok(res) }
8686
}
8787
}
8888

src/librustc/mir/mod.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
use crate::hir::def::{CtorKind, Namespace};
88
use crate::hir::def_id::DefId;
99
use crate::hir::{self, InlineAsm as HirInlineAsm};
10-
use crate::mir::interpret::{ConstValue, EvalErrorPanic, InterpError::Panic, Scalar};
10+
use crate::mir::interpret::{ConstValue, PanicMessage, InterpError::Panic, Scalar};
1111
use crate::mir::visit::MirVisitable;
1212
use crate::rustc_serialize as serialize;
1313
use crate::ty::adjustment::PointerCast;
@@ -3087,8 +3087,8 @@ impl<'tcx> TypeFoldable<'tcx> for Terminator<'tcx> {
30873087
}
30883088
}
30893089
Assert { ref cond, expected, ref msg, target, cleanup } => {
3090-
let msg = if let Panic(EvalErrorPanic::BoundsCheck { ref len, ref index }) = *msg {
3091-
Panic(EvalErrorPanic::BoundsCheck {
3090+
let msg = if let Panic(PanicMessage::BoundsCheck { ref len, ref index }) = *msg {
3091+
Panic(PanicMessage::BoundsCheck {
30923092
len: len.fold_with(folder),
30933093
index: index.fold_with(folder),
30943094
})
@@ -3132,7 +3132,7 @@ impl<'tcx> TypeFoldable<'tcx> for Terminator<'tcx> {
31323132
}
31333133
Assert { ref cond, ref msg, .. } => {
31343134
if cond.visit_with(visitor) {
3135-
if let Panic(EvalErrorPanic::BoundsCheck { ref len, ref index }) = *msg {
3135+
if let Panic(PanicMessage::BoundsCheck { ref len, ref index }) = *msg {
31363136
len.visit_with(visitor) || index.visit_with(visitor)
31373137
} else {
31383138
false

src/librustc/mir/visit.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,7 @@ macro_rules! make_mir_visitor {
514514
msg: & $($mutability)? AssertMessage<'tcx>,
515515
location: Location) {
516516
use crate::mir::interpret::InterpError::*;
517-
use crate::mir::interpret::EvalErrorPanic::BoundsCheck;
517+
use crate::mir::interpret::PanicMessage::BoundsCheck;
518518
if let Panic(BoundsCheck { len, index }) = msg {
519519
self.visit_operand(len, location);
520520
self.visit_operand(index, location);

src/librustc_codegen_ssa/mir/block.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use rustc::middle::lang_items;
22
use rustc::ty::{self, Ty, TypeFoldable, Instance};
33
use rustc::ty::layout::{self, LayoutOf, HasTyCtxt, FnTypeExt};
44
use rustc::mir::{self, Place, PlaceBase, Static, StaticKind};
5-
use rustc::mir::interpret::{InterpError, EvalErrorPanic};
5+
use rustc::mir::interpret::{InterpError, PanicMessage};
66
use rustc_target::abi::call::{ArgType, FnType, PassMode, IgnoreMode};
77
use rustc_target::spec::abi::Abi;
88
use crate::base;
@@ -368,7 +368,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
368368
// checked operation, just a comparison with the minimum
369369
// value, so we have to check for the assert message.
370370
if !bx.check_overflow() {
371-
if let InterpError::Panic(EvalErrorPanic::OverflowNeg) = *msg {
371+
if let InterpError::Panic(PanicMessage::OverflowNeg) = *msg {
372372
const_cond = Some(expected);
373373
}
374374
}
@@ -403,7 +403,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
403403

404404
// Put together the arguments to the panic entry point.
405405
let (lang_item, args) = match *msg {
406-
InterpError::Panic(EvalErrorPanic::BoundsCheck { ref len, ref index }) => {
406+
InterpError::Panic(PanicMessage::BoundsCheck { ref len, ref index }) => {
407407
let len = self.codegen_operand(&mut bx, len).immediate();
408408
let index = self.codegen_operand(&mut bx, index).immediate();
409409

src/librustc_mir/borrow_check/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -734,8 +734,8 @@ impl<'cx, 'tcx> DataflowResultsConsumer<'cx, 'tcx> for MirBorrowckCtxt<'cx, 'tcx
734734
cleanup: _,
735735
} => {
736736
self.consume_operand(loc, (cond, span), flow_state);
737-
use rustc::mir::interpret::{InterpError::Panic, EvalErrorPanic};
738-
if let Panic(EvalErrorPanic::BoundsCheck { ref len, ref index }) = *msg {
737+
use rustc::mir::interpret::{InterpError::Panic, PanicMessage};
738+
if let Panic(PanicMessage::BoundsCheck { ref len, ref index }) = *msg {
739739
self.consume_operand(loc, (len, span), flow_state);
740740
self.consume_operand(loc, (index, span), flow_state);
741741
}

src/librustc_mir/borrow_check/nll/invalidation.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ impl<'cx, 'tcx> Visitor<'tcx> for InvalidationGenerator<'cx, 'tcx> {
207207
cleanup: _,
208208
} => {
209209
self.consume_operand(location, cond);
210-
use rustc::mir::interpret::{InterpError::Panic, EvalErrorPanic::BoundsCheck};
210+
use rustc::mir::interpret::{InterpError::Panic, PanicMessage::BoundsCheck};
211211
if let Panic(BoundsCheck { ref len, ref index }) = *msg {
212212
self.consume_operand(location, len);
213213
self.consume_operand(location, index);

src/librustc_mir/borrow_check/nll/type_check/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ use rustc::infer::canonical::QueryRegionConstraints;
2828
use rustc::infer::outlives::env::RegionBoundPairs;
2929
use rustc::infer::{InferCtxt, InferOk, LateBoundRegionConversionTime, NLLRegionVariableOrigin};
3030
use rustc::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
31-
use rustc::mir::interpret::{InterpError::Panic, ConstValue, EvalErrorPanic};
31+
use rustc::mir::interpret::{InterpError::Panic, ConstValue, PanicMessage};
3232
use rustc::mir::tcx::PlaceTy;
3333
use rustc::mir::visit::{PlaceContext, Visitor, NonMutatingUseContext};
3434
use rustc::mir::*;
@@ -1589,7 +1589,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
15891589
span_mirbug!(self, term, "bad Assert ({:?}, not bool", cond_ty);
15901590
}
15911591

1592-
if let Panic(EvalErrorPanic::BoundsCheck { ref len, ref index }) = *msg {
1592+
if let Panic(PanicMessage::BoundsCheck { ref len, ref index }) = *msg {
15931593
if len.ty(body, tcx) != tcx.types.usize {
15941594
span_mirbug!(self, len, "bounds-check length non-usize {:?}", len)
15951595
}

src/librustc_mir/build/expr/as_place.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use crate::build::expr::category::Category;
44
use crate::build::ForGuard::{OutsideGuard, RefWithinGuard};
55
use crate::build::{BlockAnd, BlockAndExtension, Builder};
66
use crate::hair::*;
7-
use rustc::mir::interpret::{InterpError::Panic, EvalErrorPanic::BoundsCheck};
7+
use rustc::mir::interpret::{InterpError::Panic, PanicMessage::BoundsCheck};
88
use rustc::mir::*;
99
use rustc::ty::{CanonicalUserTypeAnnotation, Variance};
1010

src/librustc_mir/build/expr/as_rvalue.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use crate::build::expr::category::{Category, RvalueFunc};
77
use crate::build::{BlockAnd, BlockAndExtension, Builder};
88
use crate::hair::*;
99
use rustc::middle::region;
10-
use rustc::mir::interpret::{InterpError::Panic, EvalErrorPanic};
10+
use rustc::mir::interpret::{InterpError::Panic, PanicMessage};
1111
use rustc::mir::*;
1212
use rustc::ty::{self, CanonicalUserTypeAnnotation, Ty, UpvarSubsts};
1313
use syntax_pos::Span;
@@ -101,7 +101,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
101101
block,
102102
Operand::Move(is_min),
103103
false,
104-
Panic(EvalErrorPanic::OverflowNeg),
104+
Panic(PanicMessage::OverflowNeg),
105105
expr_span,
106106
);
107107
}
@@ -401,7 +401,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
401401
let val = result_value.clone().field(val_fld, ty);
402402
let of = result_value.field(of_fld, bool_ty);
403403

404-
let err = Panic(EvalErrorPanic::Overflow(op));
404+
let err = Panic(PanicMessage::Overflow(op));
405405

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

@@ -412,9 +412,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
412412
// and 2. there are two possible failure cases, divide-by-zero and overflow.
413413

414414
let (zero_err, overflow_err) = if op == BinOp::Div {
415-
(Panic(EvalErrorPanic::DivisionByZero), Panic(EvalErrorPanic::Overflow(op)))
415+
(Panic(PanicMessage::DivisionByZero), Panic(PanicMessage::Overflow(op)))
416416
} else {
417-
(Panic(EvalErrorPanic::RemainderByZero), Panic(EvalErrorPanic::Overflow(op)))
417+
(Panic(PanicMessage::RemainderByZero), Panic(PanicMessage::Overflow(op)))
418418
};
419419

420420
// Check for / 0

src/librustc_mir/interpret/intrinsics.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use rustc::ty;
77
use rustc::ty::layout::{LayoutOf, Primitive, Size};
88
use rustc::mir::BinOp;
99
use rustc::mir::interpret::{
10-
InterpResult, InterpError, Scalar, EvalErrorPanic,
10+
InterpResult, InterpError, Scalar, PanicMessage,
1111
};
1212

1313
use super::{
@@ -261,7 +261,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
261261
let file = Symbol::intern(self.read_str(file_place)?);
262262
let line = self.read_scalar(line.into())?.to_u32()?;
263263
let col = self.read_scalar(col.into())?.to_u32()?;
264-
return Err(InterpError::Panic(EvalErrorPanic::Panic { msg, file, line, col }).into());
264+
return Err(InterpError::Panic(PanicMessage::Panic { msg, file, line, col }).into());
265265
} else if Some(def_id) == self.tcx.lang_items().begin_panic_fn() {
266266
assert!(args.len() == 2);
267267
// &'static str, &(&'static str, u32, u32)
@@ -279,7 +279,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
279279
let file = Symbol::intern(self.read_str(file_place)?);
280280
let line = self.read_scalar(line.into())?.to_u32()?;
281281
let col = self.read_scalar(col.into())?.to_u32()?;
282-
return Err(InterpError::Panic(EvalErrorPanic::Panic { msg, file, line, col }).into());
282+
return Err(InterpError::Panic(PanicMessage::Panic { msg, file, line, col }).into());
283283
} else {
284284
return Ok(false);
285285
}

src/librustc_mir/interpret/operator.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use rustc::mir;
22
use rustc::ty::{self, layout::TyLayout};
33
use syntax::ast::FloatTy;
44
use rustc_apfloat::Float;
5-
use rustc::mir::interpret::{InterpResult, EvalErrorPanic, Scalar};
5+
use rustc::mir::interpret::{InterpResult, PanicMessage, Scalar};
66

77
use super::{InterpCx, PlaceTy, Immediate, Machine, ImmTy};
88

@@ -173,8 +173,8 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
173173
return Ok((Scalar::from_bool(op(&l, &r)), false));
174174
}
175175
let op: Option<fn(i128, i128) -> (i128, bool)> = match bin_op {
176-
Div if r == 0 => return err!(Panic(EvalErrorPanic::DivisionByZero)),
177-
Rem if r == 0 => return err!(Panic(EvalErrorPanic::RemainderByZero)),
176+
Div if r == 0 => return err!(Panic(PanicMessage::DivisionByZero)),
177+
Rem if r == 0 => return err!(Panic(PanicMessage::RemainderByZero)),
178178
Div => Some(i128::overflowing_div),
179179
Rem => Some(i128::overflowing_rem),
180180
Add => Some(i128::overflowing_add),
@@ -231,8 +231,8 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
231231
Add => u128::overflowing_add,
232232
Sub => u128::overflowing_sub,
233233
Mul => u128::overflowing_mul,
234-
Div if r == 0 => return err!(Panic(EvalErrorPanic::DivisionByZero)),
235-
Rem if r == 0 => return err!(Panic(EvalErrorPanic::RemainderByZero)),
234+
Div if r == 0 => return err!(Panic(PanicMessage::DivisionByZero)),
235+
Rem if r == 0 => return err!(Panic(PanicMessage::RemainderByZero)),
236236
Div => u128::overflowing_div,
237237
Rem => u128::overflowing_rem,
238238
_ => bug!(),

src/librustc_mir/interpret/place.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use rustc::ty::TypeFoldable;
1313

1414
use super::{
1515
GlobalId, AllocId, Allocation, Scalar, InterpResult, Pointer, PointerArithmetic,
16-
InterpCx, Machine, AllocMap, AllocationExtra, EvalErrorPanic,
16+
InterpCx, Machine, AllocMap, AllocationExtra, PanicMessage,
1717
RawConst, Immediate, ImmTy, ScalarMaybeUndef, Operand, OpTy, MemoryKind, LocalValue
1818
};
1919

@@ -356,7 +356,7 @@ where
356356
// This can be violated because this runs during promotion on code where the
357357
// type system has not yet ensured that such things don't happen.
358358
debug!("tried to access element {} of array/slice with length {}", field, len);
359-
return err!(Panic(EvalErrorPanic::BoundsCheck { len, index: field }));
359+
return err!(Panic(PanicMessage::BoundsCheck { len, index: field }));
360360
}
361361
stride * field
362362
}

0 commit comments

Comments
 (0)