Skip to content

Commit 55dc822

Browse files
committed
Ran tests/ui/update-all-references.sh" and cargo dev fmt`
1 parent 431fcbc commit 55dc822

File tree

6 files changed

+175
-73
lines changed

6 files changed

+175
-73
lines changed

tests/ui/methods.stderr

Lines changed: 0 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -20,71 +20,3 @@ LL | | ).next();
2020
|
2121
= note: `-D clippy::filter-next` implied by `-D warnings`
2222

23-
error: called `is_some()` after searching an `Iterator` with find. This is more succinctly expressed by calling `any()`.
24-
--> $DIR/methods.rs:143:22
25-
|
26-
LL | let _ = v.iter().find(|&x| *x < 0).is_some();
27-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `any(|x| *x < 0)`
28-
|
29-
= note: `-D clippy::search-is-some` implied by `-D warnings`
30-
31-
error: called `is_some()` after searching an `Iterator` with find. This is more succinctly expressed by calling `any()`.
32-
--> $DIR/methods.rs:144:20
33-
|
34-
LL | let _ = (0..1).find(|x| **y == *x).is_some(); // one dereference less
35-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `any(|x| **y == x)`
36-
37-
error: called `is_some()` after searching an `Iterator` with find. This is more succinctly expressed by calling `any()`.
38-
--> $DIR/methods.rs:145:20
39-
|
40-
LL | let _ = (0..1).find(|x| *x == 0).is_some();
41-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `any(|x| x == 0)`
42-
43-
error: called `is_some()` after searching an `Iterator` with find. This is more succinctly expressed by calling `any()`.
44-
--> $DIR/methods.rs:146:22
45-
|
46-
LL | let _ = v.iter().find(|x| **x == 0).is_some();
47-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `any(|x| *x == 0)`
48-
49-
error: called `is_some()` after searching an `Iterator` with find. This is more succinctly expressed by calling `any()`.
50-
--> $DIR/methods.rs:149:13
51-
|
52-
LL | let _ = v.iter().find(|&x| {
53-
| _____________^
54-
LL | | *x < 0
55-
LL | | }
56-
LL | | ).is_some();
57-
| |______________________________^
58-
59-
error: called `is_some()` after searching an `Iterator` with position. This is more succinctly expressed by calling `any()`.
60-
--> $DIR/methods.rs:155:22
61-
|
62-
LL | let _ = v.iter().position(|&x| x < 0).is_some();
63-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `any(|&x| x < 0)`
64-
65-
error: called `is_some()` after searching an `Iterator` with position. This is more succinctly expressed by calling `any()`.
66-
--> $DIR/methods.rs:158:13
67-
|
68-
LL | let _ = v.iter().position(|&x| {
69-
| _____________^
70-
LL | | x < 0
71-
LL | | }
72-
LL | | ).is_some();
73-
| |______________________________^
74-
75-
error: called `is_some()` after searching an `Iterator` with rposition. This is more succinctly expressed by calling `any()`.
76-
--> $DIR/methods.rs:164:22
77-
|
78-
LL | let _ = v.iter().rposition(|&x| x < 0).is_some();
79-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `any(|&x| x < 0)`
80-
81-
error: called `is_some()` after searching an `Iterator` with rposition. This is more succinctly expressed by calling `any()`.
82-
--> $DIR/methods.rs:167:13
83-
|
84-
LL | let _ = v.iter().rposition(|&x| {
85-
| _____________^
86-
LL | | x < 0
87-
LL | | }
88-
LL | | ).is_some();
89-
| |______________________________^
90-

tests/ui/search_is_some.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#[macro_use]
1+
// aux-build:option_helpers.rs
22
extern crate option_helpers;
33
use option_helpers::IteratorFalsePositives;
44

@@ -36,4 +36,3 @@ fn main() {
3636
// `Pattern` that is not a string
3737
let _ = "hello world".find(|c: char| c == 'o' || c == 'l').is_some();
3838
}
39-

