fix suggestion for search_is_some
This commit is contained in:
parent
bd0b75f6c3
commit
c3fde34fd5
1 changed files with 10 additions and 4 deletions
|
@ -1977,10 +1977,16 @@ fn lint_search_is_some<'a, 'tcx>(
|
|||
if search_snippet.lines().count() <= 1 {
|
||||
// suggest `any(|x| ..)` instead of `any(|&x| ..)` for `find(|&x| ..).is_some()`
|
||||
let any_search_snippet =
|
||||
if search_method == "find" && search_snippet.starts_with("|&") {
|
||||
if_chain! {
|
||||
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;
|
||||
then {
|
||||
Some(search_snippet.replacen('&', "", 1))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
};
|
||||
// add note if not multi-line
|
||||
span_note_and_lint(
|
||||
|
|
Loading…
Reference in a new issue