Skip to content

Commit

Permalink
check closure arguments before use it
Browse files Browse the repository at this point in the history
  • Loading branch information
airt committed Apr 30, 2019
1 parent 5d6a100 commit d063516
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion clippy_lints/src/methods/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit d063516

Please sign in to comment.