tests/ui/search_is_some.stderr

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
error: called `is_some()` after searching an `Iterator` with find. This is more succinctly expressed by calling `any()`.
2+
--> $DIR/search_is_some.rs:13:13
3+
|
4+
LL | let _ = v.iter().find(|&x| {
5+
| _____________^
6+
LL | | *x < 0
7+
LL | | }
8+
LL | | ).is_some();
9+
| |______________________________^
10+
|
11+
= note: `-D clippy::search-is-some` implied by `-D warnings`
12+
13+
error: called `is_some()` after searching an `Iterator` with position. This is more succinctly expressed by calling `any()`.
14+
--> $DIR/search_is_some.rs:19:13
15+
|
16+
LL | let _ = v.iter().position(|&x| {
17+
| _____________^
18+
LL | | x < 0
19+
LL | | }
20+
LL | | ).is_some();
21+
| |______________________________^
22+
23+
error: called `is_some()` after searching an `Iterator` with rposition. This is more succinctly expressed by calling `any()`.
24+
--> $DIR/search_is_some.rs:25:13
25+
|
26+
LL | let _ = v.iter().rposition(|&x| {
27+
| _____________^
28+
LL | | x < 0
29+
LL | | }
30+
LL | | ).is_some();
31+
| |______________________________^
32+
33+
error: use of a blacklisted/placeholder name `foo`
34+
--> $DIR/search_is_some.rs:31:9
35+
|
36+
LL | let foo = IteratorFalsePositives { foo: 0 };
37+
| ^^^
38+
|
39+
= note: `-D clippy::blacklisted-name` implied by `-D warnings`
40+
41+
error: aborting due to 4 previous errors
42+

tests/ui/search_is_some_fixable.fixed

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// run-rustfix
2+
3+
#![warn(clippy::search_is_some)]
4+
5+
fn main() {
6+
let v = vec![3, 2, 1, 0, -1, -2, -3];
7+
let y = &&42;
8+
9+
// Check `find().is_some()`, single-line case.
10+
let _ = v.iter().any(|x| *x < 0);
11+
let _ = (0..1).any(|x| **y == x); // one dereference less
12+
let _ = (0..1).any(|x| x == 0);
13+
let _ = v.iter().any(|x| *x == 0);
14+
15+
// Check `position().is_some()`, single-line case.
16+
let _ = v.iter().any(|&x| x < 0);
17+
18+
// Check `rposition().is_some()`, single-line case.
19+
let _ = v.iter().any(|&x| x < 0);
20+
21+
let s1 = String::from("hello world");
22+
let s2 = String::from("world");
23+
// caller of `find()` is a `&`static str`
24+
let _ = "hello world".contains("world");
25+
let _ = "hello world".contains(&s2);
26+
let _ = "hello world".contains(&s2[2..]);
27+
// caller of `find()` is a `String`
28+
let _ = s1.contains("world");
29+
let _ = s1.contains(&s2);
30+
let _ = s1.contains(&s2[2..]);
31+
// caller of `find()` is slice of `String`
32+
let _ = s1[2..].contains("world");
33+
let _ = s1[2..].contains(&s2);
34+
let _ = s1[2..].contains(&s2[2..]);
35+
}

