Skip to content

Commit a71211d

Browse files
committed
Auto merge of #12140 - GuillaumeGomez:improve-message-search_is_some, r=llogiq
Improve help message for `search_is_some` lint Fixes #11681. Like mentioned in the issue, we tend to use the formulation "consider using", which we didn't in this case. I think it clears both the confusion and also makes help message more coherent overall. r? `@llogiq` changelog: Improve help message for `search_is_some` lint
2 parents 7eca5af + 37947ff commit a71211d

File tree

5 files changed

+97
-97
lines changed

5 files changed

+97
-97
lines changed

clippy_lints/src/methods/search_is_some.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ pub(super) fn check<'tcx>(
6363
SEARCH_IS_SOME,
6464
method_span.with_hi(expr.span.hi()),
6565
&msg,
66-
"use `any()` instead",
66+
"consider using",
6767
format!(
6868
"any({})",
6969
any_search_snippet.as_ref().map_or(&*search_snippet, String::as_str)
@@ -77,7 +77,7 @@ pub(super) fn check<'tcx>(
7777
SEARCH_IS_SOME,
7878
expr.span,
7979
&msg,
80-
"use `!_.any()` instead",
80+
"consider using",
8181
format!(
8282
"!{iter}.any({})",
8383
any_search_snippet.as_ref().map_or(&*search_snippet, String::as_str)
@@ -118,7 +118,7 @@ pub(super) fn check<'tcx>(
118118
SEARCH_IS_SOME,
119119
method_span.with_hi(expr.span.hi()),
120120
&msg,
121-
"use `contains()` instead",
121+
"consider using",
122122
format!("contains({find_arg})"),
123123
applicability,
124124
);
@@ -132,7 +132,7 @@ pub(super) fn check<'tcx>(
132132
SEARCH_IS_SOME,
133133
expr.span,
134134
&msg,
135-
"use `!_.contains()` instead",
135+
"consider using",
136136
format!("!{string}.contains({find_arg})"),
137137
applicability,
138138
);

tests/ui/crashes/ice-9041.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error: called `is_some()` after searching an `Iterator` with `find`
22
--> $DIR/ice-9041.rs:5:19
33
|
44
LL | things.iter().find(|p| is_thing_ready(p)).is_some()
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `any()` instead: `any(|p| is_thing_ready(&p))`
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `any(|p| is_thing_ready(&p))`
66
|
77
= note: `-D clippy::search-is-some` implied by `-D warnings`
88
= help: to override `-D warnings` add `#[allow(clippy::search_is_some)]`

tests/ui/search_is_some.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ error: called `is_some()` after searching an `Iterator` with `find`
4040
--> $DIR/search_is_some.rs:42:20
4141
|
4242
LL | let _ = (0..1).find(some_closure).is_some();
43-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `any()` instead: `any(some_closure)`
43+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `any(some_closure)`
4444

4545
error: called `is_none()` after searching an `Iterator` with `find`
4646
--> $DIR/search_is_some.rs:52:13
@@ -82,7 +82,7 @@ error: called `is_none()` after searching an `Iterator` with `find`
8282
--> $DIR/search_is_some.rs:79:13
8383
|
8484
LL | let _ = (0..1).find(some_closure).is_none();
85-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `!_.any()` instead: `!(0..1).any(some_closure)`
85+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `!(0..1).any(some_closure)`
8686

8787
error: aborting due to 8 previous errors
8888

0 commit comments

Comments
 (0)