remove the bad rhs value error and panic instead. the typechecker prevent this

This commit is contained in:
Oliver Schneider 2016-06-20 17:52:36 +02:00
parent a088f105aa
commit 001ae69212
No known key found for this signature in database
GPG Key ID: 56D6EEA0FC67AC46
2 changed files with 1 additions and 5 deletions

View File

@ -5,7 +5,6 @@
use memory::Pointer;
use rustc_const_math::ConstMathErr;
use syntax::codemap::Span;
use primval::PrimVal;
#[derive(Clone, Debug)]
pub enum EvalError<'tcx> {
@ -29,7 +28,6 @@ pub enum EvalError<'tcx> {
ExecuteMemory,
ArrayIndexOutOfBounds(Span, u64, u64),
Math(Span, ConstMathErr),
InvalidBitShiftRhs(PrimVal),
}
pub type EvalResult<'tcx, T> = Result<T, EvalError<'tcx>>;
@ -68,8 +66,6 @@ fn description(&self) -> &str {
"array index out of bounds",
EvalError::Math(..) =>
"mathematical operation failed",
EvalError::InvalidBitShiftRhs(..) =>
"bit shift rhs not an int",
}
}

View File

@ -91,7 +91,7 @@ fn unrelated_ptr_ops<'tcx>(bin_op: mir::BinOp) -> EvalResult<'tcx, PrimVal> {
U16(i) => (i & ((1 << mask_bits) - 1)) as u32,
U32(i) => (i & ((1 << mask_bits) - 1)) as u32,
U64(i) => (i & ((1 << mask_bits) - 1)) as u32,
_ => return Err(EvalError::InvalidBitShiftRhs(right)),
_ => panic!("bad MIR: bitshift rhs is not integral"),
};
macro_rules! shift {
($v:ident, $l:ident, $r:ident) => ({