}
#[derive(Clone, RustcEncodable, RustcDecodable, HashStable)]
-pub enum PanicMessage<O> {
+pub enum PanicInfo<O> {
Panic {
msg: Symbol,
line: u32,
}
/// Type for MIR `Assert` terminator error messages.
-pub type AssertMessage<'tcx> = PanicMessage<mir::Operand<'tcx>>;
+pub type AssertMessage<'tcx> = PanicInfo<mir::Operand<'tcx>>;
-impl<O> PanicMessage<O> {
+impl<O> PanicInfo<O> {
/// Getting a description does not require `O` to be printable, and does not
/// require allocation.
/// The caller is expected to handle `Panic` and `BoundsCheck` separately.
pub fn description(&self) -> &'static str {
- use PanicMessage::*;
+ use PanicInfo::*;
match self {
Overflow(mir::BinOp::Add) =>
"attempt to add with overflow",
GeneratorResumedAfterPanic =>
"generator resumed after panicking",
Panic { .. } | BoundsCheck { .. } =>
- bug!("Unexpected PanicMessage"),
+ bug!("Unexpected PanicInfo"),
}
}
}
-impl<O: fmt::Debug> fmt::Debug for PanicMessage<O> {
+impl<O: fmt::Debug> fmt::Debug for PanicInfo<O> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
- use PanicMessage::*;
+ use PanicInfo::*;
match self {
Panic { ref msg, line, col, ref file } =>
write!(f, "the evaluated program panicked at '{}', {}:{}:{}", msg, file, line, col),
#[derive(Clone, RustcEncodable, RustcDecodable, HashStable)]
pub enum InterpError<'tcx> {
/// The program panicked.
- Panic(PanicMessage<u64>),
+ Panic(PanicInfo<u64>),
/// The program caused undefined behavior.
UndefinedBehaviour(UndefinedBehaviourInfo),
/// The program did something the interpreter does not support (some of these *might* be UB
macro_rules! err_panic {
($($tt:tt)*) => {
Err($crate::mir::interpret::InterpError::Panic(
- $crate::mir::interpret::PanicMessage::$($tt)*
+ $crate::mir::interpret::PanicInfo::$($tt)*
).into())
};
}
pub use self::error::{
InterpErrorInfo, InterpResult, InterpError, AssertMessage, ConstEvalErr, struct_error,
- FrameInfo, ConstEvalRawResult, ConstEvalResult, ErrorHandled, PanicMessage, UnsupportedInfo,
+ FrameInfo, ConstEvalRawResult, ConstEvalResult, ErrorHandled, PanicInfo, UnsupportedInfo,
InvalidProgramInfo, ResourceExhaustionInfo, UndefinedBehaviourInfo,
};
use crate::hir::def::{CtorKind, Namespace};
use crate::hir::def_id::DefId;
use crate::hir::{self, InlineAsm as HirInlineAsm};
-use crate::mir::interpret::{ConstValue, PanicMessage, Scalar};
+use crate::mir::interpret::{ConstValue, PanicInfo, Scalar};
use crate::mir::visit::MirVisitable;
use crate::ty::adjustment::PointerCast;
use crate::ty::fold::{TypeFoldable, TypeFolder, TypeVisitor};
}
}
Assert { ref cond, expected, ref msg, target, cleanup } => {
- use PanicMessage::*;
+ use PanicInfo::*;
let msg = match msg {
BoundsCheck { ref len, ref index } =>
BoundsCheck {
}
Assert { ref cond, ref msg, .. } => {
if cond.visit_with(visitor) {
- use PanicMessage::*;
+ use PanicInfo::*;
match msg {
BoundsCheck { ref len, ref index } =>
len.visit_with(visitor) || index.visit_with(visitor),
fn super_assert_message(&mut self,
msg: & $($mutability)? AssertMessage<'tcx>,
location: Location) {
- use crate::mir::interpret::PanicMessage::*;
+ use crate::mir::interpret::PanicInfo::*;
match msg {
BoundsCheck { len, index } => {
self.visit_operand(len, location);
use rustc::ty::{self, Ty, TypeFoldable, Instance};
use rustc::ty::layout::{self, LayoutOf, HasTyCtxt, FnTypeExt};
use rustc::mir::{self, Place, PlaceBase, Static, StaticKind};
-use rustc::mir::interpret::PanicMessage;
+use rustc::mir::interpret::PanicInfo;
use rustc_target::abi::call::{ArgType, FnType, PassMode, IgnoreMode};
use rustc_target::spec::abi::Abi;
use crate::base;
// checked operation, just a comparison with the minimum
// value, so we have to check for the assert message.
if !bx.check_overflow() {
- if let PanicMessage::OverflowNeg = *msg {
+ if let PanicInfo::OverflowNeg = *msg {
const_cond = Some(expected);
}
}
// Put together the arguments to the panic entry point.
let (lang_item, args) = match msg {
- PanicMessage::BoundsCheck { ref len, ref index } => {
+ PanicInfo::BoundsCheck { ref len, ref index } => {
let len = self.codegen_operand(&mut bx, len).immediate();
let index = self.codegen_operand(&mut bx, index).immediate();
cleanup: _,
} => {
self.consume_operand(loc, (cond, span), flow_state);
- use rustc::mir::interpret::PanicMessage;
- if let PanicMessage::BoundsCheck { ref len, ref index } = *msg {
+ use rustc::mir::interpret::PanicInfo;
+ if let PanicInfo::BoundsCheck { ref len, ref index } = *msg {
self.consume_operand(loc, (len, span), flow_state);
self.consume_operand(loc, (index, span), flow_state);
}
cleanup: _,
} => {
self.consume_operand(location, cond);
- use rustc::mir::interpret::PanicMessage;
- if let PanicMessage::BoundsCheck { ref len, ref index } = *msg {
+ use rustc::mir::interpret::PanicInfo;
+ if let PanicInfo::BoundsCheck { ref len, ref index } = *msg {
self.consume_operand(location, len);
self.consume_operand(location, index);
}
use rustc::infer::outlives::env::RegionBoundPairs;
use rustc::infer::{InferCtxt, InferOk, LateBoundRegionConversionTime, NLLRegionVariableOrigin};
use rustc::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
-use rustc::mir::interpret::{ConstValue, PanicMessage};
+use rustc::mir::interpret::{ConstValue, PanicInfo};
use rustc::mir::tcx::PlaceTy;
use rustc::mir::visit::{PlaceContext, Visitor, NonMutatingUseContext};
use rustc::mir::*;
span_mirbug!(self, term, "bad Assert ({:?}, not bool", cond_ty);
}
- if let PanicMessage::BoundsCheck { ref len, ref index } = *msg {
+ if let PanicInfo::BoundsCheck { ref len, ref index } = *msg {
if len.ty(body, tcx) != tcx.types.usize {
span_mirbug!(self, len, "bounds-check length non-usize {:?}", len)
}
use crate::build::ForGuard::{OutsideGuard, RefWithinGuard};
use crate::build::{BlockAnd, BlockAndExtension, Builder};
use crate::hair::*;
-use rustc::mir::interpret::{PanicMessage::BoundsCheck};
+use rustc::mir::interpret::{PanicInfo::BoundsCheck};
use rustc::mir::*;
use rustc::ty::{CanonicalUserTypeAnnotation, Variance};
use crate::build::{BlockAnd, BlockAndExtension, Builder};
use crate::hair::*;
use rustc::middle::region;
-use rustc::mir::interpret::PanicMessage;
+use rustc::mir::interpret::PanicInfo;
use rustc::mir::*;
use rustc::ty::{self, CanonicalUserTypeAnnotation, Ty, UpvarSubsts};
use syntax_pos::Span;
block,
Operand::Move(is_min),
false,
- PanicMessage::OverflowNeg,
+ PanicInfo::OverflowNeg,
expr_span,
);
}
let val = result_value.clone().field(val_fld, ty);
let of = result_value.field(of_fld, bool_ty);
- let err = PanicMessage::Overflow(op);
+ let err = PanicInfo::Overflow(op);
block = self.assert(block, Operand::Move(of), false, err, span);
// and 2. there are two possible failure cases, divide-by-zero and overflow.
let zero_err = if op == BinOp::Div {
- PanicMessage::DivisionByZero
+ PanicInfo::DivisionByZero
} else {
- PanicMessage::RemainderByZero
+ PanicInfo::RemainderByZero
};
- let overflow_err = PanicMessage::Overflow(op);
+ let overflow_err = PanicInfo::Overflow(op);
// Check for / 0
let is_zero = self.temp(bool_ty, span);
use rustc::ty::layout::{LayoutOf, Primitive, Size};
use rustc::mir::BinOp;
use rustc::mir::interpret::{
- InterpResult, InterpError, Scalar, PanicMessage, UnsupportedInfo::*,
+ InterpResult, InterpError, Scalar, PanicInfo, UnsupportedInfo::*,
};
use super::{
let file = Symbol::intern(self.read_str(file_place)?);
let line = self.read_scalar(line.into())?.to_u32()?;
let col = self.read_scalar(col.into())?.to_u32()?;
- return Err(InterpError::Panic(PanicMessage::Panic { msg, file, line, col }).into());
+ return Err(InterpError::Panic(PanicInfo::Panic { msg, file, line, col }).into());
} else if Some(def_id) == self.tcx.lang_items().begin_panic_fn() {
assert!(args.len() == 2);
// &'static str, &(&'static str, u32, u32)
let file = Symbol::intern(self.read_str(file_place)?);
let line = self.read_scalar(line.into())?.to_u32()?;
let col = self.read_scalar(col.into())?.to_u32()?;
- return Err(InterpError::Panic(PanicMessage::Panic { msg, file, line, col }).into());
+ return Err(InterpError::Panic(PanicInfo::Panic { msg, file, line, col }).into());
} else {
return Ok(false);
}
self.goto_block(Some(target))?;
} else {
// Compute error message
- use rustc::mir::interpret::PanicMessage::*;
+ use rustc::mir::interpret::PanicInfo::*;
return match msg {
BoundsCheck { ref len, ref index } => {
let len = self.read_immediate(self.eval_operand(len, None)?)
use rustc::mir::visit::{
Visitor, PlaceContext, MutatingUseContext, MutVisitor, NonMutatingUseContext,
};
-use rustc::mir::interpret::{Scalar, GlobalId, InterpResult, InterpError, PanicMessage};
+use rustc::mir::interpret::{Scalar, GlobalId, InterpResult, InterpError, PanicInfo};
use rustc::ty::{self, Instance, ParamEnv, Ty, TyCtxt};
use syntax_pos::{Span, DUMMY_SP};
use rustc::ty::subst::InternalSubsts;
)
} else {
if overflow {
- let err = InterpError::Panic(PanicMessage::Overflow(op)).into();
+ let err = InterpError::Panic(PanicInfo::Overflow(op)).into();
let _: Option<()> = self.use_ecx(source_info, |_| Err(err));
return None;
}
.as_local_hir_id(self.source.def_id())
.expect("some part of a failing const eval must be local");
let msg = match msg {
- PanicMessage::Overflow(_) |
- PanicMessage::OverflowNeg |
- PanicMessage::DivisionByZero |
- PanicMessage::RemainderByZero =>
+ PanicInfo::Overflow(_) |
+ PanicInfo::OverflowNeg |
+ PanicInfo::DivisionByZero |
+ PanicInfo::RemainderByZero =>
msg.description().to_owned(),
- PanicMessage::BoundsCheck { ref len, ref index } => {
+ PanicInfo::BoundsCheck { ref len, ref index } => {
let len = self
.eval_operand(len, source_info)
.expect("len must be const");
let mut cases = create_cases(body, &transform, |point| Some(point.resume));
- use rustc::mir::interpret::PanicMessage::{
+ use rustc::mir::interpret::PanicInfo::{
GeneratorResumedAfterPanic,
GeneratorResumedAfterReturn,
};