Fix badly mangled lint message for neg-cmp-op-on-partial-ord

This commit is contained in:
Georg Brandl 2018-06-29 16:55:26 +02:00
parent b4b6e6558e
commit 949f0d9c72
4 changed files with 15 additions and 15 deletions

View file

@ -4,20 +4,20 @@ use rustc::lint::*;
use crate::utils::{self, paths, span_lint, in_external_macro};
/// **What it does:**
/// Checks for the usage of negated comparision operators on types which only implement
/// Checks for the usage of negated comparison operators on types which only implement
/// `PartialOrd` (e.g. `f64`).
///
/// **Why is this bad?**
/// These operators make it easy to forget that the underlying types actually allow not only three
/// potential Orderings (Less, Equal, Greater) but also a forth one (Uncomparable). Escpeccially if
/// the operator based comparision result is negated it is easy to miss that fact.
/// potential Orderings (Less, Equal, Greater) but also a forth one (Uncomparable). This is
/// especially easy to miss if the operator based comparison result is negated.
///
/// **Known problems:** None.
///
/// **Example:**
///
/// ```rust
/// use core::cmp::Ordering;
/// use std::cmp::Ordering;
///
/// // Bad
/// let a = 1.0;
@ -37,7 +37,7 @@ use crate::utils::{self, paths, span_lint, in_external_macro};
declare_clippy_lint! {
pub NEG_CMP_OP_ON_PARTIAL_ORD,
complexity,
"The use of negated comparision operators on partially orded types may produce confusing code."
"The use of negated comparison operators on partially ordered types may produce confusing code."
}
pub struct NoNegCompOpForPartialOrd;
@ -83,10 +83,10 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NoNegCompOpForPartialOrd {
cx,
NEG_CMP_OP_ON_PARTIAL_ORD,
expr.span,
"The use of negated comparision operators on partially orded \
"The use of negated comparison operators on partially ordered \
types produces code that is hard to read and refactor. Please \
consider to use the `partial_cmp` instead, to make it clear \
that the two values could be incomparable."
consider using the `partial_cmp` method instead, to make it \
clear that the two values could be incomparable."
)
}
}

View file

@ -116,7 +116,7 @@ fn warn_for_built_in_methods_with_negation() {
}
#[allow(neg_cmp_op_on_partial_ord)]
fn dont_warn_for_negated_partial_ord_comparision() {
fn dont_warn_for_negated_partial_ord_comparison() {
let a: f64 = unimplemented!();
let b: f64 = unimplemented!();
let _ = !(a < b);

View file

@ -59,9 +59,9 @@ fn main() {
// Issue 2856: False positive on assert!()
//
// The macro always negates the result of the given comparision in its
// The macro always negates the result of the given comparison in its
// internal check which automatically triggered the lint. As it's an
// external macro there was no chance to do anything about it which lead
// external macro there was no chance to do anything about it which led
// to a whitelisting of all external macros.
assert!(a_value < another_value);
}

View file

@ -1,4 +1,4 @@
error: The use of negated comparision operators on partially orded types produces code that is hard to read and refactor. Please consider to use the `partial_cmp` instead, to make it clear that the two values could be incomparable.
error: The use of negated comparison operators on partially ordered types produces code that is hard to read and refactor. Please consider using the `partial_cmp` method instead, to make it clear that the two values could be incomparable.
--> $DIR/neg_cmp_op_on_partial_ord.rs:17:21
|
17 | let _not_less = !(a_value < another_value);
@ -6,19 +6,19 @@ error: The use of negated comparision operators on partially orded types produce
|
= note: `-D neg-cmp-op-on-partial-ord` implied by `-D warnings`
error: The use of negated comparision operators on partially orded types produces code that is hard to read and refactor. Please consider to use the `partial_cmp` instead, to make it clear that the two values could be incomparable.
error: The use of negated comparison operators on partially ordered types produces code that is hard to read and refactor. Please consider using the `partial_cmp` method instead, to make it clear that the two values could be incomparable.
--> $DIR/neg_cmp_op_on_partial_ord.rs:20:30
|
20 | let _not_less_or_equal = !(a_value <= another_value);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: The use of negated comparision operators on partially orded types produces code that is hard to read and refactor. Please consider to use the `partial_cmp` instead, to make it clear that the two values could be incomparable.
error: The use of negated comparison operators on partially ordered types produces code that is hard to read and refactor. Please consider using the `partial_cmp` method instead, to make it clear that the two values could be incomparable.
--> $DIR/neg_cmp_op_on_partial_ord.rs:23:24
|
23 | let _not_greater = !(a_value > another_value);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
error: The use of negated comparision operators on partially orded types produces code that is hard to read and refactor. Please consider to use the `partial_cmp` instead, to make it clear that the two values could be incomparable.
error: The use of negated comparison operators on partially ordered types produces code that is hard to read and refactor. Please consider using the `partial_cmp` method instead, to make it clear that the two values could be incomparable.
--> $DIR/neg_cmp_op_on_partial_ord.rs:26:33
|
26 | let _not_greater_or_equal = !(a_value >= another_value);