Add tests with closure

This commit is contained in:
ThibsG 2021-10-20 22:04:56 +02:00
parent abaaf744fd
commit 7221999181
2 changed files with 22 additions and 4 deletions

View File

@ -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();
}

View File

@ -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