]> git.lizzy.rs Git - rust.git/blob - tests/ui/methods.stderr
Adapt the *.stderr files of the ui-tests to the tool_lints
[rust.git] / tests / ui / methods.stderr
1 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:21:5
3    |
4 21 |     pub fn add(self, other: T) -> T { self }
5    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6    |
7    = note: `-D clippy::should-implement-trait` implied by `-D warnings`
8
9 error: methods called `into_*` usually take self by value; consider choosing a less ambiguous name
10   --> $DIR/methods.rs:32:17
11    |
12 32 |     fn into_u16(&self) -> u16 { 0 }
13    |                 ^^^^^
14    |
15    = note: `-D clippy::wrong-self-convention` implied by `-D warnings`
16
17 error: methods called `to_*` usually take self by reference; consider choosing a less ambiguous name
18   --> $DIR/methods.rs:34:21
19    |
20 34 |     fn to_something(self) -> u32 { 0 }
21    |                     ^^^^
22
23 error: methods called `new` usually take no self; consider choosing a less ambiguous name
24   --> $DIR/methods.rs:36:12
25    |
26 36 |     fn new(self) {}
27    |            ^^^^
28
29 error: methods called `new` usually return `Self`
30   --> $DIR/methods.rs:36:5
31    |
32 36 |     fn new(self) {}
33    |     ^^^^^^^^^^^^^^^
34    |
35    = note: `-D clippy::new-ret-no-self` implied by `-D warnings`
36
37 error: called `map(f).unwrap_or(a)` on an Option value. This can be done more directly by calling `map_or(a, f)` instead
38    --> $DIR/methods.rs:104:13
39     |
40 104 |       let _ = opt.map(|x| x + 1)
41     |  _____________^
42 105 | |
43 106 | |                .unwrap_or(0); // should lint even though this call is on a separate line
44     | |____________________________^
45     |
46     = note: `-D clippy::option-map-unwrap-or` implied by `-D warnings`
47     = note: replace `map(|x| x + 1).unwrap_or(0)` with `map_or(0, |x| x + 1)`
48
49 error: called `map(f).unwrap_or(a)` on an Option value. This can be done more directly by calling `map_or(a, f)` instead
50    --> $DIR/methods.rs:108:13
51     |
52 108 |       let _ = opt.map(|x| {
53     |  _____________^
54 109 | |                         x + 1
55 110 | |                     }
56 111 | |               ).unwrap_or(0);
57     | |____________________________^
58
59 error: called `map(f).unwrap_or(a)` on an Option value. This can be done more directly by calling `map_or(a, f)` instead
60    --> $DIR/methods.rs:112:13
61     |
62 112 |       let _ = opt.map(|x| x + 1)
63     |  _____________^
64 113 | |                .unwrap_or({
65 114 | |                     0
66 115 | |                 });
67     | |__________________^
68
69 error: called `map(f).unwrap_or(None)` on an Option value. This can be done more directly by calling `and_then(f)` instead
70    --> $DIR/methods.rs:117:13
71     |
72 117 |     let _ = opt.map(|x| Some(x + 1)).unwrap_or(None);
73     |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
74     |
75     = note: replace `map(|x| Some(x + 1)).unwrap_or(None)` with `and_then(|x| Some(x + 1))`
76
77 error: called `map(f).unwrap_or(None)` on an Option value. This can be done more directly by calling `and_then(f)` instead
78    --> $DIR/methods.rs:119:13
79     |
80 119 |       let _ = opt.map(|x| {
81     |  _____________^
82 120 | |         Some(x + 1)
83 121 | |     }
84 122 | |     ).unwrap_or(None);
85     | |_____________________^
86
87 error: called `map(f).unwrap_or(None)` on an Option value. This can be done more directly by calling `and_then(f)` instead
88    --> $DIR/methods.rs:123:13
89     |
90 123 |       let _ = opt
91     |  _____________^
92 124 | |         .map(|x| Some(x + 1))
93 125 | |         .unwrap_or(None);
94     | |________________________^
95     |
96     = note: replace `map(|x| Some(x + 1)).unwrap_or(None)` with `and_then(|x| Some(x + 1))`
97
98 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
99    --> $DIR/methods.rs:131:13
100     |
101 131 |       let _ = opt.map(|x| x + 1)
102     |  _____________^
103 132 | |
104 133 | |                .unwrap_or_else(|| 0); // should lint even though this call is on a separate line
105     | |____________________________________^
106     |
107     = note: `-D clippy::option-map-unwrap-or-else` implied by `-D warnings`
108     = note: replace `map(|x| x + 1).unwrap_or_else(|| 0)` with `map_or_else(|| 0, |x| x + 1)`
109
110 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
111    --> $DIR/methods.rs:135:13
112     |
113 135 |       let _ = opt.map(|x| {
114     |  _____________^
115 136 | |                         x + 1
116 137 | |                     }
117 138 | |               ).unwrap_or_else(|| 0);
118     | |____________________________________^
119
120 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
121    --> $DIR/methods.rs:139:13
122     |
123 139 |       let _ = opt.map(|x| x + 1)
124     |  _____________^
125 140 | |                .unwrap_or_else(||
126 141 | |                     0
127 142 | |                 );
128     | |_________________^
129
130 error: called `map_or(None, f)` on an Option value. This can be done more directly by calling `and_then(f)` instead
131    --> $DIR/methods.rs:148:13
132     |
133 148 |     let _ = opt.map_or(None, |x| Some(x + 1));
134     |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using and_then instead: `opt.and_then(|x| Some(x + 1))`
135     |
136     = note: `-D clippy::option-map-or-none` implied by `-D warnings`
137
138 error: called `map_or(None, f)` on an Option value. This can be done more directly by calling `and_then(f)` instead
139    --> $DIR/methods.rs:150:13
140     |
141 150 |       let _ = opt.map_or(None, |x| {
142     |  _____________^
143 151 | |                         Some(x + 1)
144 152 | |                        }
145 153 | |                 );
146     | |_________________^
147 help: try using and_then instead
148     |
149 150 |     let _ = opt.and_then(|x| {
150 151 |                         Some(x + 1)
151 152 |                        });
152     |
153
154 error: called `map(f).unwrap_or_else(g)` on a Result value. This can be done more directly by calling `ok().map_or_else(g, f)` instead
155    --> $DIR/methods.rs:163:13
156     |
157 163 |       let _ = res.map(|x| x + 1)
158     |  _____________^
159 164 | |
160 165 | |                .unwrap_or_else(|e| 0); // should lint even though this call is on a separate line
161     | |_____________________________________^
162     |
163     = note: `-D clippy::result-map-unwrap-or-else` implied by `-D warnings`
164     = note: replace `map(|x| x + 1).unwrap_or_else(|e| 0)` with `ok().map_or_else(|e| 0, |x| x + 1)`
165
166 error: called `map(f).unwrap_or_else(g)` on a Result value. This can be done more directly by calling `ok().map_or_else(g, f)` instead
167    --> $DIR/methods.rs:167:13
168     |
169 167 |       let _ = res.map(|x| {
170     |  _____________^
171 168 | |                         x + 1
172 169 | |                     }
173 170 | |               ).unwrap_or_else(|e| 0);
174     | |_____________________________________^
175
176 error: called `map(f).unwrap_or_else(g)` on a Result value. This can be done more directly by calling `ok().map_or_else(g, f)` instead
177    --> $DIR/methods.rs:171:13
178     |
179 171 |       let _ = res.map(|x| x + 1)
180     |  _____________^
181 172 | |                .unwrap_or_else(|e|
182 173 | |                     0
183 174 | |                 );
184     | |_________________^
185
186 error: called `filter(p).next()` on an `Iterator`. This is more succinctly expressed by calling `.find(p)` instead.
187    --> $DIR/methods.rs:234:13
188     |
189 234 |     let _ = v.iter().filter(|&x| *x < 0).next();
190     |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
191     |
192     = note: `-D clippy::filter-next` implied by `-D warnings`
193     = note: replace `filter(|&x| *x < 0).next()` with `find(|&x| *x < 0)`
194
195 error: called `filter(p).next()` on an `Iterator`. This is more succinctly expressed by calling `.find(p)` instead.
196    --> $DIR/methods.rs:237:13
197     |
198 237 |       let _ = v.iter().filter(|&x| {
199     |  _____________^
200 238 | |                                 *x < 0
201 239 | |                             }
202 240 | |                    ).next();
203     | |___________________________^
204
205 error: called `is_some()` after searching an `Iterator` with find. This is more succinctly expressed by calling `any()`.
206    --> $DIR/methods.rs:252:13
207     |
208 252 |     let _ = v.iter().find(|&x| *x < 0).is_some();
209     |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
210     |
211     = note: `-D clippy::search-is-some` implied by `-D warnings`
212     = note: replace `find(|&x| *x < 0).is_some()` with `any(|&x| *x < 0)`
213
214 error: called `is_some()` after searching an `Iterator` with find. This is more succinctly expressed by calling `any()`.
215    --> $DIR/methods.rs:255:13
216     |
217 255 |       let _ = v.iter().find(|&x| {
218     |  _____________^
219 256 | |                               *x < 0
220 257 | |                           }
221 258 | |                    ).is_some();
222     | |______________________________^
223
224 error: called `is_some()` after searching an `Iterator` with position. This is more succinctly expressed by calling `any()`.
225    --> $DIR/methods.rs:261:13
226     |
227 261 |     let _ = v.iter().position(|&x| x < 0).is_some();
228     |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
229     |
230     = note: replace `position(|&x| x < 0).is_some()` with `any(|&x| x < 0)`
231
232 error: called `is_some()` after searching an `Iterator` with position. This is more succinctly expressed by calling `any()`.
233    --> $DIR/methods.rs:264:13
234     |
235 264 |       let _ = v.iter().position(|&x| {
236     |  _____________^
237 265 | |                                   x < 0
238 266 | |                               }
239 267 | |                    ).is_some();
240     | |______________________________^
241
242 error: called `is_some()` after searching an `Iterator` with rposition. This is more succinctly expressed by calling `any()`.
243    --> $DIR/methods.rs:270:13
244     |
245 270 |     let _ = v.iter().rposition(|&x| x < 0).is_some();
246     |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
247     |
248     = note: replace `rposition(|&x| x < 0).is_some()` with `any(|&x| x < 0)`
249
250 error: called `is_some()` after searching an `Iterator` with rposition. This is more succinctly expressed by calling `any()`.
251    --> $DIR/methods.rs:273:13
252     |
253 273 |       let _ = v.iter().rposition(|&x| {
254     |  _____________^
255 274 | |                                    x < 0
256 275 | |                                }
257 276 | |                    ).is_some();
258     | |______________________________^
259
260 error: use of `unwrap_or` followed by a function call
261    --> $DIR/methods.rs:308:22
262     |
263 308 |     with_constructor.unwrap_or(make());
264     |                      ^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(make)`
265     |
266     = note: `-D clippy::or-fun-call` implied by `-D warnings`
267
268 error: use of `unwrap_or` followed by a call to `new`
269    --> $DIR/methods.rs:311:5
270     |
271 311 |     with_new.unwrap_or(Vec::new());
272     |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `with_new.unwrap_or_default()`
273
274 error: use of `unwrap_or` followed by a function call
275    --> $DIR/methods.rs:314:21
276     |
277 314 |     with_const_args.unwrap_or(Vec::with_capacity(12));
278     |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| Vec::with_capacity(12))`
279
280 error: use of `unwrap_or` followed by a function call
281    --> $DIR/methods.rs:317:14
282     |
283 317 |     with_err.unwrap_or(make());
284     |              ^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|_| make())`
285
286 error: use of `unwrap_or` followed by a function call
287    --> $DIR/methods.rs:320:19
288     |
289 320 |     with_err_args.unwrap_or(Vec::with_capacity(12));
290     |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|_| Vec::with_capacity(12))`
291
292 error: use of `unwrap_or` followed by a call to `default`
293    --> $DIR/methods.rs:323:5
294     |
295 323 |     with_default_trait.unwrap_or(Default::default());
296     |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `with_default_trait.unwrap_or_default()`
297
298 error: use of `unwrap_or` followed by a call to `default`
299    --> $DIR/methods.rs:326:5
300     |
301 326 |     with_default_type.unwrap_or(u64::default());
302     |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `with_default_type.unwrap_or_default()`
303
304 error: use of `unwrap_or` followed by a function call
305    --> $DIR/methods.rs:329:14
306     |
307 329 |     with_vec.unwrap_or(vec![]);
308     |              ^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| < [ _ ] > :: into_vec ( box [ $ ( $ x ) , * ] ))`
309
310 error: use of `unwrap_or` followed by a function call
311    --> $DIR/methods.rs:334:21
312     |
313 334 |     without_default.unwrap_or(Foo::new());
314     |                     ^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(Foo::new)`
315
316 error: use of `or_insert` followed by a function call
317    --> $DIR/methods.rs:337:19
318     |
319 337 |     map.entry(42).or_insert(String::new());
320     |                   ^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `or_insert_with(String::new)`
321
322 error: use of `or_insert` followed by a function call
323    --> $DIR/methods.rs:340:21
324     |
325 340 |     btree.entry(42).or_insert(String::new());
326     |                     ^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `or_insert_with(String::new)`
327
328 error: use of `unwrap_or` followed by a function call
329    --> $DIR/methods.rs:343:21
330     |
331 343 |     let _ = stringy.unwrap_or("".to_owned());
332     |                     ^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| "".to_owned())`
333
334 error: `error_code` is shadowed by `123_i32`
335    --> $DIR/methods.rs:377:9
336     |
337 377 |     let error_code = 123_i32;
338     |         ^^^^^^^^^^
339     |
340     = note: `-D clippy::shadow-unrelated` implied by `-D warnings`
341 note: initialization happens here
342    --> $DIR/methods.rs:377:22
343     |
344 377 |     let error_code = 123_i32;
345     |                      ^^^^^^^
346 note: previous binding is here
347    --> $DIR/methods.rs:364:9
348     |
349 364 |     let error_code = 123_i32;
350     |         ^^^^^^^^^^
351
352 error: use of `expect` followed by a function call
353    --> $DIR/methods.rs:366:26
354     |
355 366 |     with_none_and_format.expect(&format!("Error {}: fake error", error_code));
356     |                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| panic!("Error {}: fake error", error_code))`
357     |
358     = note: `-D clippy::expect-fun-call` implied by `-D warnings`
359
360 error: use of `expect` followed by a function call
361    --> $DIR/methods.rs:369:26
362     |
363 369 |     with_none_and_as_str.expect(format!("Error {}: fake error", error_code).as_str());
364     |                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| panic!(format!("Error {}: fake error", error_code).as_str()))`
365
366 error: use of `expect` followed by a function call
367    --> $DIR/methods.rs:379:25
368     |
369 379 |     with_err_and_format.expect(&format!("Error {}: fake error", error_code));
370     |                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|_| panic!("Error {}: fake error", error_code))`
371
372 error: use of `expect` followed by a function call
373    --> $DIR/methods.rs:382:25
374     |
375 382 |     with_err_and_as_str.expect(format!("Error {}: fake error", error_code).as_str());
376     |                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|_| panic!(format!("Error {}: fake error", error_code).as_str()))`
377
378 error: called `.iter().nth()` on a Vec. Calling `.get()` is both faster and more readable
379    --> $DIR/methods.rs:406:23
380     |
381 406 |         let bad_vec = some_vec.iter().nth(3);
382     |                       ^^^^^^^^^^^^^^^^^^^^^^
383     |
384     = note: `-D clippy::iter-nth` implied by `-D warnings`
385
386 error: called `.iter().nth()` on a slice. Calling `.get()` is both faster and more readable
387    --> $DIR/methods.rs:407:26
388     |
389 407 |         let bad_slice = &some_vec[..].iter().nth(3);
390     |                          ^^^^^^^^^^^^^^^^^^^^^^^^^^
391
392 error: called `.iter().nth()` on a slice. Calling `.get()` is both faster and more readable
393    --> $DIR/methods.rs:408:31
394     |
395 408 |         let bad_boxed_slice = boxed_slice.iter().nth(3);
396     |                               ^^^^^^^^^^^^^^^^^^^^^^^^^
397
398 error: called `.iter().nth()` on a VecDeque. Calling `.get()` is both faster and more readable
399    --> $DIR/methods.rs:409:29
400     |
401 409 |         let bad_vec_deque = some_vec_deque.iter().nth(3);
402     |                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
403
404 error: called `.iter_mut().nth()` on a Vec. Calling `.get_mut()` is both faster and more readable
405    --> $DIR/methods.rs:414:23
406     |
407 414 |         let bad_vec = some_vec.iter_mut().nth(3);
408     |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^
409
410 error: called `.iter_mut().nth()` on a slice. Calling `.get_mut()` is both faster and more readable
411    --> $DIR/methods.rs:417:26
412     |
413 417 |         let bad_slice = &some_vec[..].iter_mut().nth(3);
414     |                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
415
416 error: called `.iter_mut().nth()` on a VecDeque. Calling `.get_mut()` is both faster and more readable
417    --> $DIR/methods.rs:420:29
418     |
419 420 |         let bad_vec_deque = some_vec_deque.iter_mut().nth(3);
420     |                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
421
422 error: called `skip(x).next()` on an iterator. This is more succinctly expressed by calling `nth(x)`
423    --> $DIR/methods.rs:432:13
424     |
425 432 |     let _ = some_vec.iter().skip(42).next();
426     |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
427     |
428     = note: `-D clippy::iter-skip-next` implied by `-D warnings`
429
430 error: called `skip(x).next()` on an iterator. This is more succinctly expressed by calling `nth(x)`
431    --> $DIR/methods.rs:433:13
432     |
433 433 |     let _ = some_vec.iter().cycle().skip(42).next();
434     |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
435
436 error: called `skip(x).next()` on an iterator. This is more succinctly expressed by calling `nth(x)`
437    --> $DIR/methods.rs:434:13
438     |
439 434 |     let _ = (1..10).skip(10).next();
440     |             ^^^^^^^^^^^^^^^^^^^^^^^
441
442 error: called `skip(x).next()` on an iterator. This is more succinctly expressed by calling `nth(x)`
443    --> $DIR/methods.rs:435:14
444     |
445 435 |     let _ = &some_vec[..].iter().skip(3).next();
446     |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
447
448 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
449    --> $DIR/methods.rs:444:13
450     |
451 444 |     let _ = opt.unwrap();
452     |             ^^^^^^^^^^^^
453     |
454     = note: `-D clippy::option-unwrap-used` implied by `-D warnings`
455
456 error: aborting due to 56 previous errors
457