summaryrefslogtreecommitdiffstats
path: root/tests/ui/lint/invalid-nan-comparison-suggestion.fixed
blob: feafc6c1b8c132843faf0ab3f403d3b689924329 (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
35
36
// check-pass
// run-rustfix

fn main() {
    let x = 5f32;
    let _ = x.is_nan();
    //~^ WARN incorrect NaN comparison
    let _ = !x.is_nan();
    //~^ WARN incorrect NaN comparison

    let x = 5f64;
    let _ = x.is_nan();
    //~^ WARN incorrect NaN comparison
    let _ = !x.is_nan();
    //~^ WARN incorrect NaN comparison

    let b = &2.3f32;
    if !b.is_nan() {}
    //~^ WARN incorrect NaN comparison

    let b = &2.3f32;
    if !b.is_nan() {}
    //~^ WARN incorrect NaN comparison

    let _ =
        !b.is_nan();

    #[allow(unused_macros)]
    macro_rules! nan { () => { f32::NAN }; }
    macro_rules! number { () => { 5f32 }; }

    let _ = number!().is_nan();
    //~^ WARN incorrect NaN comparison
    let _ = !number!().is_nan();
    //~^ WARN incorrect NaN comparison
}