From daafeb35b731a599fc8b6c4cf37b81f838dae319 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Tue, 17 Sep 2019 08:58:51 +0200 Subject: [PATCH] document Miri error categories --- src/librustc/mir/interpret/error.rs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/librustc/mir/interpret/error.rs b/src/librustc/mir/interpret/error.rs index 09c822f7508..2975944c7fb 100644 --- a/src/librustc/mir/interpret/error.rs +++ b/src/librustc/mir/interpret/error.rs @@ -313,6 +313,9 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { } } +/// Error information for when the program we executed turned out not to actually be a valid +/// program. This cannot happen in stand-alone Miri, but it can happen during CTFE/ConstProp +/// where we work on generic code or execution does not have all information available. #[derive(Clone, RustcEncodable, RustcDecodable, HashStable)] pub enum InvalidProgramInfo<'tcx> { /// Resolution can fail if we are in a too generic context. @@ -342,6 +345,7 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { } } +/// Error information for when the program caused Undefined Behavior. #[derive(Clone, RustcEncodable, RustcDecodable, HashStable)] pub enum UndefinedBehaviorInfo { /// Free-form case. Only for errors that are never caught! @@ -364,12 +368,19 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { } } +/// Error information for when the program did something that might (or might not) be correct +/// to do according to the Rust spec, but due to limitations in the interpreter, the +/// operation could not be carried out. These limitations can differ between CTFE and the +/// Miri engine, e.g., CTFE does not support casting pointers to "real" integers. +/// +/// Currently, we also use this as fall-back error kind for errors that have not been +/// categorized yet. #[derive(Clone, RustcEncodable, RustcDecodable, HashStable)] pub enum UnsupportedOpInfo<'tcx> { /// Free-form case. Only for errors that are never caught! Unsupported(String), - // -- Everything below is not classified yet -- + // -- Everything below is not categorized yet -- FunctionAbiMismatch(Abi, Abi), FunctionArgMismatch(Ty<'tcx>, Ty<'tcx>), FunctionRetMismatch(Ty<'tcx>, Ty<'tcx>), @@ -536,6 +547,8 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { } } +/// Error information for when the program exhausted the resources granted to it +/// by the interpreter. #[derive(Clone, RustcEncodable, RustcDecodable, HashStable)] pub enum ResourceExhaustionInfo { /// The stack grew too big.