Auto merge of #111818 - Urgau:uplift_cmp_nan, r=cjgillot
Uplift `clippy::cmp_nan` lint This PR aims at uplifting the `clippy::cmp_nan` lint into rustc. ## `invalid_nan_comparisons` ~~(deny-by-default)~~ (warn-by-default) The `invalid_nan_comparisons` lint checks comparison with `f32::NAN` or `f64::NAN` as one of the operand. ### Example ```rust,compile_fail let a = 2.3f32; if a == f32::NAN {} ``` ### Explanation NaN does not compare meaningfully to anything – not even itself – so those comparisons are always false. ----- Mostly followed the instructions for uplifting a clippy lint described here: https://github.com/rust-lang/rust/pull/99696#pullrequestreview-1134072751 `@rustbot` label: +I-lang-nominated r? compiler
This commit is contained in:
commit
788c98df59
25 changed files with 604 additions and 308 deletions
|
@ -403,6 +403,7 @@ impl f32 {
|
|||
/// and the stability of its representation over Rust versions
|
||||
/// and target platforms isn't guaranteed.
|
||||
#[stable(feature = "assoc_int_consts", since = "1.43.0")]
|
||||
#[rustc_diagnostic_item = "f32_nan"]
|
||||
pub const NAN: f32 = 0.0_f32 / 0.0_f32;
|
||||
/// Infinity (∞).
|
||||
#[stable(feature = "assoc_int_consts", since = "1.43.0")]
|
||||
|
|
|
@ -401,6 +401,7 @@ impl f64 {
|
|||
/// This constant isn't guaranteed to equal to any specific NaN bitpattern,
|
||||
/// and the stability of its representation over Rust versions
|
||||
/// and target platforms isn't guaranteed.
|
||||
#[rustc_diagnostic_item = "f64_nan"]
|
||||
#[stable(feature = "assoc_int_consts", since = "1.43.0")]
|
||||
pub const NAN: f64 = 0.0_f64 / 0.0_f64;
|
||||
/// Infinity (∞).
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue