Skip to content

Commit 533abfa

Browse files
committed
UI Test Cleanup: No wrong_self_convention in methods.rs
These cases are already covered in `tests/ui/wrong_self_convention.rs`. cc #2038
1 parent d1b4fc9 commit 533abfa

File tree

2 files changed

+23
-42
lines changed

2 files changed

+23
-42
lines changed

tests/ui/methods.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
clippy::default_trait_access,
1313
clippy::use_self,
1414
clippy::new_ret_no_self,
15-
clippy::useless_format
15+
clippy::useless_format,
16+
clippy::wrong_self_convention
1617
)]
1718

1819
#[macro_use]

tests/ui/methods.stderr

Lines changed: 21 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: defining a method called `add` on this type; consider implementing the `std::ops::Add` trait or choosing a less ambiguous name
2-
--> $DIR/methods.rs:35:5
2+
--> $DIR/methods.rs:36:5
33
|
44
LL | / pub fn add(self, other: T) -> T {
55
LL | | self
@@ -8,28 +8,8 @@ LL | | }
88
|
99
= note: `-D clippy::should-implement-trait` implied by `-D warnings`
1010

11-
error: methods called `into_*` usually take self by value; consider choosing a less ambiguous name
12-
--> $DIR/methods.rs:70:17
13-
|
14-
LL | fn into_u16(&self) -> u16 {
15-
| ^^^^^
16-
|
17-
= note: `-D clippy::wrong-self-convention` implied by `-D warnings`
18-
19-
error: methods called `to_*` usually take self by reference; consider choosing a less ambiguous name
20-
--> $DIR/methods.rs:74:21
21-
|
22-
LL | fn to_something(self) -> u32 {
23-
| ^^^^
24-
25-
error: methods called `new` usually take no self; consider choosing a less ambiguous name
26-
--> $DIR/methods.rs:78:12
27-
|
28-
LL | fn new(self) -> Self {
29-
| ^^^^
30-
3111
error: called `map(f).unwrap_or(a)` on an Option value. This can be done more directly by calling `map_or(a, f)` instead
32-
--> $DIR/methods.rs:157:13
12+
--> $DIR/methods.rs:158:13
3313
|
3414
LL | let _ = opt.map(|x| x + 1)
3515
| _____________^
@@ -41,7 +21,7 @@ LL | | .unwrap_or(0);
4121
= note: replace `map(|x| x + 1).unwrap_or(0)` with `map_or(0, |x| x + 1)`
4222

4323
error: called `map(f).unwrap_or(a)` on an Option value. This can be done more directly by calling `map_or(a, f)` instead
44-
--> $DIR/methods.rs:161:13
24+
--> $DIR/methods.rs:162:13
4525
|
4626
LL | let _ = opt.map(|x| {
4727
| _____________^
@@ -51,7 +31,7 @@ LL | | ).unwrap_or(0);
5131
| |____________________________^
5232

5333
error: called `map(f).unwrap_or(a)` on an Option value. This can be done more directly by calling `map_or(a, f)` instead
54-
--> $DIR/methods.rs:165:13
34+
--> $DIR/methods.rs:166:13
5535
|
5636
LL | let _ = opt.map(|x| x + 1)
5737
| _____________^
@@ -61,15 +41,15 @@ LL | | });
6141
| |__________________^
6242

6343
error: called `map(f).unwrap_or(None)` on an Option value. This can be done more directly by calling `and_then(f)` instead
64-
--> $DIR/methods.rs:170:13
44+
--> $DIR/methods.rs:171:13
6545
|
6646
LL | let _ = opt.map(|x| Some(x + 1)).unwrap_or(None);
6747
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6848
|
6949
= note: replace `map(|x| Some(x + 1)).unwrap_or(None)` with `and_then(|x| Some(x + 1))`
7050

7151
error: called `map(f).unwrap_or(None)` on an Option value. This can be done more directly by calling `and_then(f)` instead
72-
--> $DIR/methods.rs:172:13
52+
--> $DIR/methods.rs:173:13
7353
|
7454
LL | let _ = opt.map(|x| {
7555
| _____________^
@@ -79,7 +59,7 @@ LL | | ).unwrap_or(None);
7959
| |_____________________^
8060

8161
error: called `map(f).unwrap_or(None)` on an Option value. This can be done more directly by calling `and_then(f)` instead
82-
--> $DIR/methods.rs:176:13
62+
--> $DIR/methods.rs:177:13
8363
|
8464
LL | let _ = opt
8565
| _____________^
@@ -90,15 +70,15 @@ LL | | .unwrap_or(None);
9070
= note: replace `map(|x| Some(x + 1)).unwrap_or(None)` with `and_then(|x| Some(x + 1))`
9171

9272
error: called `map(f).unwrap_or(a)` on an Option value. This can be done more directly by calling `map_or(a, f)` instead
93-
--> $DIR/methods.rs:187:13
73+
--> $DIR/methods.rs:188:13
9474
|
9575
LL | let _ = Some("prefix").map(|p| format!("{}.", p)).unwrap_or(id);
9676
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
9777
|
9878
= note: replace `map(|p| format!("{}.", p)).unwrap_or(id)` with `map_or(id, |p| format!("{}.", p))`
9979

10080
error: called `map(f).unwrap_or_else(g)` on an Option value. This can be done more directly by calling `map_or_else(g, f)` instead
101-
--> $DIR/methods.rs:191:13
81+
--> $DIR/methods.rs:192:13
10282
|
10383
LL | let _ = opt.map(|x| x + 1)
10484
| _____________^
@@ -110,7 +90,7 @@ LL | | .unwrap_or_else(|| 0);
11090
= note: replace `map(|x| x + 1).unwrap_or_else(|| 0)` with `map_or_else(|| 0, |x| x + 1)`
11191

11292
error: called `map(f).unwrap_or_else(g)` on an Option value. This can be done more directly by calling `map_or_else(g, f)` instead
113-
--> $DIR/methods.rs:195:13
93+
--> $DIR/methods.rs:196:13
11494
|
11595
LL | let _ = opt.map(|x| {
11696
| _____________^
@@ -120,7 +100,7 @@ LL | | ).unwrap_or_else(|| 0);
120100
| |____________________________________^
121101

122102
error: called `map(f).unwrap_or_else(g)` on an Option value. This can be done more directly by calling `map_or_else(g, f)` instead
123-
--> $DIR/methods.rs:199:13
103+
--> $DIR/methods.rs:200:13
124104
|
125105
LL | let _ = opt.map(|x| x + 1)
126106
| _____________^
@@ -130,7 +110,7 @@ LL | | );
130110
| |_________________^
131111

132112
error: called `filter(p).next()` on an `Iterator`. This is more succinctly expressed by calling `.find(p)` instead.
133-
--> $DIR/methods.rs:229:13
113+
--> $DIR/methods.rs:230:13
134114
|
135115
LL | let _ = v.iter().filter(|&x| *x < 0).next();
136116
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -139,7 +119,7 @@ LL | let _ = v.iter().filter(|&x| *x < 0).next();
139119
= note: replace `filter(|&x| *x < 0).next()` with `find(|&x| *x < 0)`
140120

141121
error: called `filter(p).next()` on an `Iterator`. This is more succinctly expressed by calling `.find(p)` instead.
142-
--> $DIR/methods.rs:232:13
122+
--> $DIR/methods.rs:233:13
143123
|
144124
LL | let _ = v.iter().filter(|&x| {
145125
| _____________^
@@ -149,7 +129,7 @@ LL | | ).next();
149129
| |___________________________^
150130

151131
error: called `is_some()` after searching an `Iterator` with find. This is more succinctly expressed by calling `any()`.
152-
--> $DIR/methods.rs:248:13
132+
--> $DIR/methods.rs:249:13
153133
|
154134
LL | let _ = v.iter().find(|&x| *x < 0).is_some();
155135
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -158,7 +138,7 @@ LL | let _ = v.iter().find(|&x| *x < 0).is_some();
158138
= note: replace `find(|&x| *x < 0).is_some()` with `any(|x| *x < 0)`
159139

160140
error: called `is_some()` after searching an `Iterator` with find. This is more succinctly expressed by calling `any()`.
161-
--> $DIR/methods.rs:251:13
141+
--> $DIR/methods.rs:252:13
162142
|
163143
LL | let _ = v.iter().find(|&x| {
164144
| _____________^
@@ -168,15 +148,15 @@ LL | | ).is_some();
168148
| |______________________________^
169149

170150
error: called `is_some()` after searching an `Iterator` with position. This is more succinctly expressed by calling `any()`.
171-
--> $DIR/methods.rs:257:13
151+
--> $DIR/methods.rs:258:13
172152
|
173153
LL | let _ = v.iter().position(|&x| x < 0).is_some();
174154
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
175155
|
176156
= note: replace `position(|&x| x < 0).is_some()` with `any(|&x| x < 0)`
177157

178158
error: called `is_some()` after searching an `Iterator` with position. This is more succinctly expressed by calling `any()`.
179-
--> $DIR/methods.rs:260:13
159+
--> $DIR/methods.rs:261:13
180160
|
181161
LL | let _ = v.iter().position(|&x| {
182162
| _____________^
@@ -186,15 +166,15 @@ LL | | ).is_some();
186166
| |______________________________^
187167

188168
error: called `is_some()` after searching an `Iterator` with rposition. This is more succinctly expressed by calling `any()`.
189-
--> $DIR/methods.rs:266:13
169+
--> $DIR/methods.rs:267:13
190170
|
191171
LL | let _ = v.iter().rposition(|&x| x < 0).is_some();
192172
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
193173
|
194174
= note: replace `rposition(|&x| x < 0).is_some()` with `any(|&x| x < 0)`
195175

196176
error: called `is_some()` after searching an `Iterator` with rposition. This is more succinctly expressed by calling `any()`.
197-
--> $DIR/methods.rs:269:13
177+
--> $DIR/methods.rs:270:13
198178
|
199179
LL | let _ = v.iter().rposition(|&x| {
200180
| _____________^
@@ -204,12 +184,12 @@ LL | | ).is_some();
204184
| |______________________________^
205185

206186
error: used unwrap() on an Option value. If you don't want to handle the None case gracefully, consider using expect() to provide a better panic message
207-
--> $DIR/methods.rs:284:13
187+
--> $DIR/methods.rs:285:13
208188
|
209189
LL | let _ = opt.unwrap();
210190
| ^^^^^^^^^^^^
211191
|
212192
= note: `-D clippy::option-unwrap-used` implied by `-D warnings`
213193

214-
error: aborting due to 23 previous errors
194+
error: aborting due to 20 previous errors
215195

0 commit comments

Comments
 (0)