Skip to content

Commit aafec28

Browse files
committed
Deprecate float_cmp_const
1 parent 38c11ed commit aafec28

File tree

6 files changed

+23
-38
lines changed

6 files changed

+23
-38
lines changed

clippy_lints/src/declared_lints.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -566,7 +566,6 @@ pub(crate) static LINTS: &[&crate::LintInfo] = &[
566566
crate::operators::ERASING_OP_INFO,
567567
crate::operators::FLOAT_ARITHMETIC_INFO,
568568
crate::operators::FLOAT_CMP_INFO,
569-
crate::operators::FLOAT_CMP_CONST_INFO,
570569
crate::operators::FLOAT_EQUALITY_WITHOUT_ABS_INFO,
571570
crate::operators::IDENTITY_OP_INFO,
572571
crate::operators::IMPOSSIBLE_COMPARISONS_INFO,

clippy_lints/src/deprecated_lints.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,3 +241,14 @@ declare_deprecated_lint! {
241241
pub MISMATCHED_TARGET_OS,
242242
"this lint has been replaced by `unexpected_cfgs`"
243243
}
244+
245+
declare_deprecated_lint! {
246+
/// ### What it does
247+
/// Nothing. This lint has been deprecated.
248+
///
249+
/// ### Deprecation reason
250+
/// `float_cmp` handles this via config options
251+
#[clippy::version = "1.76.0"]
252+
pub FLOAT_CMP_CONST,
253+
"`float_cmp` handles this via config options"
254+
}

clippy_lints/src/lib.deprecated.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,4 +75,8 @@
7575
"clippy::mismatched_target_os",
7676
"this lint has been replaced by `unexpected_cfgs`",
7777
);
78+
store.register_removed(
79+
"clippy::float_cmp_const",
80+
"`float_cmp` handles this via config options",
81+
);
7882
}

clippy_lints/src/operators/mod.rs

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -590,41 +590,6 @@ declare_clippy_lint! {
590590
"using `==` or `!=` on float values instead of comparing difference with an epsilon"
591591
}
592592

593-
declare_clippy_lint! {
594-
/// ### What it does
595-
/// Checks for (in-)equality comparisons on floating-point
596-
/// value and constant, except in functions called `*eq*` (which probably
597-
/// implement equality for a type involving floats).
598-
///
599-
/// ### Why restrict this?
600-
/// Floating point calculations are usually imprecise, so
601-
/// asking if two values are *exactly* equal is asking for trouble. For a good
602-
/// guide on what to do, see [the floating point
603-
/// guide](http://www.floating-point-gui.de/errors/comparison).
604-
///
605-
/// ### Example
606-
/// ```no_run
607-
/// let x: f64 = 1.0;
608-
/// const ONE: f64 = 1.00;
609-
///
610-
/// if x == ONE { } // where both are floats
611-
/// ```
612-
///
613-
/// Use instead:
614-
/// ```no_run
615-
/// # let x: f64 = 1.0;
616-
/// # const ONE: f64 = 1.00;
617-
/// let error_margin = f64::EPSILON; // Use an epsilon for comparison
618-
/// // Or, if Rust <= 1.42, use `std::f64::EPSILON` constant instead.
619-
/// // let error_margin = std::f64::EPSILON;
620-
/// if (x - ONE).abs() < error_margin { }
621-
/// ```
622-
#[clippy::version = "pre 1.29.0"]
623-
pub FLOAT_CMP_CONST,
624-
restriction,
625-
"using `==` or `!=` on float constants instead of comparing difference with an epsilon"
626-
}
627-
628593
declare_clippy_lint! {
629594
/// ### What it does
630595
/// Checks for getting the remainder of a division by one or minus
@@ -801,7 +766,6 @@ impl_lint_pass!(Operators => [
801766
INTEGER_DIVISION,
802767
CMP_OWNED,
803768
FLOAT_CMP,
804-
FLOAT_CMP_CONST,
805769
MODULO_ONE,
806770
MODULO_ARITHMETIC,
807771
NEEDLESS_BITWISE_BOOL,

tests/ui/deprecated.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,6 @@
2020
#![warn(clippy::wrong_pub_self_convention)]
2121
#![warn(clippy::maybe_misused_cfg)]
2222
#![warn(clippy::mismatched_target_os)]
23+
#![warn(clippy::float_cmp_const)]
2324

2425
fn main() {}

tests/ui/deprecated.stderr

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,5 +109,11 @@ error: lint `clippy::mismatched_target_os` has been removed: this lint has been
109109
LL | #![warn(clippy::mismatched_target_os)]
110110
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
111111

112-
error: aborting due to 18 previous errors
112+
error: lint `clippy::float_cmp_const` has been removed: `float_cmp` handles this via config options
113+
--> tests/ui/deprecated.rs:23:9
114+
|
115+
LL | #![warn(clippy::float_cmp_const)]
116+
| ^^^^^^^^^^^^^^^^^^^^^^^
117+
118+
error: aborting due to 19 previous errors
113119

0 commit comments

Comments
 (0)