Skip to content

Commit a397d94

Browse files
author
Eric Loren
committed
PR suggestion: use util for closures
1 parent 255cf0a commit a397d94

File tree

1 file changed

+2
-5
lines changed
  • clippy_lints/src/methods

1 file changed

+2
-5
lines changed

clippy_lints/src/methods/mod.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -3192,8 +3192,9 @@ fn is_method<'tcx>(cx: &LateContext<'tcx>, expr: &hir::Expr<'_>, method_path: &[
31923192
hir::ExprKind::Path(qp) => match_qpath(qp, method_path),
31933193
hir::ExprKind::Closure(_, _, c, _, _) => {
31943194
let body = cx.tcx.hir().body(*c);
3195+
let closure_expr = remove_blocks(&body.value);
31953196
let arg_id = body.params[0].pat.hir_id;
3196-
match body.value.kind {
3197+
match closure_expr.kind {
31973198
hir::ExprKind::MethodCall(hir::PathSegment { ident, .. }, _, ref args, _) => {
31983199
if_chain! {
31993200
if ident.name == method_name;
@@ -3205,10 +3206,6 @@ fn is_method<'tcx>(cx: &LateContext<'tcx>, expr: &hir::Expr<'_>, method_path: &[
32053206
}
32063207
false
32073208
},
3208-
hir::ExprKind::Block(ref block, _) => block
3209-
.expr
3210-
.as_ref()
3211-
.map_or(false, |expr| is_method(cx, &expr, method_path, method_name)),
32123209
_ => false,
32133210
}
32143211
},

0 commit comments

Comments
 (0)