more grouping of the variants in InterpError
This commit is contained in:
parent
01859bb160
commit
fc48f3e824
1 changed files with 46 additions and 44 deletions
|
@ -137,12 +137,13 @@ impl<'tcx> ConstEvalErr<'tcx> {
|
||||||
message: &str,
|
message: &str,
|
||||||
lint_root: Option<hir::HirId>,
|
lint_root: Option<hir::HirId>,
|
||||||
) -> Result<DiagnosticBuilder<'tcx>, ErrorHandled> {
|
) -> Result<DiagnosticBuilder<'tcx>, ErrorHandled> {
|
||||||
|
use InvalidProgramInfo::*;
|
||||||
match self.error {
|
match self.error {
|
||||||
InterpError::Layout(LayoutError::Unknown(_)) |
|
InterpError::InvalidProgram(Layout(LayoutError::Unknown(_))) |
|
||||||
InterpError::InvalidProgram(InvalidProgramMessage::TooGeneric) =>
|
InterpError::InvalidProgram(TooGeneric) =>
|
||||||
return Err(ErrorHandled::TooGeneric),
|
return Err(ErrorHandled::TooGeneric),
|
||||||
InterpError::Layout(LayoutError::SizeOverflow(_)) |
|
InterpError::Layout(LayoutError::SizeOverflow(_)) |
|
||||||
InterpError::InvalidProgram(InvalidProgramMessage::TypeckError) =>
|
InterpError::InvalidProgram(TypeckError) =>
|
||||||
return Err(ErrorHandled::Reported),
|
return Err(ErrorHandled::Reported),
|
||||||
_ => {},
|
_ => {},
|
||||||
}
|
}
|
||||||
|
@ -312,7 +313,7 @@ impl<O: fmt::Debug> fmt::Debug for PanicMessage<O> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, RustcEncodable, RustcDecodable, HashStable)]
|
#[derive(Clone, RustcEncodable, RustcDecodable, HashStable)]
|
||||||
pub enum InvalidProgramMessage {
|
pub enum InvalidProgramInfo<'tcx> {
|
||||||
/// Resolution can fail if we are in a too generic context
|
/// Resolution can fail if we are in a too generic context
|
||||||
TooGeneric,
|
TooGeneric,
|
||||||
/// Cannot compute this constant because it depends on another one
|
/// Cannot compute this constant because it depends on another one
|
||||||
|
@ -320,50 +321,20 @@ pub enum InvalidProgramMessage {
|
||||||
ReferencedConstant,
|
ReferencedConstant,
|
||||||
/// Abort in case type errors are reached
|
/// Abort in case type errors are reached
|
||||||
TypeckError,
|
TypeckError,
|
||||||
|
Layout(layout::LayoutError<'tcx>),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, RustcEncodable, RustcDecodable, HashStable)]
|
#[derive(Clone, RustcEncodable, RustcDecodable, HashStable)]
|
||||||
pub enum UndefinedBehaviourMessage {
|
pub enum UndefinedBehaviourInfo {
|
||||||
|
Unreachable,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, RustcEncodable, RustcDecodable, HashStable)]
|
#[derive(Clone, RustcEncodable, RustcDecodable, HashStable)]
|
||||||
pub enum UnsupportedMessage {
|
pub enum UnsupportedInfo<'tcx> {
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, RustcEncodable, RustcDecodable, HashStable)]
|
|
||||||
pub enum ResourceExhaustionMessage {
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, RustcEncodable, RustcDecodable, HashStable)]
|
|
||||||
pub enum InterpError<'tcx> {
|
|
||||||
/// The program panicked.
|
|
||||||
Panic(PanicMessage<u64>),
|
|
||||||
/// The program caused undefined behavior.
|
|
||||||
UndefinedBehaviour(UndefinedBehaviourMessage),
|
|
||||||
/// The program did something the interpreter does not support (some of these *might* be UB
|
|
||||||
/// but the interpreter is not sure).
|
|
||||||
Unsupported(UnsupportedMessage),
|
|
||||||
/// The program was invalid (ill-typed, not sufficiently monomorphized, ...).
|
|
||||||
InvalidProgram(InvalidProgramMessage),
|
|
||||||
/// The program exhausted the interpreter's resources (stack/heap too big,
|
|
||||||
/// execution takes too long, ..).
|
|
||||||
ResourceExhaustion(ResourceExhaustionMessage),
|
|
||||||
|
|
||||||
/// THe above 5 variants are what we want to group all the remaining InterpError variants into
|
|
||||||
|
|
||||||
/// This variant is used by machines to signal their own errors that do not
|
|
||||||
/// match an existing variant.
|
|
||||||
MachineError(String),
|
|
||||||
|
|
||||||
/// Not actually an interpreter error -- used to signal that execution has exited
|
|
||||||
/// with the given status code. Used by Miri, but not by CTFE.
|
|
||||||
Exit(i32),
|
|
||||||
|
|
||||||
FunctionAbiMismatch(Abi, Abi),
|
FunctionAbiMismatch(Abi, Abi),
|
||||||
FunctionArgMismatch(Ty<'tcx>, Ty<'tcx>),
|
FunctionArgMismatch(Ty<'tcx>, Ty<'tcx>),
|
||||||
FunctionRetMismatch(Ty<'tcx>, Ty<'tcx>),
|
FunctionRetMismatch(Ty<'tcx>, Ty<'tcx>),
|
||||||
FunctionArgCountMismatch,
|
FunctionArgCountMismatch,
|
||||||
NoMirFor(String),
|
|
||||||
UnterminatedCString(Pointer),
|
UnterminatedCString(Pointer),
|
||||||
DanglingPointerDeref,
|
DanglingPointerDeref,
|
||||||
DoubleFree,
|
DoubleFree,
|
||||||
|
@ -384,12 +355,48 @@ pub enum InterpError<'tcx> {
|
||||||
ReadUndefBytes(Size),
|
ReadUndefBytes(Size),
|
||||||
DeadLocal,
|
DeadLocal,
|
||||||
InvalidBoolOp(mir::BinOp),
|
InvalidBoolOp(mir::BinOp),
|
||||||
|
InlineAsm,
|
||||||
|
UnimplementedTraitSelection,
|
||||||
|
CalledClosureAsFunction,
|
||||||
|
NoMirFor(String),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, RustcEncodable, RustcDecodable, HashStable)]
|
||||||
|
pub enum ResourceExhaustionInfo {
|
||||||
|
StackFrameLimitReached,
|
||||||
|
InfiniteLoop,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, RustcEncodable, RustcDecodable, HashStable)]
|
||||||
|
pub enum InterpError<'tcx> {
|
||||||
|
/// The program panicked.
|
||||||
|
Panic(PanicMessage<u64>),
|
||||||
|
/// The program caused undefined behavior.
|
||||||
|
UndefinedBehaviour(UndefinedBehaviourInfo),
|
||||||
|
/// The program did something the interpreter does not support (some of these *might* be UB
|
||||||
|
/// but the interpreter is not sure).
|
||||||
|
Unsupported(UnsupportedInfo<'tcx>),
|
||||||
|
/// The program was invalid (ill-typed, not sufficiently monomorphized, ...).
|
||||||
|
InvalidProgram(InvalidProgramInfo<'tcx>),
|
||||||
|
/// The program exhausted the interpreter's resources (stack/heap too big,
|
||||||
|
/// execution takes too long, ..).
|
||||||
|
ResourceExhaustion(ResourceExhaustionInfo),
|
||||||
|
|
||||||
|
/// THe above 5 variants are what we want to group all the remaining InterpError variants into
|
||||||
|
|
||||||
|
/// This variant is used by machines to signal their own errors that do not
|
||||||
|
/// match an existing variant.
|
||||||
|
MachineError(String),
|
||||||
|
|
||||||
|
/// Not actually an interpreter error -- used to signal that execution has exited
|
||||||
|
/// with the given status code. Used by Miri, but not by CTFE.
|
||||||
|
Exit(i32),
|
||||||
|
|
||||||
Unimplemented(String),
|
Unimplemented(String),
|
||||||
DerefFunctionPointer,
|
DerefFunctionPointer,
|
||||||
ExecuteMemory,
|
ExecuteMemory,
|
||||||
Intrinsic(String),
|
Intrinsic(String),
|
||||||
InvalidChar(u128),
|
InvalidChar(u128),
|
||||||
StackFrameLimitReached,
|
|
||||||
OutOfTls,
|
OutOfTls,
|
||||||
TlsOutOfBounds,
|
TlsOutOfBounds,
|
||||||
AbiViolation(String),
|
AbiViolation(String),
|
||||||
|
@ -398,25 +405,20 @@ pub enum InterpError<'tcx> {
|
||||||
has: Align,
|
has: Align,
|
||||||
},
|
},
|
||||||
ValidationFailure(String),
|
ValidationFailure(String),
|
||||||
CalledClosureAsFunction,
|
|
||||||
VtableForArgumentlessMethod,
|
VtableForArgumentlessMethod,
|
||||||
ModifiedConstantMemory,
|
ModifiedConstantMemory,
|
||||||
ModifiedStatic,
|
ModifiedStatic,
|
||||||
AssumptionNotHeld,
|
AssumptionNotHeld,
|
||||||
InlineAsm,
|
|
||||||
TypeNotPrimitive(Ty<'tcx>),
|
TypeNotPrimitive(Ty<'tcx>),
|
||||||
ReallocatedWrongMemoryKind(String, String),
|
ReallocatedWrongMemoryKind(String, String),
|
||||||
DeallocatedWrongMemoryKind(String, String),
|
DeallocatedWrongMemoryKind(String, String),
|
||||||
ReallocateNonBasePtr,
|
ReallocateNonBasePtr,
|
||||||
DeallocateNonBasePtr,
|
DeallocateNonBasePtr,
|
||||||
IncorrectAllocationInformation(Size, Size, Align, Align),
|
IncorrectAllocationInformation(Size, Size, Align, Align),
|
||||||
Layout(layout::LayoutError<'tcx>),
|
|
||||||
HeapAllocZeroBytes,
|
HeapAllocZeroBytes,
|
||||||
HeapAllocNonPowerOfTwoAlignment(u64),
|
HeapAllocNonPowerOfTwoAlignment(u64),
|
||||||
Unreachable,
|
|
||||||
ReadFromReturnPointer,
|
ReadFromReturnPointer,
|
||||||
PathNotFound(Vec<String>),
|
PathNotFound(Vec<String>),
|
||||||
UnimplementedTraitSelection,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub type InterpResult<'tcx, T = ()> = Result<T, InterpErrorInfo<'tcx>>;
|
pub type InterpResult<'tcx, T = ()> = Result<T, InterpErrorInfo<'tcx>>;
|
||||||
|
|
Loading…
Reference in a new issue