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