remove the bad rhs value error and panic instead. the typechecker prevent this
This commit is contained in:
parent
a088f105aa
commit
001ae69212
@ -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",
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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) => ({
|
||||
|
Loading…
Reference in New Issue
Block a user