rust-clippy/tests/compile-fail/cmp_nan.rs
2015-11-09 08:49:20 +05:30

22 lines
848 B
Rust

#![feature(plugin)]
#![plugin(clippy)]
#[deny(cmp_nan)]
#[allow(float_cmp)]
fn main() {
let x = 5f32;
x == std::f32::NAN; //~ERROR doomed comparison with NAN
x != std::f32::NAN; //~ERROR doomed comparison with NAN
x < std::f32::NAN; //~ERROR doomed comparison with NAN
x > std::f32::NAN; //~ERROR doomed comparison with NAN
x <= std::f32::NAN; //~ERROR doomed comparison with NAN
x >= std::f32::NAN; //~ERROR doomed comparison with NAN
let y = 0f64;
y == std::f64::NAN; //~ERROR doomed comparison with NAN
y != std::f64::NAN; //~ERROR doomed comparison with NAN
y < std::f64::NAN; //~ERROR doomed comparison with NAN
y > std::f64::NAN; //~ERROR doomed comparison with NAN
y <= std::f64::NAN; //~ERROR doomed comparison with NAN
y >= std::f64::NAN; //~ERROR doomed comparison with NAN
}