From d063516c85a2d0ae368911bd8ffe3a9459a252ba Mon Sep 17 00:00:00 2001 From: airt Date: Wed, 1 May 2019 04:41:00 +0800 Subject: [PATCH] check closure arguments before use it --- clippy_lints/src/methods/mod.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/clippy_lints/src/methods/mod.rs b/clippy_lints/src/methods/mod.rs index 07a207545a0..3ea18f1d14d 100644 --- a/clippy_lints/src/methods/mod.rs +++ b/clippy_lints/src/methods/mod.rs @@ -1980,7 +1980,8 @@ fn lint_search_is_some<'a, 'tcx>( if search_method == "find"; if let hir::ExprKind::Closure(_, _, body_id, ..) = search_args[1].node; let closure_body = cx.tcx.hir().body(body_id); - if let hir::PatKind::Ref(..) = closure_body.arguments[0].pat.node; + if let Some(closure_arg) = closure_body.arguments.get(0); + if let hir::PatKind::Ref(..) = closure_arg.pat.node; then { Some(search_snippet.replacen('&', "", 1)) } else {