Open
Description
Consider the following function:
fn nan_test() -> bool {
let v = std::f32::NAN;
v != v //warning: equal expressions as operands to `!=`
}
The eq_op
warning is wrong here since floats only implement PartialOrd
and doing v != v
allows me to detect them in a generic context:
fn max<T: PartialOrd>(v1: T, v2: T) -> T {
if v2 != v2 { v2 }
else if v2 > v1 { v2 } else { v1 }
}
Maybe a solution is to check whether the result of the expression returns something that implements Ord
or not?