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;
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;
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."
)
}
}
}
#[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);
// 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);
}
-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);
|
= 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);