]> git.lizzy.rs Git - rust.git/blobdiff - clippy_lints/src/needless_bool.rs
ast/hir: Rename field-related structures
[rust.git] / clippy_lints / src / needless_bool.rs
index a799a644e970e1d3bce83435db28f6576bba5115..f283ff1715fb667df833c98cebc41039603d04ee 100644 (file)
@@ -3,10 +3,7 @@
 //! This lint is **warn** by default
 
 use crate::utils::sugg::Sugg;
-use crate::utils::{
-    higher, is_expn_of, parent_node_is_if_expr, snippet_with_applicability, span_lint, span_lint_and_sugg,
-};
-use if_chain::if_chain;
+use crate::utils::{is_expn_of, parent_node_is_if_expr, snippet_with_applicability, span_lint, span_lint_and_sugg};
 use rustc_ast::ast::LitKind;
 use rustc_errors::Applicability;
 use rustc_hir::{BinOpKind, Block, Expr, ExprKind, StmtKind, UnOp};
@@ -72,7 +69,7 @@
 impl<'tcx> LateLintPass<'tcx> for NeedlessBool {
     fn check_expr(&mut self, cx: &LateContext<'tcx>, e: &'tcx Expr<'_>) {
         use self::Expression::{Bool, RetBool};
-        if let Some((ref pred, ref then_block, Some(ref else_expr))) = higher::if_block(&e) {
+        if let ExprKind::If(ref pred, ref then_block, Some(ref else_expr)) = e.kind {
             let reduce = |ret, not| {
                 let mut applicability = Applicability::MachineApplicable;
                 let snip = Sugg::hir_with_applicability(cx, pred, "<predicate>", &mut applicability);
@@ -198,13 +195,9 @@ struct ExpressionInfoWithSpan {
 }
 
 fn is_unary_not(e: &Expr<'_>) -> (bool, Span) {
-    if_chain! {
-        if let ExprKind::Unary(unop, operand) = e.kind;
-        if let UnOp::UnNot = unop;
-        then {
-            return (true, operand.span);
-        }
-    };
+    if let ExprKind::Unary(UnOp::Not, operand) = e.kind {
+        return (true, operand.span);
+    }
     (false, e.span)
 }