From 949f0d9c72e901a001acd9c82bca6339be3b6b0e Mon Sep 17 00:00:00 2001 From: Georg Brandl Date: Fri, 29 Jun 2018 16:55:26 +0200 Subject: [PATCH] Fix badly mangled lint message for neg-cmp-op-on-partial-ord --- clippy_lints/src/neg_cmp_op_on_partial_ord.rs | 16 ++++++++-------- tests/ui/booleans.rs | 2 +- tests/ui/neg_cmp_op_on_partial_ord.rs | 4 ++-- tests/ui/neg_cmp_op_on_partial_ord.stderr | 8 ++++---- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/clippy_lints/src/neg_cmp_op_on_partial_ord.rs b/clippy_lints/src/neg_cmp_op_on_partial_ord.rs index 013bab69d79..cae88263111 100644 --- a/clippy_lints/src/neg_cmp_op_on_partial_ord.rs +++ b/clippy_lints/src/neg_cmp_op_on_partial_ord.rs @@ -4,20 +4,20 @@ 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 @@ 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 @@ fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) { 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." ) } } diff --git a/tests/ui/booleans.rs b/tests/ui/booleans.rs index 9daf15d378c..fc16c12af28 100644 --- a/tests/ui/booleans.rs +++ b/tests/ui/booleans.rs @@ -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); diff --git a/tests/ui/neg_cmp_op_on_partial_ord.rs b/tests/ui/neg_cmp_op_on_partial_ord.rs index 483972bb41b..e739908bc28 100644 --- a/tests/ui/neg_cmp_op_on_partial_ord.rs +++ b/tests/ui/neg_cmp_op_on_partial_ord.rs @@ -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); } diff --git a/tests/ui/neg_cmp_op_on_partial_ord.stderr b/tests/ui/neg_cmp_op_on_partial_ord.stderr index 5067ece8705..ccd30561100 100644 --- a/tests/ui/neg_cmp_op_on_partial_ord.stderr +++ b/tests/ui/neg_cmp_op_on_partial_ord.stderr @@ -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); -- 2.44.0