File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -1975,6 +1975,13 @@ fn lint_search_is_some<'a, 'tcx>(
19751975 ) ;
19761976 let search_snippet = snippet ( cx, search_args[ 1 ] . span , ".." ) ;
19771977 if search_snippet. lines ( ) . count ( ) <= 1 {
1978+ // suggest `any(|x| ..)` instead of `any(|&x| ..)` for `find(|&x| ..).is_some()`
1979+ let any_search_snippet =
1980+ if search_method == "find" && search_snippet. starts_with ( "|&" ) {
1981+ Some ( search_snippet. replacen ( '&' , "" , 1 ) )
1982+ } else {
1983+ None
1984+ } ;
19781985 // add note if not multi-line
19791986 span_note_and_lint (
19801987 cx,
@@ -1983,8 +1990,9 @@ fn lint_search_is_some<'a, 'tcx>(
19831990 & msg,
19841991 expr. span ,
19851992 & format ! (
1986- "replace `{0}({1}).is_some()` with `any({1})`" ,
1987- search_method, search_snippet
1993+ "replace `{0}({1}).is_some()` with `any({2})`" ,
1994+ search_method, search_snippet,
1995+ any_search_snippet. as_ref( ) . map_or( & * search_snippet, String :: as_str)
19881996 ) ,
19891997 ) ;
19901998 } else {
You can’t perform that action at this time.
0 commit comments