use if_chain::if_chain;
+use rustc::declare_lint_pass;
use rustc::hir::*;
use rustc::lint::{in_external_macro, LateContext, LateLintPass, LintArray, LintContext, LintPass};
-use rustc::{declare_tool_lint, lint_array};
+use rustc_session::declare_tool_lint;
use crate::utils::{self, paths, span_lint};
"The use of negated comparison operators on partially ordered types may produce confusing code."
}
-pub struct NoNegCompOpForPartialOrd;
-
-impl LintPass for NoNegCompOpForPartialOrd {
- fn get_lints(&self) -> LintArray {
- lint_array!(NEG_CMP_OP_ON_PARTIAL_ORD)
- }
-
- fn name(&self) -> &'static str {
- "NoNegCompOpForPartialOrd"
- }
-}
+declare_lint_pass!(NoNegCompOpForPartialOrd => [NEG_CMP_OP_ON_PARTIAL_ORD]);
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NoNegCompOpForPartialOrd {
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
if_chain! {
if !in_external_macro(cx.sess(), expr.span);
- if let ExprKind::Unary(UnOp::UnNot, ref inner) = expr.node;
- if let ExprKind::Binary(ref op, ref left, _) = inner.node;
+ if let ExprKind::Unary(UnOp::UnNot, ref inner) = expr.kind;
+ if let ExprKind::Binary(ref op, ref left, _) = inner.kind;
if let BinOpKind::Le | BinOpKind::Ge | BinOpKind::Lt | BinOpKind::Gt = op.node;
then {