Also handle ConstFloat::F32 in is_allowed
This commit is contained in:
parent
7ba3a713a1
commit
0cf7990e72
@ -362,16 +362,28 @@ fn is_allowed(cx: &LateContext, expr: &Expr) -> bool {
|
||||
let res = ConstContext::with_tables(cx.tcx, cx.tables).eval(expr);
|
||||
if let Ok(ConstVal::Float(val)) = res {
|
||||
use std::cmp::Ordering;
|
||||
match val {
|
||||
val @ ConstFloat::F32(_) => {
|
||||
let zero = ConstFloat::F32(0.0);
|
||||
|
||||
let infinity = ConstFloat::F32(::std::f32::INFINITY);
|
||||
|
||||
let neg_infinity = ConstFloat::F32(::std::f32::NEG_INFINITY);
|
||||
|
||||
val.try_cmp(zero) == Ok(Ordering::Equal) || val.try_cmp(infinity) == Ok(Ordering::Equal) ||
|
||||
val.try_cmp(neg_infinity) == Ok(Ordering::Equal)
|
||||
},
|
||||
val @ ConstFloat::F64(_) => {
|
||||
let zero = ConstFloat::F64(0.0);
|
||||
|
||||
let infinity = ConstFloat::F64(::std::f64::INFINITY);
|
||||
|
||||
|
||||
let neg_infinity = ConstFloat::F64(::std::f64::NEG_INFINITY);
|
||||
|
||||
val.try_cmp(zero) == Ok(Ordering::Equal) || val.try_cmp(infinity) == Ok(Ordering::Equal) ||
|
||||
val.try_cmp(neg_infinity) == Ok(Ordering::Equal)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
false
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user