]> git.lizzy.rs Git - rust.git/blob - tests/ui/methods.stderr
Merge pull request #2984 from flip1995/single_char_pattern
[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 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 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 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 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 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 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 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 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 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 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: use of `expect` followed by a function call
335    --> $DIR/methods.rs:366:26
336     |
337 366 |     with_none_and_format.expect(&format!("Error {}: fake error", error_code));
338     |                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| panic!("Error {}: fake error", error_code))`
339     |
340     = note: `-D expect-fun-call` implied by `-D warnings`
341
342 error: use of `expect` followed by a function call
343    --> $DIR/methods.rs:369:26
344     |
345 369 |     with_none_and_as_str.expect(format!("Error {}: fake error", error_code).as_str());
346     |                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| panic!(format!("Error {}: fake error", error_code).as_str()))`
347
348 error: use of `expect` followed by a function call
349    --> $DIR/methods.rs:379:25
350     |
351 379 |     with_err_and_format.expect(&format!("Error {}: fake error", error_code));
352     |                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|_| panic!("Error {}: fake error", error_code))`
353
354 error: use of `expect` followed by a function call
355    --> $DIR/methods.rs:382:25
356     |
357 382 |     with_err_and_as_str.expect(format!("Error {}: fake error", error_code).as_str());
358     |                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|_| panic!(format!("Error {}: fake error", error_code).as_str()))`
359
360 error: called `.iter().nth()` on a Vec. Calling `.get()` is both faster and more readable
361    --> $DIR/methods.rs:402:23
362     |
363 402 |         let bad_vec = some_vec.iter().nth(3);
364     |                       ^^^^^^^^^^^^^^^^^^^^^^
365     |
366     = note: `-D iter-nth` implied by `-D warnings`
367
368 error: called `.iter().nth()` on a slice. Calling `.get()` is both faster and more readable
369    --> $DIR/methods.rs:403:26
370     |
371 403 |         let bad_slice = &some_vec[..].iter().nth(3);
372     |                          ^^^^^^^^^^^^^^^^^^^^^^^^^^
373
374 error: called `.iter().nth()` on a slice. Calling `.get()` is both faster and more readable
375    --> $DIR/methods.rs:404:31
376     |
377 404 |         let bad_boxed_slice = boxed_slice.iter().nth(3);
378     |                               ^^^^^^^^^^^^^^^^^^^^^^^^^
379
380 error: called `.iter().nth()` on a VecDeque. Calling `.get()` is both faster and more readable
381    --> $DIR/methods.rs:405:29
382     |
383 405 |         let bad_vec_deque = some_vec_deque.iter().nth(3);
384     |                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
385
386 error: called `.iter_mut().nth()` on a Vec. Calling `.get_mut()` is both faster and more readable
387    --> $DIR/methods.rs:410:23
388     |
389 410 |         let bad_vec = some_vec.iter_mut().nth(3);
390     |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^
391
392 error: called `.iter_mut().nth()` on a slice. Calling `.get_mut()` is both faster and more readable
393    --> $DIR/methods.rs:413:26
394     |
395 413 |         let bad_slice = &some_vec[..].iter_mut().nth(3);
396     |                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
397
398 error: called `.iter_mut().nth()` on a VecDeque. Calling `.get_mut()` is both faster and more readable
399    --> $DIR/methods.rs:416:29
400     |
401 416 |         let bad_vec_deque = some_vec_deque.iter_mut().nth(3);
402     |                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
403
404 error: called `skip(x).next()` on an iterator. This is more succinctly expressed by calling `nth(x)`
405    --> $DIR/methods.rs:428:13
406     |
407 428 |     let _ = some_vec.iter().skip(42).next();
408     |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
409     |
410     = note: `-D iter-skip-next` implied by `-D warnings`
411
412 error: called `skip(x).next()` on an iterator. This is more succinctly expressed by calling `nth(x)`
413    --> $DIR/methods.rs:429:13
414     |
415 429 |     let _ = some_vec.iter().cycle().skip(42).next();
416     |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
417
418 error: called `skip(x).next()` on an iterator. This is more succinctly expressed by calling `nth(x)`
419    --> $DIR/methods.rs:430:13
420     |
421 430 |     let _ = (1..10).skip(10).next();
422     |             ^^^^^^^^^^^^^^^^^^^^^^^
423
424 error: called `skip(x).next()` on an iterator. This is more succinctly expressed by calling `nth(x)`
425    --> $DIR/methods.rs:431:14
426     |
427 431 |     let _ = &some_vec[..].iter().skip(3).next();
428     |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
429
430 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
431    --> $DIR/methods.rs:440:13
432     |
433 440 |     let _ = opt.unwrap();
434     |             ^^^^^^^^^^^^
435     |
436     = note: `-D option-unwrap-used` implied by `-D warnings`
437
438 error: aborting due to 55 previous errors
439