|
3 | 3 | //! This lint is **warn** by default |
4 | 4 |
|
5 | 5 | use crate::utils::sugg::Sugg; |
6 | | -use crate::utils::{in_macro, span_lint, span_lint_and_sugg}; |
| 6 | +use crate::utils::{higher, in_macro, span_lint, span_lint_and_sugg}; |
7 | 7 | use rustc::hir::*; |
8 | 8 | use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; |
9 | 9 | use rustc::{declare_lint_pass, declare_tool_lint}; |
@@ -59,7 +59,7 @@ declare_lint_pass!(NeedlessBool => [NEEDLESS_BOOL]); |
59 | 59 | impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessBool { |
60 | 60 | fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx Expr) { |
61 | 61 | use self::Expression::*; |
62 | | - if let ExprKind::If(ref pred, ref then_block, Some(ref else_expr)) = e.node { |
| 62 | + if let Some((ref pred, ref then_block, Some(ref else_expr))) = higher::if_block(&e) { |
63 | 63 | let reduce = |ret, not| { |
64 | 64 | let mut applicability = Applicability::MachineApplicable; |
65 | 65 | 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 |
119 | 119 | let parent_node = cx.tcx.hir().get_by_hir_id(parent_id); |
120 | 120 |
|
121 | 121 | if let rustc::hir::Node::Expr(e) = parent_node { |
122 | | - if let ExprKind::If(_, _, _) = e.node { |
| 122 | + if higher::if_block(&e).is_some() { |
123 | 123 | return true; |
124 | 124 | } |
125 | 125 | } |
|
0 commit comments