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