3afbe4f9c7
Currently `f32_nan` and `f64_nan` are used to provide the `invalid_nan_comparison` lint. Since we have `f16_nan` and `f128_nan`, hook these up so the new float types get the same lints.
51 lines
1.1 KiB
Rust
51 lines
1.1 KiB
Rust
//@ check-pass
|
|
//@ run-rustfix
|
|
|
|
#![feature(f16, f128)]
|
|
|
|
fn main() {
|
|
let x = 5f16;
|
|
let _ = x.is_nan();
|
|
//~^ WARN incorrect NaN comparison
|
|
let _ = !x.is_nan();
|
|
//~^ WARN incorrect NaN comparison
|
|
|
|
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 x = 5f128;
|
|
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
|
|
}
|