use rustc::hir::*;
use rustc::lint::*;
-use crate::utils::{self, paths};
+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
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
if_chain! {
+ if !in_external_macro(cx, expr.span);
if let Expr_::ExprUnary(UnOp::UnNot, ref inner) = expr.node;
if let Expr_::ExprBinary(ref op, ref left, _) = inner.node;
if let BinOp_::BiLe | BinOp_::BiGe | BinOp_::BiLt | BinOp_::BiGt = op.node;
};
if implements_partial_ord && !implements_ord {
- cx.span_lint(
+ span_lint(
+ cx,
NEG_CMP_OP_ON_PARTIAL_ORD,
expr.span,
"The use of negated comparision operators on partially orded \
-/// This test case utilizes `f64` an easy example for `PartialOrd` only types
-/// but the lint itself actually validates any expression where the left
-/// operand implements `PartialOrd` but not `Ord`.
+//! This test case utilizes `f64` an easy example for `PartialOrd` only types
+//! but the lint itself actually validates any expression where the left
+//! operand implements `PartialOrd` but not `Ord`.
use std::cmp::Ordering;
let _ = a_value <= another_value;
let _ = a_value > another_value;
let _ = a_value >= another_value;
-}
+ // --- regression tests ---
+
+ // Issue 2856: False positive on assert!()
+ //
+ // The macro always negates the result of the given comparision 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
+ // to a whitelisting of all external macros.
+ assert!(a_value < another_value);
+}