//! 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};
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);
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;
}
}