tests/ui/search_is_some_fixable.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@
55
fn main() {
66
let v = vec![3, 2, 1, 0, -1, -2, -3];
77
let y = &&42;
8-
8+
99
// Check `find().is_some()`, single-line case.
1010
let _ = v.iter().find(|&x| *x < 0).is_some();
1111
let _ = (0..1).find(|x| **y == *x).is_some(); // one dereference less
1212
let _ = (0..1).find(|x| *x == 0).is_some();
1313
let _ = v.iter().find(|x| **x == 0).is_some();
14-
14+
1515
// Check `position().is_some()`, single-line case.
1616
let _ = v.iter().position(|&x| x < 0).is_some();
17-
17+
1818
// Check `rposition().is_some()`, single-line case.
1919
let _ = v.iter().rposition(|&x| x < 0).is_some();
2020

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
error: called `is_some()` after searching an `Iterator` with find. This is more succinctly expressed by calling `any()`.
2+
--> $DIR/search_is_some_fixable.rs:10:22
3+
|
4+
LL | let _ = v.iter().find(|&x| *x < 0).is_some();
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `any(|x| *x < 0)`
6+
|
7+
= note: `-D clippy::search-is-some` implied by `-D warnings`
8+
9+
error: called `is_some()` after searching an `Iterator` with find. This is more succinctly expressed by calling `any()`.
10+
--> $DIR/search_is_some_fixable.rs:11:20
11+
|
12+
LL | let _ = (0..1).find(|x| **y == *x).is_some(); // one dereference less
13+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `any(|x| **y == x)`
14+
15+
error: called `is_some()` after searching an `Iterator` with find. This is more succinctly expressed by calling `any()`.
16+
--> $DIR/search_is_some_fixable.rs:12:20
17+
|
18+
LL | let _ = (0..1).find(|x| *x == 0).is_some();
19+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `any(|x| x == 0)`
20+
21+
error: called `is_some()` after searching an `Iterator` with find. This is more succinctly expressed by calling `any()`.
22+
--> $DIR/search_is_some_fixable.rs:13:22
23+
|
24+
LL | let _ = v.iter().find(|x| **x == 0).is_some();
25+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `any(|x| *x == 0)`
26+
27+
error: called `is_some()` after searching an `Iterator` with position. This is more succinctly expressed by calling `any()`.
28+
--> $DIR/search_is_some_fixable.rs:16:22
29+
|
30+
LL | let _ = v.iter().position(|&x| x < 0).is_some();
31+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `any(|&x| x < 0)`
32+
33+
error: called `is_some()` after searching an `Iterator` with rposition. This is more succinctly expressed by calling `any()`.
34+
--> $DIR/search_is_some_fixable.rs:19:22
35+
|
36+
LL | let _ = v.iter().rposition(|&x| x < 0).is_some();
37+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `any(|&x| x < 0)`
38+
39+
error: called `is_some()` after calling `find()` on a string. This is more succinctly expressed by calling `contains()`.
40+
--> $DIR/search_is_some_fixable.rs:24:27
41+
|
42+
LL | let _ = "hello world".find("world").is_some();
43+
| ^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `contains("world")`
44+
45+
error: called `is_some()` after calling `find()` on a string. This is more succinctly expressed by calling `contains()`.
46+
--> $DIR/search_is_some_fixable.rs:25:27
47+
|
48+
LL | let _ = "hello world".find(&s2).is_some();
49+
| ^^^^^^^^^^^^^^^^^^^ help: try this: `contains(&s2)`
50+
51+
error: called `is_some()` after calling `find()` on a string. This is more succinctly expressed by calling `contains()`.
52+
--> $DIR/search_is_some_fixable.rs:26:27
53+
|
54+
LL | let _ = "hello world".find(&s2[2..]).is_some();
55+
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `contains(&s2[2..])`
56+
57+
error: called `is_some()` after calling `find()` on a string. This is more succinctly expressed by calling `contains()`.
58+
--> $DIR/search_is_some_fixable.rs:28:16
59+
|
60+
LL | let _ = s1.find("world").is_some();
61+
| ^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `contains("world")`
62+
63+
error: called `is_some()` after calling `find()` on a string. This is more succinctly expressed by calling `contains()`.
64+
--> $DIR/search_is_some_fixable.rs:29:16
65+
|
66+
LL | let _ = s1.find(&s2).is_some();
67+
| ^^^^^^^^^^^^^^^^^^^ help: try this: `contains(&s2)`
68+
69+
error: called `is_some()` after calling `find()` on a string. This is more succinctly expressed by calling `contains()`.
70+
--> $DIR/search_is_some_fixable.rs:30:16
71+
|
72+
LL | let _ = s1.find(&s2[2..]).is_some();
73+
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `contains(&s2[2..])`
74+
75+
error: called `is_some()` after calling `find()` on a string. This is more succinctly expressed by calling `contains()`.
76+
--> $DIR/search_is_some_fixable.rs:32:21
77+
|
78+
LL | let _ = s1[2..].find("world").is_some();
79+
| ^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `contains("world")`
80+
81+
error: called `is_some()` after calling `find()` on a string. This is more succinctly expressed by calling `contains()`.
82+
--> $DIR/search_is_some_fixable.rs:33:21
83+
|
84+
LL | let _ = s1[2..].find(&s2).is_some();
85+
| ^^^^^^^^^^^^^^^^^^^ help: try this: `contains(&s2)`
86+
87+
error: called `is_some()` after calling `find()` on a string. This is more succinctly expressed by calling `contains()`.
88+
--> $DIR/search_is_some_fixable.rs:34:21
89+
|
90+
LL | let _ = s1[2..].find(&s2[2..]).is_some();
91+
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `contains(&s2[2..])`
92+
93+
error: aborting due to 15 previous errors
94+

0 commit comments

Comments
 (0)