about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMarcin Serwin <toxyxer@gmail.com>2020-04-06 08:56:22 +0200
committerMarcin Serwin <toxyxer@gmail.com>2020-04-09 08:10:14 +0200
commit84ae3d8bc85453601066bbebba3c372df763773f (patch)
tree9d0f0fa71587e72142d839f483dadd9201a4ac95
parentc7b5e30423169f7de0e1874c018f47ba4f63d79e (diff)
downloadrust-84ae3d8bc85453601066bbebba3c372df763773f.tar.gz
rust-84ae3d8bc85453601066bbebba3c372df763773f.zip
Make epsilon note spanless when comparing arrays
-rw-r--r--clippy_lints/src/misc.rs4
-rw-r--r--tests/ui/float_cmp.stderr6
-rw-r--r--tests/ui/float_cmp_const.stderr6
3 files changed, 5 insertions, 11 deletions
diff --git a/clippy_lints/src/misc.rs b/clippy_lints/src/misc.rs
index d9cef4851f5..491cebc96ab 100644
--- a/clippy_lints/src/misc.rs
+++ b/clippy_lints/src/misc.rs
@@ -389,8 +389,10 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MiscLints {
                                 ),
                                 Applicability::HasPlaceholders, // snippet
                             );
+                            db.span_note(expr.span, "`f32::EPSILON` and `f64::EPSILON` are available.");
+                        } else {
+                            db.note("`f32::EPSILON` and `f64::EPSILON` are available.");
                         }
-                        db.span_note(expr.span, "`f32::EPSILON` and `f64::EPSILON` are available.");
                     });
                 } else if op == BinOpKind::Rem && is_integer_const(cx, right, 1) {
                     span_lint(cx, MODULO_ONE, expr.span, "any number modulo 1 will be 0");
diff --git a/tests/ui/float_cmp.stderr b/tests/ui/float_cmp.stderr
index b0d8dd7c3f3..8952caa0676 100644
--- a/tests/ui/float_cmp.stderr
+++ b/tests/ui/float_cmp.stderr
@@ -53,11 +53,7 @@ error: strict comparison of `f32` or `f64`
 LL |     a1 == a2;
    |     ^^^^^^^^
    |
-note: `f32::EPSILON` and `f64::EPSILON` are available.
-  --> $DIR/float_cmp.rs:98:5
-   |
-LL |     a1 == a2;
-   |     ^^^^^^^^
+   = note: `f32::EPSILON` and `f64::EPSILON` are available.
 
 error: strict comparison of `f32` or `f64`
   --> $DIR/float_cmp.rs:99:5
diff --git a/tests/ui/float_cmp_const.stderr b/tests/ui/float_cmp_const.stderr
index da4b0b937a8..f93ee310785 100644
--- a/tests/ui/float_cmp_const.stderr
+++ b/tests/ui/float_cmp_const.stderr
@@ -89,11 +89,7 @@ error: strict comparison of `f32` or `f64` constant
 LL |     NON_ZERO_ARRAY == NON_ZERO_ARRAY2;
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
-note: `std::f32::EPSILON` and `std::f64::EPSILON` are available.
-  --> $DIR/float_cmp_const.rs:61:5
-   |
-LL |     NON_ZERO_ARRAY == NON_ZERO_ARRAY2;
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   = note: `std::f32::EPSILON` and `std::f64::EPSILON` are available.
 
 error: aborting due to 8 previous errors