2016-03-14 21:48:00 -06:00
|
|
|
use std::error::Error;
|
2017-08-04 10:55:35 -07:00
|
|
|
use std::{fmt, env};
|
2017-08-02 16:59:01 +02:00
|
|
|
|
2016-11-03 10:38:08 +01:00
|
|
|
use rustc::mir;
|
2017-03-14 10:49:22 +01:00
|
|
|
use rustc::ty::{FnSig, Ty, layout};
|
2017-07-21 13:39:06 +02:00
|
|
|
|
|
|
|
use super::{
|
2017-08-07 12:34:33 -07:00
|
|
|
MemoryPointer, Lock, AccessKind
|
2017-07-21 13:39:06 +02:00
|
|
|
};
|
|
|
|
|
2016-06-17 13:09:20 +02:00
|
|
|
use rustc_const_math::ConstMathErr;
|
|
|
|
use syntax::codemap::Span;
|
2017-08-03 12:37:52 +02:00
|
|
|
use backtrace::Backtrace;
|
2016-03-14 21:48:00 -06:00
|
|
|
|
2017-07-25 11:32:48 +02:00
|
|
|
#[derive(Debug)]
|
2017-08-02 16:59:01 +02:00
|
|
|
pub struct EvalError<'tcx> {
|
|
|
|
pub kind: EvalErrorKind<'tcx>,
|
2017-08-04 10:55:35 -07:00
|
|
|
pub backtrace: Option<Backtrace>,
|
2017-08-02 16:59:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
impl<'tcx> From<EvalErrorKind<'tcx>> for EvalError<'tcx> {
|
|
|
|
fn from(kind: EvalErrorKind<'tcx>) -> Self {
|
2017-08-04 10:55:35 -07:00
|
|
|
let backtrace = match env::var("RUST_BACKTRACE") {
|
|
|
|
Ok(ref val) if !val.is_empty() => Some(Backtrace::new_unresolved()),
|
|
|
|
_ => None
|
|
|
|
};
|
2017-08-02 16:59:01 +02:00
|
|
|
EvalError {
|
|
|
|
kind,
|
2017-08-04 10:55:35 -07:00
|
|
|
backtrace,
|
2017-08-02 16:59:01 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug)]
|
|
|
|
pub enum EvalErrorKind<'tcx> {
|
2017-07-25 11:32:48 +02:00
|
|
|
/// This variant is used by machines to signal their own errors that do not
|
|
|
|
/// match an existing variant
|
|
|
|
MachineError(Box<Error>),
|
2017-03-14 10:49:22 +01:00
|
|
|
FunctionPointerTyMismatch(FnSig<'tcx>, FnSig<'tcx>),
|
2016-09-27 17:01:06 +02:00
|
|
|
NoMirFor(String),
|
2017-07-04 13:16:29 +02:00
|
|
|
UnterminatedCString(MemoryPointer),
|
2016-03-14 21:48:00 -06:00
|
|
|
DanglingPointerDeref,
|
2017-07-12 14:51:47 +02:00
|
|
|
DoubleFree,
|
2016-09-22 15:47:16 +02:00
|
|
|
InvalidMemoryAccess,
|
2016-06-08 13:43:34 +02:00
|
|
|
InvalidFunctionPointer,
|
2016-03-14 21:48:00 -06:00
|
|
|
InvalidBool,
|
2016-03-28 21:08:08 -06:00
|
|
|
InvalidDiscriminant,
|
2016-05-31 12:05:25 +02:00
|
|
|
PointerOutOfBounds {
|
2017-07-04 13:16:29 +02:00
|
|
|
ptr: MemoryPointer,
|
2017-06-04 19:31:34 -07:00
|
|
|
access: bool,
|
2016-11-18 12:55:14 +01:00
|
|
|
allocation_size: u64,
|
2016-05-31 12:05:25 +02:00
|
|
|
},
|
2017-06-22 18:41:10 -07:00
|
|
|
InvalidNullPointerUsage,
|
2016-03-18 23:03:46 -06:00
|
|
|
ReadPointerAsBytes,
|
2017-06-19 10:58:59 +02:00
|
|
|
ReadBytesAsPointer,
|
2016-03-18 23:03:46 -06:00
|
|
|
InvalidPointerMath,
|
2016-03-26 23:56:49 -06:00
|
|
|
ReadUndefBytes,
|
2017-05-31 17:41:33 -07:00
|
|
|
DeadLocal,
|
2016-05-30 15:27:52 +02:00
|
|
|
InvalidBoolOp(mir::BinOp),
|
|
|
|
Unimplemented(String),
|
2016-06-13 11:39:15 +02:00
|
|
|
DerefFunctionPointer,
|
|
|
|
ExecuteMemory,
|
2016-06-17 13:09:20 +02:00
|
|
|
ArrayIndexOutOfBounds(Span, u64, u64),
|
|
|
|
Math(Span, ConstMathErr),
|
2017-06-22 00:08:19 -07:00
|
|
|
Intrinsic(String),
|
2017-06-07 15:39:44 -07:00
|
|
|
OverflowingMath,
|
2017-01-12 08:28:42 +01:00
|
|
|
InvalidChar(u128),
|
2016-07-05 10:47:10 +02:00
|
|
|
OutOfMemory {
|
2016-11-18 12:55:14 +01:00
|
|
|
allocation_size: u64,
|
|
|
|
memory_size: u64,
|
|
|
|
memory_usage: u64,
|
2016-07-05 13:17:40 +02:00
|
|
|
},
|
|
|
|
ExecutionTimeLimitReached,
|
2016-07-05 13:23:58 +02:00
|
|
|
StackFrameLimitReached,
|
2017-05-25 16:40:13 -07:00
|
|
|
OutOfTls,
|
|
|
|
TlsOutOfBounds,
|
2017-05-25 22:38:07 -07:00
|
|
|
AbiViolation(String),
|
2016-07-05 14:27:27 +02:00
|
|
|
AlignmentCheckFailed {
|
2016-11-18 12:55:14 +01:00
|
|
|
required: u64,
|
|
|
|
has: u64,
|
2016-07-05 14:27:27 +02:00
|
|
|
},
|
2017-06-16 17:58:18 -07:00
|
|
|
MemoryLockViolation {
|
|
|
|
ptr: MemoryPointer,
|
|
|
|
len: u64,
|
2017-07-19 19:45:25 -07:00
|
|
|
frame: usize,
|
2017-06-16 17:58:18 -07:00
|
|
|
access: AccessKind,
|
2017-08-07 12:34:33 -07:00
|
|
|
lock: Lock,
|
2017-06-16 17:58:18 -07:00
|
|
|
},
|
2017-07-19 19:45:25 -07:00
|
|
|
MemoryAcquireConflict {
|
|
|
|
ptr: MemoryPointer,
|
|
|
|
len: u64,
|
|
|
|
kind: AccessKind,
|
2017-08-07 12:34:33 -07:00
|
|
|
lock: Lock,
|
2017-07-19 19:45:25 -07:00
|
|
|
},
|
2017-06-19 14:56:05 -07:00
|
|
|
InvalidMemoryLockRelease {
|
|
|
|
ptr: MemoryPointer,
|
|
|
|
len: u64,
|
2017-07-24 14:17:58 -07:00
|
|
|
frame: usize,
|
2017-08-07 12:34:33 -07:00
|
|
|
lock: Lock,
|
2017-06-19 14:56:05 -07:00
|
|
|
},
|
2017-07-13 20:08:35 -07:00
|
|
|
DeallocatedLockedMemory {
|
|
|
|
ptr: MemoryPointer,
|
2017-08-07 12:34:33 -07:00
|
|
|
lock: Lock,
|
2017-07-13 20:08:35 -07:00
|
|
|
},
|
|
|
|
ValidationFailure(String),
|
2016-09-09 12:51:14 +02:00
|
|
|
CalledClosureAsFunction,
|
|
|
|
VtableForArgumentlessMethod,
|
2016-09-09 17:44:04 +02:00
|
|
|
ModifiedConstantMemory,
|
2016-09-13 13:08:57 +02:00
|
|
|
AssumptionNotHeld,
|
2016-09-28 11:48:43 -06:00
|
|
|
InlineAsm,
|
2016-11-03 12:30:41 +01:00
|
|
|
TypeNotPrimitive(Ty<'tcx>),
|
2017-07-28 16:48:43 +02:00
|
|
|
ReallocatedWrongMemoryKind(String, String),
|
|
|
|
DeallocatedWrongMemoryKind(String, String),
|
2017-07-03 16:06:06 -07:00
|
|
|
ReallocateNonBasePtr,
|
|
|
|
DeallocateNonBasePtr,
|
|
|
|
IncorrectAllocationInformation,
|
2016-11-17 17:23:40 +01:00
|
|
|
Layout(layout::LayoutError<'tcx>),
|
2017-06-23 12:55:49 +02:00
|
|
|
HeapAllocZeroBytes,
|
|
|
|
HeapAllocNonPowerOfTwoAlignment(u64),
|
2017-01-12 09:41:36 +01:00
|
|
|
Unreachable,
|
2017-02-09 10:34:23 +01:00
|
|
|
Panic,
|
2017-06-28 13:37:23 +02:00
|
|
|
ReadFromReturnPointer,
|
2017-07-12 10:36:14 +02:00
|
|
|
PathNotFound(Vec<String>),
|
2016-03-14 21:48:00 -06:00
|
|
|
}
|
|
|
|
|
2017-02-04 13:09:10 -08:00
|
|
|
pub type EvalResult<'tcx, T = ()> = Result<T, EvalError<'tcx>>;
|
2016-03-14 21:48:00 -06:00
|
|
|
|
2016-06-14 10:34:54 +02:00
|
|
|
impl<'tcx> Error for EvalError<'tcx> {
|
2016-03-14 21:48:00 -06:00
|
|
|
fn description(&self) -> &str {
|
2017-08-02 16:59:01 +02:00
|
|
|
use self::EvalErrorKind::*;
|
|
|
|
match self.kind {
|
2017-07-25 11:32:48 +02:00
|
|
|
MachineError(ref inner) => inner.description(),
|
2017-07-03 16:06:06 -07:00
|
|
|
FunctionPointerTyMismatch(..) =>
|
2016-06-14 10:34:54 +02:00
|
|
|
"tried to call a function through a function pointer of a different type",
|
2017-07-03 16:06:06 -07:00
|
|
|
InvalidMemoryAccess =>
|
2016-09-22 15:47:16 +02:00
|
|
|
"tried to access memory through an invalid pointer",
|
2017-07-03 16:06:06 -07:00
|
|
|
DanglingPointerDeref =>
|
2016-03-26 23:56:49 -06:00
|
|
|
"dangling pointer was dereferenced",
|
2017-07-12 14:51:47 +02:00
|
|
|
DoubleFree =>
|
|
|
|
"tried to deallocate dangling pointer",
|
2017-07-03 16:06:06 -07:00
|
|
|
InvalidFunctionPointer =>
|
2017-08-08 13:06:14 +02:00
|
|
|
"tried to use a function pointer after offsetting it",
|
2017-07-03 16:06:06 -07:00
|
|
|
InvalidBool =>
|
2016-03-26 23:56:49 -06:00
|
|
|
"invalid boolean value read",
|
2017-07-03 16:06:06 -07:00
|
|
|
InvalidDiscriminant =>
|
2016-03-28 21:08:08 -06:00
|
|
|
"invalid enum discriminant value read",
|
2017-07-03 16:06:06 -07:00
|
|
|
PointerOutOfBounds { .. } =>
|
2016-03-26 23:56:49 -06:00
|
|
|
"pointer offset outside bounds of allocation",
|
2017-07-03 16:06:06 -07:00
|
|
|
InvalidNullPointerUsage =>
|
2017-06-22 18:41:10 -07:00
|
|
|
"invalid use of NULL pointer",
|
2017-06-16 17:58:18 -07:00
|
|
|
MemoryLockViolation { .. } =>
|
|
|
|
"memory access conflicts with lock",
|
2017-07-19 19:45:25 -07:00
|
|
|
MemoryAcquireConflict { .. } =>
|
|
|
|
"new memory lock conflicts with existing lock",
|
2017-07-13 17:25:38 -07:00
|
|
|
ValidationFailure(..) =>
|
|
|
|
"type validation failed",
|
2017-06-19 14:56:05 -07:00
|
|
|
InvalidMemoryLockRelease { .. } =>
|
2017-07-19 19:45:25 -07:00
|
|
|
"invalid attempt to release write lock",
|
2017-07-13 20:08:35 -07:00
|
|
|
DeallocatedLockedMemory { .. } =>
|
|
|
|
"tried to deallocate memory in conflict with a lock",
|
2017-07-03 16:06:06 -07:00
|
|
|
ReadPointerAsBytes =>
|
2016-03-18 23:03:46 -06:00
|
|
|
"a raw memory access tried to access part of a pointer value as raw bytes",
|
2017-07-03 16:06:06 -07:00
|
|
|
ReadBytesAsPointer =>
|
2017-06-19 10:58:59 +02:00
|
|
|
"a memory access tried to interpret some bytes as a pointer",
|
2017-07-03 16:06:06 -07:00
|
|
|
InvalidPointerMath =>
|
2017-06-23 13:30:31 +02:00
|
|
|
"attempted to do invalid arithmetic on pointers that would leak base addresses, e.g. comparing pointers into different allocations",
|
2017-07-03 16:06:06 -07:00
|
|
|
ReadUndefBytes =>
|
2016-03-26 23:56:49 -06:00
|
|
|
"attempted to read undefined bytes",
|
2017-07-03 16:06:06 -07:00
|
|
|
DeadLocal =>
|
2017-05-31 17:41:33 -07:00
|
|
|
"tried to access a dead local variable",
|
2017-07-03 16:06:06 -07:00
|
|
|
InvalidBoolOp(_) =>
|
2016-05-30 15:27:52 +02:00
|
|
|
"invalid boolean operation",
|
2017-07-03 16:06:06 -07:00
|
|
|
Unimplemented(ref msg) => msg,
|
|
|
|
DerefFunctionPointer =>
|
2016-06-13 11:39:15 +02:00
|
|
|
"tried to dereference a function pointer",
|
2017-07-03 16:06:06 -07:00
|
|
|
ExecuteMemory =>
|
2016-06-13 11:39:15 +02:00
|
|
|
"tried to treat a memory pointer as a function pointer",
|
2017-07-03 16:06:06 -07:00
|
|
|
ArrayIndexOutOfBounds(..) =>
|
2016-06-17 13:09:20 +02:00
|
|
|
"array index out of bounds",
|
2017-07-03 16:06:06 -07:00
|
|
|
Math(..) =>
|
2016-06-17 13:09:20 +02:00
|
|
|
"mathematical operation failed",
|
2017-07-03 16:06:06 -07:00
|
|
|
Intrinsic(..) =>
|
2017-06-22 00:08:19 -07:00
|
|
|
"intrinsic failed",
|
2017-07-03 16:06:06 -07:00
|
|
|
OverflowingMath =>
|
2017-06-07 15:39:44 -07:00
|
|
|
"attempted to do overflowing math",
|
2017-07-03 16:06:06 -07:00
|
|
|
NoMirFor(..) =>
|
2016-09-27 17:01:06 +02:00
|
|
|
"mir not found",
|
2017-07-03 16:06:06 -07:00
|
|
|
InvalidChar(..) =>
|
2016-06-20 12:29:45 +02:00
|
|
|
"tried to interpret an invalid 32-bit value as a char",
|
2017-07-03 16:06:06 -07:00
|
|
|
OutOfMemory{..} =>
|
2016-07-05 13:17:40 +02:00
|
|
|
"could not allocate more memory",
|
2017-07-03 16:06:06 -07:00
|
|
|
ExecutionTimeLimitReached =>
|
2016-07-05 13:17:40 +02:00
|
|
|
"reached the configured maximum execution time",
|
2017-07-03 16:06:06 -07:00
|
|
|
StackFrameLimitReached =>
|
2016-07-05 13:23:58 +02:00
|
|
|
"reached the configured maximum number of stack frames",
|
2017-07-03 16:06:06 -07:00
|
|
|
OutOfTls =>
|
2017-05-25 16:40:13 -07:00
|
|
|
"reached the maximum number of representable TLS keys",
|
2017-07-03 16:06:06 -07:00
|
|
|
TlsOutOfBounds =>
|
2017-05-25 16:40:13 -07:00
|
|
|
"accessed an invalid (unallocated) TLS key",
|
2017-07-03 16:06:06 -07:00
|
|
|
AbiViolation(ref msg) => msg,
|
|
|
|
AlignmentCheckFailed{..} =>
|
2016-07-05 14:27:27 +02:00
|
|
|
"tried to execute a misaligned read or write",
|
2017-07-03 16:06:06 -07:00
|
|
|
CalledClosureAsFunction =>
|
2016-09-09 12:51:14 +02:00
|
|
|
"tried to call a closure through a function pointer",
|
2017-07-03 16:06:06 -07:00
|
|
|
VtableForArgumentlessMethod =>
|
2016-09-09 12:51:14 +02:00
|
|
|
"tried to call a vtable function without arguments",
|
2017-07-03 16:06:06 -07:00
|
|
|
ModifiedConstantMemory =>
|
2016-09-09 17:44:04 +02:00
|
|
|
"tried to modify constant memory",
|
2017-07-03 16:06:06 -07:00
|
|
|
AssumptionNotHeld =>
|
2016-09-28 18:22:25 +02:00
|
|
|
"`assume` argument was false",
|
2017-07-03 16:06:06 -07:00
|
|
|
InlineAsm =>
|
2017-02-10 05:27:02 -08:00
|
|
|
"miri does not support inline assembly",
|
2017-07-03 16:06:06 -07:00
|
|
|
TypeNotPrimitive(_) =>
|
2016-11-03 12:30:41 +01:00
|
|
|
"expected primitive type, got nonprimitive",
|
2017-07-12 14:51:47 +02:00
|
|
|
ReallocatedWrongMemoryKind(_, _) =>
|
2017-08-03 12:37:24 +02:00
|
|
|
"tried to reallocate memory from one kind to another",
|
2017-07-12 14:51:47 +02:00
|
|
|
DeallocatedWrongMemoryKind(_, _) =>
|
|
|
|
"tried to deallocate memory of the wrong kind",
|
2017-07-03 16:06:06 -07:00
|
|
|
ReallocateNonBasePtr =>
|
|
|
|
"tried to reallocate with a pointer not to the beginning of an existing object",
|
|
|
|
DeallocateNonBasePtr =>
|
|
|
|
"tried to deallocate with a pointer not to the beginning of an existing object",
|
|
|
|
IncorrectAllocationInformation =>
|
|
|
|
"tried to deallocate or reallocate using incorrect alignment or size",
|
|
|
|
Layout(_) =>
|
2016-11-17 17:23:40 +01:00
|
|
|
"rustc layout computation failed",
|
2017-07-03 16:06:06 -07:00
|
|
|
UnterminatedCString(_) =>
|
2016-12-16 17:10:16 -08:00
|
|
|
"attempted to get length of a null terminated string, but no null found before end of allocation",
|
2017-07-03 16:06:06 -07:00
|
|
|
HeapAllocZeroBytes =>
|
2017-06-23 12:55:49 +02:00
|
|
|
"tried to re-, de- or allocate zero bytes on the heap",
|
2017-07-03 16:06:06 -07:00
|
|
|
HeapAllocNonPowerOfTwoAlignment(_) =>
|
2017-06-23 12:55:49 +02:00
|
|
|
"tried to re-, de-, or allocate heap memory with alignment that is not a power of two",
|
2017-07-03 16:06:06 -07:00
|
|
|
Unreachable =>
|
2017-01-12 09:41:36 +01:00
|
|
|
"entered unreachable code",
|
2017-07-03 16:06:06 -07:00
|
|
|
Panic =>
|
2017-02-09 10:34:23 +01:00
|
|
|
"the evaluated program panicked",
|
2017-07-03 16:06:06 -07:00
|
|
|
ReadFromReturnPointer =>
|
2017-06-28 13:37:23 +02:00
|
|
|
"tried to read from the return pointer",
|
2017-08-02 16:59:01 +02:00
|
|
|
EvalErrorKind::PathNotFound(_) =>
|
2017-07-12 10:36:14 +02:00
|
|
|
"a path could not be resolved, maybe the crate is not loaded",
|
2016-03-14 21:48:00 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-07-25 11:32:48 +02:00
|
|
|
fn cause(&self) -> Option<&Error> {
|
2017-08-02 16:59:01 +02:00
|
|
|
use self::EvalErrorKind::*;
|
|
|
|
match self.kind {
|
2017-07-25 11:32:48 +02:00
|
|
|
MachineError(ref inner) => Some(&**inner),
|
|
|
|
_ => None,
|
|
|
|
}
|
|
|
|
}
|
2016-03-14 21:48:00 -06:00
|
|
|
}
|
|
|
|
|
2016-06-14 10:34:54 +02:00
|
|
|
impl<'tcx> fmt::Display for EvalError<'tcx> {
|
2016-03-14 21:48:00 -06:00
|
|
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
2017-08-02 16:59:01 +02:00
|
|
|
use self::EvalErrorKind::*;
|
|
|
|
match self.kind {
|
2017-07-03 16:06:06 -07:00
|
|
|
PointerOutOfBounds { ptr, access, allocation_size } => {
|
2017-06-04 19:31:34 -07:00
|
|
|
write!(f, "{} at offset {}, outside bounds of allocation {} which has size {}",
|
|
|
|
if access { "memory access" } else { "pointer computed" },
|
|
|
|
ptr.offset, ptr.alloc_id, allocation_size)
|
2016-06-01 11:22:37 +02:00
|
|
|
},
|
2017-07-19 19:45:25 -07:00
|
|
|
MemoryLockViolation { ptr, len, frame, access, ref lock } => {
|
|
|
|
write!(f, "{:?} access by frame {} at {:?}, size {}, is in conflict with lock {:?}",
|
|
|
|
access, frame, ptr, len, lock)
|
|
|
|
}
|
|
|
|
MemoryAcquireConflict { ptr, len, kind, ref lock } => {
|
|
|
|
write!(f, "new {:?} lock at {:?}, size {}, is in conflict with lock {:?}",
|
|
|
|
kind, ptr, len, lock)
|
2017-06-16 17:58:18 -07:00
|
|
|
}
|
2017-07-24 14:17:58 -07:00
|
|
|
InvalidMemoryLockRelease { ptr, len, frame, ref lock } => {
|
|
|
|
write!(f, "frame {} tried to release memory write lock at {:?}, size {}, but cannot release lock {:?}",
|
|
|
|
frame, ptr, len, lock)
|
2017-06-19 14:56:05 -07:00
|
|
|
}
|
2017-07-18 16:43:37 -07:00
|
|
|
DeallocatedLockedMemory { ptr, ref lock } => {
|
2017-07-13 20:08:35 -07:00
|
|
|
write!(f, "tried to deallocate memory at {:?} in conflict with lock {:?}",
|
|
|
|
ptr, lock)
|
|
|
|
}
|
2017-07-13 17:25:38 -07:00
|
|
|
ValidationFailure(ref err) => {
|
|
|
|
write!(f, "type validation failed: {}", err)
|
|
|
|
}
|
2017-07-03 16:06:06 -07:00
|
|
|
NoMirFor(ref func) => write!(f, "no mir for `{}`", func),
|
|
|
|
FunctionPointerTyMismatch(sig, got) =>
|
2017-03-14 10:49:22 +01:00
|
|
|
write!(f, "tried to call a function with sig {} through a function pointer of type {}", sig, got),
|
2017-07-03 16:06:06 -07:00
|
|
|
ArrayIndexOutOfBounds(span, len, index) =>
|
2016-06-21 09:43:27 +02:00
|
|
|
write!(f, "index out of bounds: the len is {} but the index is {} at {:?}", len, index, span),
|
2017-07-28 16:48:43 +02:00
|
|
|
ReallocatedWrongMemoryKind(ref old, ref new) =>
|
|
|
|
write!(f, "tried to reallocate memory from {} to {}", old, new),
|
|
|
|
DeallocatedWrongMemoryKind(ref old, ref new) =>
|
|
|
|
write!(f, "tried to deallocate {} memory but gave {} as the kind", old, new),
|
2017-07-03 16:06:06 -07:00
|
|
|
Math(span, ref err) =>
|
2016-06-21 09:43:27 +02:00
|
|
|
write!(f, "{:?} at {:?}", err, span),
|
2017-07-03 16:06:06 -07:00
|
|
|
Intrinsic(ref err) =>
|
2017-06-22 00:08:19 -07:00
|
|
|
write!(f, "{}", err),
|
2017-07-03 16:06:06 -07:00
|
|
|
InvalidChar(c) =>
|
2016-06-21 09:43:27 +02:00
|
|
|
write!(f, "tried to interpret an invalid 32-bit value as a char: {}", c),
|
2017-07-03 16:06:06 -07:00
|
|
|
OutOfMemory { allocation_size, memory_size, memory_usage } =>
|
2016-07-05 10:47:10 +02:00
|
|
|
write!(f, "tried to allocate {} more bytes, but only {} bytes are free of the {} byte memory",
|
|
|
|
allocation_size, memory_size - memory_usage, memory_size),
|
2017-07-03 16:06:06 -07:00
|
|
|
AlignmentCheckFailed { required, has } =>
|
2016-07-05 14:27:27 +02:00
|
|
|
write!(f, "tried to access memory with alignment {}, but alignment {} is required",
|
|
|
|
has, required),
|
2017-07-03 16:06:06 -07:00
|
|
|
TypeNotPrimitive(ty) =>
|
2016-11-03 12:30:41 +01:00
|
|
|
write!(f, "expected primitive type, got {}", ty),
|
2017-07-03 16:06:06 -07:00
|
|
|
Layout(ref err) =>
|
2016-11-17 17:23:40 +01:00
|
|
|
write!(f, "rustc layout computation failed: {:?}", err),
|
2017-07-25 11:32:48 +02:00
|
|
|
PathNotFound(ref path) =>
|
2017-07-12 10:36:14 +02:00
|
|
|
write!(f, "Cannot find path {:?}", path),
|
2017-07-25 11:32:48 +02:00
|
|
|
MachineError(ref inner) =>
|
|
|
|
write!(f, "machine error: {}", inner),
|
2016-05-31 12:05:25 +02:00
|
|
|
_ => write!(f, "{}", self.description()),
|
|
|
|
}
|
2016-03-14 21:48:00 -06:00
|
|
|
}
|
|
|
|
}
|