]> git.lizzy.rs Git - rust.git/blobdiff - src/tools/clippy/clippy_lints/src/floating_point_arithmetic.rs
Auto merge of #85690 - bstrie:m2_arena, r=jackh726,nagisa
[rust.git] / src / tools / clippy / clippy_lints / src / floating_point_arithmetic.rs
index b01c0cdd84624d8beab66a039f0f70922d1115a1..d12482e7b7bb9531bb4fe569e29321b1976d121c 100644 (file)
@@ -3,6 +3,7 @@
     Constant::{Int, F32, F64},
 };
 use clippy_utils::diagnostics::span_lint_and_sugg;
+use clippy_utils::higher;
 use clippy_utils::{eq_expr_value, get_parent_expr, numeric_literal, sugg};
 use if_chain::if_chain;
 use rustc_errors::Applicability;
@@ -545,11 +546,11 @@ fn are_negated<'a>(cx: &LateContext<'_>, expr1: &'a Expr<'a>, expr2: &'a Expr<'a
 
 fn check_custom_abs(cx: &LateContext<'_>, expr: &Expr<'_>) {
     if_chain! {
-        if let ExprKind::If(cond, body, else_body) = expr.kind;
-        if let ExprKind::Block(block, _) = body.kind;
+        if let Some(higher::If { cond, then, r#else }) = higher::If::hir(expr);
+        if let ExprKind::Block(block, _) = then.kind;
         if block.stmts.is_empty();
         if let Some(if_body_expr) = block.expr;
-        if let Some(ExprKind::Block(else_block, _)) = else_body.map(|el| &el.kind);
+        if let Some(ExprKind::Block(else_block, _)) = r#else.map(|el| &el.kind);
         if else_block.stmts.is_empty();
         if let Some(else_body_expr) = else_block.expr;
         if let Some((if_expr_positive, body)) = are_negated(cx, if_body_expr, else_body_expr);