Make epsilon note spanless when comparing arrays

This commit is contained in:
Marcin Serwin 2020-04-06 08:56:22 +02:00
parent c7b5e30423
commit 84ae3d8bc8
3 changed files with 5 additions and 11 deletions

View File

@ -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");

View File

@ -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

View File

@ -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