]> git.lizzy.rs Git - rust.git/commitdiff
use PanicInfo and UnsupportedOpInfo
authorSaleem Jaffer <ssaleem1992@gmail.com>
Mon, 29 Jul 2019 07:58:55 +0000 (13:28 +0530)
committerSaleem Jaffer <ssaleem1992@gmail.com>
Mon, 29 Jul 2019 08:05:59 +0000 (13:35 +0530)
14 files changed:
src/librustc/mir/interpret/error.rs
src/librustc/mir/interpret/mod.rs
src/librustc/mir/mod.rs
src/librustc/mir/visit.rs
src/librustc_codegen_ssa/mir/block.rs
src/librustc_mir/borrow_check/mod.rs
src/librustc_mir/borrow_check/nll/invalidation.rs
src/librustc_mir/borrow_check/nll/type_check/mod.rs
src/librustc_mir/build/expr/as_place.rs
src/librustc_mir/build/expr/as_rvalue.rs
src/librustc_mir/interpret/intrinsics.rs
src/librustc_mir/interpret/terminator.rs
src/librustc_mir/transform/const_prop.rs
src/librustc_mir/transform/generator.rs

index e519a83c026678801c9abe080dca210b89307c7e..5a464ddd383ceff86f8132306f984ddcd3b69716 100644 (file)
@@ -237,7 +237,7 @@ fn from(kind: InterpError<'tcx>) -> Self {
 }
 
 #[derive(Clone, RustcEncodable, RustcDecodable, HashStable)]
-pub enum PanicMessage<O> {
+pub enum PanicInfo<O> {
     Panic {
         msg: Symbol,
         line: u32,
@@ -257,14 +257,14 @@ pub enum PanicMessage<O> {
 }
 
 /// 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",
@@ -293,14 +293,14 @@ pub fn description(&self) -> &'static str {
             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),
@@ -568,7 +568,7 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
 #[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
index c4a3bbfc28b18b61b20d7fb0317dea98f8246b23..4b09da87d314bfc68f8e3f40ccf1d15dfe6a8f9e 100644 (file)
@@ -31,7 +31,7 @@ macro_rules! err_ub {
 macro_rules! err_panic {
     ($($tt:tt)*) => {
         Err($crate::mir::interpret::InterpError::Panic(
-            $crate::mir::interpret::PanicMessage::$($tt)*
+            $crate::mir::interpret::PanicInfo::$($tt)*
         ).into())
     };
 }
@@ -52,7 +52,7 @@ macro_rules! err_exhaust {
 
 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,
 };
 
index 50f16858c0486835a750f9534b0c271c85dd8689..1e2ec08301cf91f544aa4515dd818de05ce13ede 100644 (file)
@@ -7,7 +7,7 @@
 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};
@@ -3152,7 +3152,7 @@ fn super_fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
                 }
             }
             Assert { ref cond, expected, ref msg, target, cleanup } => {
-                use PanicMessage::*;
+                use PanicInfo::*;
                 let msg = match msg {
                     BoundsCheck { ref len, ref index } =>
                         BoundsCheck {
@@ -3200,7 +3200,7 @@ fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
             }
             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),
index 7562981f94f61aab897ad68a74b17c7b37c09669..ee4ecb6762c96a674267956c295876663027d92b 100644 (file)
@@ -514,7 +514,7 @@ fn super_terminator_kind(&mut self,
             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);
index 18611c3e167d22893eaeed234cf7f847eb6cd602..006ebcbdec6727797112984932f2ebc0e8430d52 100644 (file)
@@ -2,7 +2,7 @@
 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;
@@ -368,7 +368,7 @@ fn codegen_assert_terminator<'b>(
         // 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);
             }
         }
@@ -403,7 +403,7 @@ fn codegen_assert_terminator<'b>(
 
         // 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();
 
index 92774bbb7a6b4d509381c58ec521a15bc619218f..2be39799b5273c23d65b8e4d39db44d5f5779b7f 100644 (file)
@@ -733,8 +733,8 @@ fn visit_terminator_entry(
                 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);
                 }
index aa9e68bd7de4412bf91e7e5cb0b2a291bbf40f35..631a81421131c334290d06af2ef8ddcb157f5b2e 100644 (file)
@@ -207,8 +207,8 @@ fn visit_terminator_kind(
                 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);
                 }
index 50c0640f885f2f25a1102812bee95aa6ce1cf67b..f10d505fe89830ca6e46e74371268c6f3eca1d2e 100644 (file)
@@ -26,7 +26,7 @@
 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::*;
@@ -1632,7 +1632,7 @@ fn check_terminator(
                     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)
                     }
index 7a428a2ec9f3626d149714db264af8bf077c7e0b..7005f274e0e7def29f39b88d373595e4b1751c67 100644 (file)
@@ -4,7 +4,7 @@
 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};
 
index 92daf06e6f8fefea4dbf21dba879996b2d431c74..ec061e74535778d7865c0f2b18700f9ed73e0982 100644 (file)
@@ -7,7 +7,7 @@
 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;
@@ -101,7 +101,7 @@ fn expr_as_rvalue(
                         block,
                         Operand::Move(is_min),
                         false,
-                        PanicMessage::OverflowNeg,
+                        PanicInfo::OverflowNeg,
                         expr_span,
                     );
                 }
@@ -401,7 +401,7 @@ pub fn build_binary_op(
             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);
 
@@ -412,11 +412,11 @@ pub fn build_binary_op(
                 // 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);
index f943ff67c085891965b6c89a19c5f9433bb0199b..9605395b84b177f5c2e3ced1200e8beefaf89f06 100644 (file)
@@ -7,7 +7,7 @@
 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::{
@@ -250,7 +250,7 @@ pub fn hook_fn(
             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)
@@ -268,7 +268,7 @@ pub fn hook_fn(
             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);
         }
index b7dbc8384586ec1fd7a14953adae9ad8db0dd044..14b92f2b3d49d350420f21d615cedadef3fe3de9 100644 (file)
@@ -136,7 +136,7 @@ pub(super) fn eval_terminator(
                     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)?)
index 9918356d355b84858937098c83c37a50fa347649..ec8a33f7a43fa0b96302f738da9952b619c657bc 100644 (file)
@@ -13,7 +13,7 @@
 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;
@@ -526,7 +526,7 @@ fn const_prop(
                     )
                 } 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;
                     }
@@ -763,12 +763,12 @@ fn visit_terminator(
                             .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");
index 5461a2e470c7e62a7e2ebb5d4ee23fb5e83586c5..94bb70e10aa53bda6d01b87dd69ef95704592f46 100644 (file)
@@ -1016,7 +1016,7 @@ fn create_generator_resume_function<'tcx>(
 
     let mut cases = create_cases(body, &transform, |point| Some(point.resume));
 
-    use rustc::mir::interpret::PanicMessage::{
+    use rustc::mir::interpret::PanicInfo::{
         GeneratorResumedAfterPanic,
         GeneratorResumedAfterReturn,
     };