rust/tests/compile-fail/cmp_nan.rs
2016-02-11 13:50:41 +01:00

23 lines
859 B
Rust

#![feature(plugin)]
#![plugin(clippy)]
#[deny(cmp_nan)]
#[allow(float_cmp, no_effect)]
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
}