3 use rustc::mir::repr as mir;
5 #[derive(Clone, Debug)]
19 InvalidBoolOp(mir::BinOp),
20 Unimplemented(String),
23 pub type EvalResult<T> = Result<T, EvalError>;
25 impl Error for EvalError {
26 fn description(&self) -> &str {
28 EvalError::DanglingPointerDeref =>
29 "dangling pointer was dereferenced",
30 EvalError::InvalidBool =>
31 "invalid boolean value read",
32 EvalError::InvalidDiscriminant =>
33 "invalid enum discriminant value read",
34 EvalError::PointerOutOfBounds { .. } =>
35 "pointer offset outside bounds of allocation",
36 EvalError::ReadPointerAsBytes =>
37 "a raw memory access tried to access part of a pointer value as raw bytes",
38 EvalError::ReadBytesAsPointer =>
39 "attempted to interpret some raw bytes as a pointer address",
40 EvalError::InvalidPointerMath =>
41 "attempted to do math or a comparison on pointers into different allocations",
42 EvalError::ReadUndefBytes =>
43 "attempted to read undefined bytes",
44 EvalError::InvalidBoolOp(_) =>
45 "invalid boolean operation",
46 EvalError::Unimplemented(ref msg) => msg,
50 fn cause(&self) -> Option<&Error> { None }
53 impl fmt::Display for EvalError {
54 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
56 EvalError::PointerOutOfBounds { offset, size, len } => write!(f, "pointer offset ({} + {}) outside bounds ({}) of allocation", offset, size, len),
57 _ => write!(f, "{}", self.description()),