]> git.lizzy.rs Git - rust.git/commitdiff
Fix needless_bool.rs
authorManish Goregaokar <manishsmail@gmail.com>
Sat, 11 May 2019 02:23:26 +0000 (19:23 -0700)
committerManish Goregaokar <manishsmail@gmail.com>
Sat, 11 May 2019 06:40:42 +0000 (23:40 -0700)
clippy_lints/src/needless_bool.rs

index 94febdbd8a793e18433b256c27dc565007e678f4..0404bc41570f1b74e09b612b923c183612e92e20 100644 (file)
@@ -3,7 +3,7 @@
 //! This lint is **warn** by default
 
 use crate::utils::sugg::Sugg;
-use crate::utils::{in_macro, span_lint, span_lint_and_sugg};
+use crate::utils::{higher, in_macro, span_lint, span_lint_and_sugg};
 use rustc::hir::*;
 use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
 use rustc::{declare_lint_pass, declare_tool_lint};
@@ -59,7 +59,7 @@
 impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessBool {
     fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx Expr) {
         use self::Expression::*;
-        if let ExprKind::If(ref pred, ref then_block, Some(ref else_expr)) = e.node {
+        if let Some((ref pred, ref then_block, Some(ref else_expr))) = higher::if_block(&e) {
             let reduce = |ret, not| {
                 let mut applicability = Applicability::MachineApplicable;
                 let snip = Sugg::hir_with_applicability(cx, pred, "<predicate>", &mut applicability);
@@ -119,7 +119,7 @@ fn parent_node_is_if_expr<'a, 'b>(expr: &Expr, cx: &LateContext<'a, 'b>) -> bool
     let parent_node = cx.tcx.hir().get_by_hir_id(parent_id);
 
     if let rustc::hir::Node::Expr(e) = parent_node {
-        if let ExprKind::If(_, _, _) = e.node {
+        if higher::if_block(&e).is_some() {
             return true;
         }
     }