//! 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::{declare_lint_pass, declare_tool_lint};
+use rustc_session::declare_tool_lint;
use syntax::ast::*;
use crate::utils::span_help_and_lint;
///
/// **Example:**
/// ```rust
+ /// # let v: Vec<usize> = vec![];
+ /// # fn a() {}
+ /// # fn b() {}
/// if !v.is_empty() {
/// a()
/// } else {
/// Could be written:
///
/// ```rust
+ /// # let v: Vec<usize> = vec![];
+ /// # fn a() {}
+ /// # fn b() {}
/// if v.is_empty() {
/// b()
/// } else {
if in_external_macro(cx.sess(), item.span) {
return;
}
- if let ExprKind::If(ref cond, _, Some(ref els)) = item.node {
- if let ExprKind::Block(..) = els.node {
- match cond.node {
+ if let ExprKind::If(ref cond, _, Some(ref els)) = item.kind {
+ if let ExprKind::Block(..) = els.kind {
+ match cond.kind {
ExprKind::Unary(UnOp::Not, _) => {
span_help_and_lint(
cx,