File tree Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -1977,10 +1977,16 @@ fn lint_search_is_some<'a, 'tcx>(
19771977 if search_snippet. lines ( ) . count ( ) <= 1 {
19781978 // suggest `any(|x| ..)` instead of `any(|&x| ..)` for `find(|&x| ..).is_some()`
19791979 let any_search_snippet =
1980- if search_method == "find" && search_snippet. starts_with ( "|&" ) {
1981- Some ( search_snippet. replacen ( '&' , "" , 1 ) )
1982- } else {
1983- None
1980+ if_chain ! {
1981+ if search_method == "find" ;
1982+ if let hir:: ExprKind :: Closure ( _, _, body_id, ..) = search_args[ 1 ] . node;
1983+ let closure_body = cx. tcx. hir( ) . body( body_id) ;
1984+ if let hir:: PatKind :: Ref ( ..) = closure_body. arguments[ 0 ] . pat. node;
1985+ then {
1986+ Some ( search_snippet. replacen( '&' , "" , 1 ) )
1987+ } else {
1988+ None
1989+ }
19841990 } ;
19851991 // add note if not multi-line
19861992 span_note_and_lint (
You can’t perform that action at this time.
0 commit comments