]> git.lizzy.rs Git - rust.git/blobdiff - clippy_lints/src/methods/unnecessary_fold.rs
separate the receiver from arguments in HIR under /clippy
[rust.git] / clippy_lints / src / methods / unnecessary_fold.rs
index 4c4034437da51601337af3aec9c36ca57a237ab0..c3531d4d0511e9e8f730dbc64e35190fc2228f53 100644 (file)
@@ -1,6 +1,6 @@
 use clippy_utils::diagnostics::span_lint_and_sugg;
 use clippy_utils::source::snippet_with_applicability;
-use clippy_utils::{is_trait_method, path_to_local_id, remove_blocks, strip_pat_refs};
+use clippy_utils::{is_trait_method, path_to_local_id, peel_blocks, strip_pat_refs};
 use if_chain::if_chain;
 use rustc_ast::ast;
 use rustc_errors::Applicability;
@@ -29,9 +29,9 @@ fn check_fold_with_op(
     ) {
         if_chain! {
             // Extract the body of the closure passed to fold
-            if let hir::ExprKind::Closure(_, _, body_id, _, _) = acc.kind;
-            let closure_body = cx.tcx.hir().body(body_id);
-            let closure_expr = remove_blocks(&closure_body.value);
+            if let hir::ExprKind::Closure(&hir::Closure { body, .. }) = acc.kind;
+            let closure_body = cx.tcx.hir().body(body);
+            let closure_expr = peel_blocks(&closure_body.value);
 
             // Check if the closure body is of the form `acc <op> some_expr(x)`
             if let hir::ExprKind::Binary(ref bin_op, left_expr, right_expr) = closure_expr.kind;