]> git.lizzy.rs Git - rust.git/blob - tests/ui/cmp_nan.rs
Auto merge of #4910 - krishna-veerareddy:issue-1205-cmp-nan-against-consts, r=phansch
[rust.git] / tests / ui / cmp_nan.rs
1 const NAN_F32: f32 = std::f32::NAN;
2 const NAN_F64: f64 = std::f64::NAN;
3
4 #[warn(clippy::cmp_nan)]
5 #[allow(clippy::float_cmp, clippy::no_effect, clippy::unnecessary_operation)]
6 fn main() {
7     let x = 5f32;
8     x == std::f32::NAN;
9     x != std::f32::NAN;
10     x < std::f32::NAN;
11     x > std::f32::NAN;
12     x <= std::f32::NAN;
13     x >= std::f32::NAN;
14     x == NAN_F32;
15     x != NAN_F32;
16     x < NAN_F32;
17     x > NAN_F32;
18     x <= NAN_F32;
19     x >= NAN_F32;
20
21     let y = 0f64;
22     y == std::f64::NAN;
23     y != std::f64::NAN;
24     y < std::f64::NAN;
25     y > std::f64::NAN;
26     y <= std::f64::NAN;
27     y >= std::f64::NAN;
28     y == NAN_F64;
29     y != NAN_F64;
30     y < NAN_F64;
31     y > NAN_F64;
32     y <= NAN_F64;
33     y >= NAN_F64;
34 }