Skip to content

Commit 1a4ff1c

Browse files
committed
Deprecate float_cmp_const
1 parent be8a3ab commit 1a4ff1c

File tree

6 files changed

+23
-38
lines changed

6 files changed

+23
-38
lines changed

clippy_lints/src/declared_lints.rs

-1
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,6 @@ pub(crate) static LINTS: &[&crate::LintInfo] = &[
550550
crate::operators::ERASING_OP_INFO,
551551
crate::operators::FLOAT_ARITHMETIC_INFO,
552552
crate::operators::FLOAT_CMP_INFO,
553-
crate::operators::FLOAT_CMP_CONST_INFO,
554553
crate::operators::FLOAT_EQUALITY_WITHOUT_ABS_INFO,
555554
crate::operators::IDENTITY_OP_INFO,
556555
crate::operators::IMPOSSIBLE_COMPARISONS_INFO,

clippy_lints/src/deprecated_lints.rs

+11
Original file line numberDiff line numberDiff line change
@@ -215,3 +215,14 @@ declare_deprecated_lint! {
215215
pub WRONG_PUB_SELF_CONVENTION,
216216
"set the `avoid-breaking-exported-api` config option to `false` to enable the `wrong_self_convention` lint for public items"
217217
}
218+
219+
declare_deprecated_lint! {
220+
/// ### What it does
221+
/// Nothing. This lint has been deprecated.
222+
///
223+
/// ### Deprecation reason
224+
/// `float_cmp` handles this via config options
225+
#[clippy::version = "1.76.0"]
226+
pub FLOAT_CMP_CONST,
227+
"`float_cmp` handles this via config options"
228+
}

clippy_lints/src/lib.deprecated.rs

+4
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,8 @@
6767
"clippy::wrong_pub_self_convention",
6868
"set the `avoid-breaking-exported-api` config option to `false` to enable the `wrong_self_convention` lint for public items",
6969
);
70+
store.register_removed(
71+
"clippy::float_cmp_const",
72+
"`float_cmp` handles this via config options",
73+
);
7074
}

clippy_lints/src/operators/mod.rs

-36
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 is this bad?
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
@@ -802,7 +767,6 @@ impl_lint_pass!(Operators => [
802767
INTEGER_DIVISION,
803768
CMP_OWNED,
804769
FLOAT_CMP,
805-
FLOAT_CMP_CONST,
806770
MODULO_ONE,
807771
MODULO_ARITHMETIC,
808772
NEEDLESS_BITWISE_BOOL,

tests/ui/deprecated.rs

+1
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,6 @@
1818
#![warn(clippy::filter_map)]
1919
#![warn(clippy::pub_enum_variant_names)]
2020
#![warn(clippy::wrong_pub_self_convention)]
21+
#![warn(clippy::float_cmp_const)]
2122

2223
fn main() {}

tests/ui/deprecated.stderr

+7-1
Original file line numberDiff line numberDiff line change
@@ -97,5 +97,11 @@ error: lint `clippy::wrong_pub_self_convention` has been removed: set the `avoid
9797
LL | #![warn(clippy::wrong_pub_self_convention)]
9898
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
9999

100-
error: aborting due to 16 previous errors
100+
error: lint `clippy::float_cmp_const` has been removed: `float_cmp` handles this via config options
101+
--> $DIR/deprecated.rs:21:9
102+
|
103+
LL | #![warn(clippy::float_cmp_const)]
104+
| ^^^^^^^^^^^^^^^^^^^^^^^
105+
106+
error: aborting due to 17 previous errors
101107

0 commit comments

Comments
 (0)