]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc/mir/interpret/error.rs
changing the fields of InterpError
[rust.git] / src / librustc / mir / interpret / error.rs
index 5309d5b039e9ebb05f03cfe4ea5742091b7cf65d..8b5f1b7fc93e96560e9ad5ae05d143c92567cc64 100644 (file)
@@ -309,8 +309,30 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
     }
 }
 
+#[derive(Clone, RustcEncodable, RustcDecodable, HashStable)]
+pub enum InvalidProgramMessage<'tcx> {
+    /// Resolution can fail if we are in a too generic context
+    TooGeneric,
+    /// Cannot compute this constant because it depends on another one
+    /// which already produced an error
+    ReferencedConstant,
+    /// Abort in case type errors are reached
+    TypeckError,
+}
+
 #[derive(Clone, RustcEncodable, RustcDecodable, HashStable)]
 pub enum InterpError<'tcx> {
+    /// The program caused undefined behavior.
+    UndefinedBehaviour(UndefinedBehaviourMessage<'tcx>),
+    /// The program did something the interpreter does not support (some of these *might* be UB
+    /// but the interpreter is not sure).
+    Unsupported(UnsupportedMessage<'tcx>),
+    /// The program was invalid (ill-typed, not sufficiently monomorphized, ...).
+    InvalidProgram(InvalidProgramMessage<'tcx>),
+    /// The program exhausted the interpreter's resources (stack/heap too big,
+    /// execution takes too long, ..).
+    ResourceExhaustion(ResourceExhaustionMessage<'tcx>),
+    
     /// This variant is used by machines to signal their own errors that do not
     /// match an existing variant.
     MachineError(String),
@@ -374,18 +396,11 @@ pub enum InterpError<'tcx> {
     HeapAllocZeroBytes,
     HeapAllocNonPowerOfTwoAlignment(u64),
     Unreachable,
+    /// The program panicked.
     Panic(PanicMessage<u64>),
     ReadFromReturnPointer,
     PathNotFound(Vec<String>),
     UnimplementedTraitSelection,
-    /// Abort in case type errors are reached
-    TypeckError,
-    /// Resolution can fail if we are in a too generic context
-    TooGeneric,
-    /// Cannot compute this constant because it depends on another one
-    /// which already produced an error
-    ReferencedConstant,
-    InfiniteLoop,
 }
 
 pub type InterpResult<'tcx, T = ()> = Result<T, InterpErrorInfo<'tcx>>;