From 0aa9658f5d29340e630d3bfcffd41abe16a96b34 Mon Sep 17 00:00:00 2001 From: Saleem Jaffer Date: Thu, 25 Jul 2019 16:59:38 +0530 Subject: [PATCH] changing the fields of InterpError --- src/librustc/mir/interpret/error.rs | 31 +++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/src/librustc/mir/interpret/error.rs b/src/librustc/mir/interpret/error.rs index 5309d5b039e..8b5f1b7fc93 100644 --- a/src/librustc/mir/interpret/error.rs +++ b/src/librustc/mir/interpret/error.rs @@ -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), ReadFromReturnPointer, PathNotFound(Vec), 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>; -- 2.44.0