]> git.lizzy.rs Git - rust.git/blobdiff - src/tools/clippy/clippy_lints/src/needless_bool.rs
Rollup merge of #89789 - jkugelman:must-use-thread-builder, r=joshtriplett
[rust.git] / src / tools / clippy / clippy_lints / src / needless_bool.rs
index 36f2829a5b94ee4dcaca93701f4e2e0f137146ea..91944653500bbde663f4e14c9226279eca4fcacc 100644 (file)
@@ -3,6 +3,7 @@
 //! This lint is **warn** by default
 
 use clippy_utils::diagnostics::{span_lint, span_lint_and_sugg};
+use clippy_utils::higher;
 use clippy_utils::source::snippet_with_applicability;
 use clippy_utils::sugg::Sugg;
 use clippy_utils::{is_else_clause, is_expn_of};
@@ -77,10 +78,15 @@ fn check_expr(&mut self, cx: &LateContext<'tcx>, e: &'tcx Expr<'_>) {
         if e.span.from_expansion() {
             return;
         }
-        if let ExprKind::If(pred, then_block, Some(else_expr)) = e.kind {
+        if let Some(higher::If {
+            cond,
+            then,
+            r#else: Some(r#else),
+        }) = higher::If::hir(e)
+        {
             let reduce = |ret, not| {
                 let mut applicability = Applicability::MachineApplicable;
-                let snip = Sugg::hir_with_applicability(cx, pred, "<predicate>", &mut applicability);
+                let snip = Sugg::hir_with_applicability(cx, cond, "<predicate>", &mut applicability);
                 let mut snip = if not { !snip } else { snip };
 
                 if ret {
@@ -101,8 +107,8 @@ fn check_expr(&mut self, cx: &LateContext<'tcx>, e: &'tcx Expr<'_>) {
                     applicability,
                 );
             };
-            if let ExprKind::Block(then_block, _) = then_block.kind {
-                match (fetch_bool_block(then_block), fetch_bool_expr(else_expr)) {
+            if let ExprKind::Block(then, _) = then.kind {
+                match (fetch_bool_block(then), fetch_bool_expr(r#else)) {
                     (RetBool(true), RetBool(true)) | (Bool(true), Bool(true)) => {
                         span_lint(
                             cx,
@@ -242,7 +248,7 @@ fn check_comparison<'a, 'tcx>(
         if l_ty.is_bool() && r_ty.is_bool() {
             let mut applicability = Applicability::MachineApplicable;
 
-            if let BinOpKind::Eq = op.node {
+            if op.node == BinOpKind::Eq {
                 let expression_info = one_side_is_unary_not(left_side, right_side);
                 if expression_info.one_side_is_unary_not {
                     span_lint_and_sugg(