Commit graph

25 commits

Author SHA1 Message Date
Sander Saares
a067cd24ac Replace incorrect suggested fix for float_cmp
Using `f32::EPSILON` or `f64::EPSILON` as the floating-point equality comparison error margin is incorrect, yet `float_cmp` has until now recommended this be done. This change fixes the given guidance (both in docs and compiler hints) to not reference these unsuitable constants.

Instead, the guidance now clarifies that the scenarios in which an absolute error margin is usable, provides a reference implementation of using a user-defined absolute error margin (as an absolute error margin can only be used-defined and may be different for different comparisons) and references the floating point guide for a reference implementation of relative error based equaltiy comparison for when absolute error margin cannot be used.

changelog: Fix guidance of [`float_cmp`] and [`float_cmp_const`] to not incorrectly recommend `f64::EPSILON` as the error margin.

Fixes #6816
2024-07-09 10:12:09 +03:00
Trevor Gross
c693f31ee2 Update float tests to include f16 and f128 2024-06-19 13:30:21 -04:00
Philipp Krones
471469d30f Merge commit '98363cbf6a7c3f8b571a7d92a3c645bb4376e4a6' into clippyup 2023-09-12 18:44:06 +02:00
Philipp Krones
cc61aeea54 Merge commit '080b587854a73f2a8cbaecff1884860a78e2ff37' into clippyup 2023-08-24 21:32:12 +02:00
flip1995
23d5457e6d Merge commit 'cb7915b00c235e9b5861564f3be78dba330980ee' into clippyup 2021-09-28 18:03:12 +01:00
flip1995
f2f2a005b4 Merge commit '6ed6f1e6a1a8f414ba7e6d9b8222e7e5a1686e42' into clippyup 2021-03-12 15:30:50 +01:00
Eduardo Broto
cdb555f4fc Merge commit 'bf1c6f9871f430e284b17aa44059e0d0395e28a6' into clippyup 2020-10-23 22:16:59 +02:00
Marcin Serwin
3c738b2286 Add float cmp tests for arrays 2020-04-09 08:08:36 +02:00
briankabiro
0d00eafd32 Add tests for float in array comparison 2020-04-09 08:05:51 +02:00
Linus Färnstrand
b192f2cd15 Use primitive type assoc consts in more tests 2020-04-08 00:43:27 +02:00
xd009642
bba2c7f02c Updated tests.
Removed unnecessary type repetition in float test and regenerated stderr
Regenerated type_repetition stderr
2019-07-27 22:53:26 +01:00
Jerry Hardee
8adbf7f2c1 Fix float_cmp false positive when comparing signum
f1.signum() == f2.signum()
f1.signum() != f2.signum()
should not trigger a warning.
2019-07-15 12:46:58 -05:00
Philipp Hansch
38d4ac7cea
Remove all copyright license headers
Discussion previously happened in https://github.com/rust-lang/rust/pull/43498
2019-01-08 21:46:39 +01:00
Matthias Krüger
435299be30 rustfmt tests 2018-12-09 23:26:16 +01:00
Oliver Scherer
b8654eaa6c Stabilize tool lints 2018-10-11 12:16:22 +02:00
Manish Goregaokar
e9c025ea70 Add license header to Rust files 2018-10-06 09:43:08 -07:00
flip1995
1b6f6051a8 Adapt ui-tests to the tool_lints 2018-08-29 11:08:29 -07:00
Oliver Schneider
50ffaca4c9
Reduce the hackiness of cargo-clippy 2017-10-03 12:07:24 +02:00
Dan Gohman
1ea70116d3 Enable the cast_lossless warning by default. 2017-08-29 05:48:56 -07:00
Oliver Schneider
74c776585c Move all our tests back to ui tests 2017-08-01 17:54:21 +02:00
Oliver Schneider
4465bc3e3f Make most tests an example so we can run them one by one 2017-05-17 14:19:44 +02:00
Luis de Bethencourt
faca269488 clean tests/ui/float.rs
Cleaning the empty lines for clarity.
2017-05-11 16:22:32 +01:00
sinkuu
6bb426b0e3 Add should_assert_eq lint (fixes #641) 2017-02-18 10:13:56 +09:00
Oliver Schneider
1f2c97a291 remove all //~ from tests 2017-02-08 14:58:07 +01:00
Oliver Schneider
fd1351f6e3 rustup and compile-fail -> ui test move 2017-02-07 21:05:30 +01:00
Renamed from tests/compile-fail/float_cmp.rs (Browse further)