From 24249530552be849d5e691f93e16c3c4e8bd7915 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Wed, 19 Jul 2017 11:35:06 -0700 Subject: [PATCH] Don't pretend that casts to bool are a thing --- src/cast.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/cast.rs b/src/cast.rs index cb0b11217098..0fa38366e1c0 100644 --- a/src/cast.rs +++ b/src/cast.rs @@ -46,9 +46,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> { fn cast_int(&self, v: u128, ty: ty::Ty<'tcx>, negative: bool) -> EvalResult<'tcx, PrimVal> { use rustc::ty::TypeVariants::*; match ty.sty { - TyBool if v == 0 => Ok(PrimVal::from_bool(false)), - TyBool if v == 1 => Ok(PrimVal::from_bool(true)), - TyBool => Err(EvalError::InvalidBool), + // Casts to bool are not permitted by rustc, no need to handle them here. TyInt(IntTy::I8) => Ok(PrimVal::Bytes(v as i128 as i8 as u128)), TyInt(IntTy::I16) => Ok(PrimVal::Bytes(v as i128 as i16 as u128)),