summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/tests/ui/cmp_nan.rs
blob: 64ca52b010a7eb5c5a38db9a3d285d706b2b3656 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
const NAN_F32: f32 = f32::NAN;
const NAN_F64: f64 = f64::NAN;

#[warn(clippy::cmp_nan)]
#[allow(clippy::float_cmp, clippy::no_effect, clippy::unnecessary_operation)]
fn main() {
    let x = 5f32;
    x == f32::NAN;
    x != f32::NAN;
    x < f32::NAN;
    x > f32::NAN;
    x <= f32::NAN;
    x >= f32::NAN;
    x == NAN_F32;
    x != NAN_F32;
    x < NAN_F32;
    x > NAN_F32;
    x <= NAN_F32;
    x >= NAN_F32;

    let y = 0f64;
    y == f64::NAN;
    y != f64::NAN;
    y < f64::NAN;
    y > f64::NAN;
    y <= f64::NAN;
    y >= f64::NAN;
    y == NAN_F64;
    y != NAN_F64;
    y < NAN_F64;
    y > NAN_F64;
    y <= NAN_F64;
    y >= NAN_F64;
}