//! lint on if branches that could be swapped so no `!` operation is necessary
//! on the condition
-use rustc::declare_lint_pass;
-use rustc::lint::{in_external_macro, EarlyContext, EarlyLintPass, LintArray, LintContext, LintPass};
-use rustc_session::declare_tool_lint;
-use syntax::ast::*;
+use rustc_ast::ast::{BinOpKind, Expr, ExprKind, UnOp};
+use rustc_lint::{EarlyContext, EarlyLintPass, LintContext};
+use rustc_middle::lint::in_external_macro;
+use rustc_session::{declare_lint_pass, declare_tool_lint};
-use crate::utils::span_help_and_lint;
+use crate::utils::span_lint_and_help;
declare_clippy_lint! {
/// **What it does:** Checks for usage of `!` or `!=` in an if condition with an
if let ExprKind::Block(..) = els.kind {
match cond.kind {
ExprKind::Unary(UnOp::Not, _) => {
- span_help_and_lint(
+ span_lint_and_help(
cx,
IF_NOT_ELSE,
item.span,
- "Unnecessary boolean `not` operation",
- "remove the `!` and swap the blocks of the if/else",
+ "unnecessary boolean `not` operation",
+ None,
+ "remove the `!` and swap the blocks of the `if`/`else`",
);
},
ExprKind::Binary(ref kind, _, _) if kind.node == BinOpKind::Ne => {
- span_help_and_lint(
+ span_lint_and_help(
cx,
IF_NOT_ELSE,
item.span,
- "Unnecessary `!=` operation",
- "change to `==` and swap the blocks of the if/else",
+ "unnecessary `!=` operation",
+ None,
+ "change to `==` and swap the blocks of the `if`/`else`",
);
},
_ => (),