diff --git a/src/librustc/ich/impls_const_math.rs b/src/librustc/ich/impls_const_math.rs index 387a6d5f35c..494fa49b53d 100644 --- a/src/librustc/ich/impls_const_math.rs +++ b/src/librustc/ich/impls_const_math.rs @@ -17,7 +17,6 @@ impl_stable_hash_for!(struct ::rustc_const_math::ConstFloat { }); impl_stable_hash_for!(enum ::rustc_const_math::ConstMathErr { - UnequalTypes(op), Overflow(op), DivisionByZero, RemainderByZero, diff --git a/src/librustc_const_math/err.rs b/src/librustc_const_math/err.rs index 5d442ee7b97..94a51c23a5e 100644 --- a/src/librustc_const_math/err.rs +++ b/src/librustc_const_math/err.rs @@ -10,7 +10,6 @@ #[derive(Debug, PartialEq, Eq, Clone, RustcEncodable, RustcDecodable)] pub enum ConstMathErr { - UnequalTypes(Op), Overflow(Op), DivisionByZero, RemainderByZero, @@ -36,17 +35,6 @@ impl ConstMathErr { pub fn description(&self) -> &'static str { use self::Op::*; match *self { - UnequalTypes(Add) => "tried to add two values of different types", - UnequalTypes(Sub) => "tried to subtract two values of different types", - UnequalTypes(Mul) => "tried to multiply two values of different types", - UnequalTypes(Div) => "tried to divide two values of different types", - UnequalTypes(Rem) => { - "tried to calculate the remainder of two values of different types" - }, - UnequalTypes(BitAnd) => "tried to bitand two values of different types", - UnequalTypes(BitOr) => "tried to bitor two values of different types", - UnequalTypes(BitXor) => "tried to xor two values of different types", - UnequalTypes(_) => unreachable!(), Overflow(Add) => "attempt to add with overflow", Overflow(Sub) => "attempt to subtract with overflow", Overflow(Mul) => "attempt to multiply with overflow", diff --git a/src/librustc_const_math/float.rs b/src/librustc_const_math/float.rs index 61e9b34f06a..35cfe466c8a 100644 --- a/src/librustc_const_math/float.rs +++ b/src/librustc_const_math/float.rs @@ -16,8 +16,6 @@ use syntax::ast; use rustc_apfloat::{Float, FloatConvert, Status}; use rustc_apfloat::ieee::{Single, Double}; -use super::err::*; - // Note that equality for `ConstFloat` means that the it is the same // constant, not that the rust values are equal. In particular, `NaN // == NaN` (at least if it's the same NaN; distinct encodings for NaN @@ -172,8 +170,8 @@ impl ::std::fmt::Debug for ConstFloat { macro_rules! derive_binop { ($op:ident, $func:ident) => { impl ::std::ops::$op for ConstFloat { - type Output = Result; - fn $func(self, rhs: Self) -> Result { + type Output = Option; + fn $func(self, rhs: Self) -> Option { let bits = match (self.ty, rhs.ty) { (ast::FloatTy::F32, ast::FloatTy::F32) =>{ let a = Single::from_bits(self.bits); @@ -185,9 +183,9 @@ macro_rules! derive_binop { let b = Double::from_bits(rhs.bits); a.$func(b).value.to_bits() } - _ => return Err(UnequalTypes(Op::$op)), + _ => return None, }; - Ok(ConstFloat { bits, ty: self.ty }) + Some(ConstFloat { bits, ty: self.ty }) } } }