2023-05-20 16:05:09 -05:00
|
|
|
//@ check-pass
|
|
|
|
//@ run-rustfix
|
|
|
|
|
2024-10-31 21:24:31 -05:00
|
|
|
#![feature(f16, f128)]
|
|
|
|
|
2023-05-20 16:05:09 -05:00
|
|
|
fn main() {
|
2024-10-31 21:24:31 -05:00
|
|
|
let x = 5f16;
|
|
|
|
let _ = x == f16::NAN;
|
|
|
|
//~^ WARN incorrect NaN comparison
|
|
|
|
let _ = x != f16::NAN;
|
|
|
|
//~^ WARN incorrect NaN comparison
|
|
|
|
|
2023-05-20 16:05:09 -05:00
|
|
|
let x = 5f32;
|
|
|
|
let _ = x == f32::NAN;
|
|
|
|
//~^ WARN incorrect NaN comparison
|
|
|
|
let _ = x != f32::NAN;
|
|
|
|
//~^ WARN incorrect NaN comparison
|
|
|
|
|
|
|
|
let x = 5f64;
|
|
|
|
let _ = x == f64::NAN;
|
|
|
|
//~^ WARN incorrect NaN comparison
|
|
|
|
let _ = x != f64::NAN;
|
|
|
|
//~^ WARN incorrect NaN comparison
|
|
|
|
|
2024-10-31 21:24:31 -05:00
|
|
|
let x = 5f128;
|
|
|
|
let _ = x == f128::NAN;
|
|
|
|
//~^ WARN incorrect NaN comparison
|
|
|
|
let _ = x != f128::NAN;
|
|
|
|
//~^ WARN incorrect NaN comparison
|
|
|
|
|
2023-05-20 16:05:09 -05:00
|
|
|
let b = &2.3f32;
|
|
|
|
if b != &f32::NAN {}
|
|
|
|
//~^ WARN incorrect NaN comparison
|
|
|
|
|
|
|
|
let b = &2.3f32;
|
|
|
|
if b != { &f32::NAN } {}
|
|
|
|
//~^ WARN incorrect NaN comparison
|
|
|
|
|
|
|
|
let _ =
|
|
|
|
b != {
|
|
|
|
//~^ WARN incorrect NaN comparison
|
|
|
|
&f32::NAN
|
|
|
|
};
|
|
|
|
|
|
|
|
#[allow(unused_macros)]
|
|
|
|
macro_rules! nan { () => { f32::NAN }; }
|
|
|
|
macro_rules! number { () => { 5f32 }; }
|
|
|
|
|
|
|
|
let _ = nan!() == number!();
|
|
|
|
//~^ WARN incorrect NaN comparison
|
|
|
|
let _ = number!() != nan!();
|
|
|
|
//~^ WARN incorrect NaN comparison
|
|
|
|
}
|