Closed
Description
Code
fn main() {
const TEST: bool = 5f32 == f32::NAN;
}
Current output
warning: constant `TEST` is never used
--> src/main.rs:2:11
|
2 | const TEST: bool = 5f32 == f32::NAN;
| ^^^^
|
= note: `#[warn(dead_code)]` on by default
warning: incorrect NaN comparison, NaN cannot be directly compared to itself
--> src/main.rs:2:24
|
2 | const TEST: bool = 5f32 == f32::NAN;
| ^^^^^^^^^^^^^^^^
|
= note: `#[warn(invalid_nan_comparisons)]` on by default
help: use `f32::is_nan()` or `f64::is_nan()` instead
|
2 - const TEST: bool = 5f32 == f32::NAN;
2 + const TEST: bool = 5f32.is_nan();
|
warning: 2 warnings emitted
Desired output
No response
Rationale and extra context
The suggestion is auto applicable
fn main() {
const TEST: bool = 5f32.is_nan();
}
but does not compiled because it relies on unstabilized features
error: `core::f32::<impl f32>::is_nan` is not yet stable as a const fn
--> src/main.rs:2:24
|
2 | const TEST: bool = 5f32.is_nan();
| ^^^^^^^^^^^^^
|
= help: add `#![feature(const_float_classify)]` to the crate attributes to enable
error: aborting due to previous error
Other cases
No response
Anything else?
rustc 1.73.0-nightly (474709a 2023-08-03)
binary: rustc
commit-hash: 474709a
commit-date: 2023-08-03
host: x86_64-unknown-linux-gnu
release: 1.73.0-nightly
LLVM version: 16.0.5