about summary refs log tree commit diff
diff options
context:
space:
mode:
authorThibsG <thibsg@pm.me>2021-10-20 22:04:56 +0200
committerThibsG <thibsg@pm.me>2021-11-20 09:40:11 +0100
commit7221999181c3d14b45ba10240bbaa49da7f74e72 (patch)
tree77c2751d8e82de61d1bdacb1f8c11dcc73166039
parentabaaf744fdbe8106bc82ceaa34e8499d5436fc3c (diff)
downloadrust-7221999181c3d14b45ba10240bbaa49da7f74e72.tar.gz
rust-7221999181c3d14b45ba10240bbaa49da7f74e72.zip
Add tests with closure
-rw-r--r--tests/ui/search_is_some.rs6
-rw-r--r--tests/ui/search_is_some.stderr20
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