Skip to content

Commit 0aa6e03

Browse files
committed
Remove the UnequalTypes error variant
1 parent 7d982fd commit 0aa6e03

File tree

3 files changed

+4
-19
lines changed

3 files changed

+4
-19
lines changed

src/librustc/ich/impls_const_math.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ impl_stable_hash_for!(struct ::rustc_const_math::ConstFloat {
1717
});
1818

1919
impl_stable_hash_for!(enum ::rustc_const_math::ConstMathErr {
20-
UnequalTypes(op),
2120
Overflow(op),
2221
DivisionByZero,
2322
RemainderByZero,

src/librustc_const_math/err.rs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
#[derive(Debug, PartialEq, Eq, Clone, RustcEncodable, RustcDecodable)]
1212
pub enum ConstMathErr {
13-
UnequalTypes(Op),
1413
Overflow(Op),
1514
DivisionByZero,
1615
RemainderByZero,
@@ -36,17 +35,6 @@ impl ConstMathErr {
3635
pub fn description(&self) -> &'static str {
3736
use self::Op::*;
3837
match *self {
39-
UnequalTypes(Add) => "tried to add two values of different types",
40-
UnequalTypes(Sub) => "tried to subtract two values of different types",
41-
UnequalTypes(Mul) => "tried to multiply two values of different types",
42-
UnequalTypes(Div) => "tried to divide two values of different types",
43-
UnequalTypes(Rem) => {
44-
"tried to calculate the remainder of two values of different types"
45-
},
46-
UnequalTypes(BitAnd) => "tried to bitand two values of different types",
47-
UnequalTypes(BitOr) => "tried to bitor two values of different types",
48-
UnequalTypes(BitXor) => "tried to xor two values of different types",
49-
UnequalTypes(_) => unreachable!(),
5038
Overflow(Add) => "attempt to add with overflow",
5139
Overflow(Sub) => "attempt to subtract with overflow",
5240
Overflow(Mul) => "attempt to multiply with overflow",

src/librustc_const_math/float.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ use syntax::ast;
1616
use rustc_apfloat::{Float, FloatConvert, Status};
1717
use rustc_apfloat::ieee::{Single, Double};
1818

19-
use super::err::*;
20-
2119
// Note that equality for `ConstFloat` means that the it is the same
2220
// constant, not that the rust values are equal. In particular, `NaN
2321
// == NaN` (at least if it's the same NaN; distinct encodings for NaN
@@ -172,8 +170,8 @@ impl ::std::fmt::Debug for ConstFloat {
172170
macro_rules! derive_binop {
173171
($op:ident, $func:ident) => {
174172
impl ::std::ops::$op for ConstFloat {
175-
type Output = Result<Self, ConstMathErr>;
176-
fn $func(self, rhs: Self) -> Result<Self, ConstMathErr> {
173+
type Output = Option<Self>;
174+
fn $func(self, rhs: Self) -> Option<Self> {
177175
let bits = match (self.ty, rhs.ty) {
178176
(ast::FloatTy::F32, ast::FloatTy::F32) =>{
179177
let a = Single::from_bits(self.bits);
@@ -185,9 +183,9 @@ macro_rules! derive_binop {
185183
let b = Double::from_bits(rhs.bits);
186184
a.$func(b).value.to_bits()
187185
}
188-
_ => return Err(UnequalTypes(Op::$op)),
186+
_ => return None,
189187
};
190-
Ok(ConstFloat { bits, ty: self.ty })
188+
Some(ConstFloat { bits, ty: self.ty })
191189
}
192190
}
193191
}

0 commit comments

Comments
 (0)