diff options
| -rw-r--r-- | tests/ui/search_is_some.rs | 6 | ||||
| -rw-r--r-- | tests/ui/search_is_some.stderr | 20 |
2 files changed, 22 insertions, 4 deletions
diff --git a/tests/ui/search_is_some.rs b/tests/ui/search_is_some.rs index 72bc6ef35d3..72f335153c1 100644 --- a/tests/ui/search_is_some.rs +++ b/tests/ui/search_is_some.rs @@ -36,6 +36,9 @@ fn main() { // check that we don't lint if `find()` is called with // `Pattern` that is not a string let _ = "hello world".find(|c: char| c == 'o' || c == 'l').is_some(); + + let some_closure = |x: &u32| *x == 0; + let _ = (0..1).find(some_closure).is_some(); } #[rustfmt::skip] @@ -70,4 +73,7 @@ fn is_none() { // check that we don't lint if `find()` is called with // `Pattern` that is not a string let _ = "hello world".find(|c: char| c == 'o' || c == 'l').is_none(); + + let some_closure = |x: &u32| *x == 0; + let _ = (0..1).find(some_closure).is_none(); } diff --git a/tests/ui/search_is_some.stderr b/tests/ui/search_is_some.stderr index f3c758e451e..54760545bce 100644 --- a/tests/ui/search_is_some.stderr +++ b/tests/ui/search_is_some.stderr @@ -35,8 +35,14 @@ LL | | ).is_some(); | = help: this is more succinctly expressed by calling `any()` +error: called `is_some()` after searching an `Iterator` with `find` + --> $DIR/search_is_some.rs:41:20 + | +LL | let _ = (0..1).find(some_closure).is_some(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `any()` instead: `any(some_closure)` + error: called `is_none()` after searching an `Iterator` with `find` - --> $DIR/search_is_some.rs:48:13 + --> $DIR/search_is_some.rs:51:13 | LL | let _ = v.iter().find(|&x| { | _____________^ @@ -48,7 +54,7 @@ LL | | ).is_none(); = help: this is more succinctly expressed by calling `any()` with negation error: called `is_none()` after searching an `Iterator` with `position` - --> $DIR/search_is_some.rs:54:13 + --> $DIR/search_is_some.rs:57:13 | LL | let _ = v.iter().position(|&x| { | _____________^ @@ -60,7 +66,7 @@ LL | | ).is_none(); = help: this is more succinctly expressed by calling `any()` with negation error: called `is_none()` after searching an `Iterator` with `rposition` - --> $DIR/search_is_some.rs:60:13 + --> $DIR/search_is_some.rs:63:13 | LL | let _ = v.iter().rposition(|&x| { | _____________^ @@ -71,5 +77,11 @@ LL | | ).is_none(); | = help: this is more succinctly expressed by calling `any()` with negation -error: aborting due to 6 previous errors +error: called `is_none()` after searching an `Iterator` with `find` + --> $DIR/search_is_some.rs:78:13 + | +LL | let _ = (0..1).find(some_closure).is_none(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `!_.any()` instead: `!(0..1).any(some_closure)` + +error: aborting due to 8 previous errors |
