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
4 21 | pub fn add(self, other: T) -> T { self }
5 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
7 = note: `-D clippy::should-implement-trait` implied by `-D warnings`
9 error: methods called `into_*` usually take self by value; consider choosing a less ambiguous name
10 --> $DIR/methods.rs:32:17
12 32 | fn into_u16(&self) -> u16 { 0 }
15 = note: `-D clippy::wrong-self-convention` implied by `-D warnings`
17 error: methods called `to_*` usually take self by reference; consider choosing a less ambiguous name
18 --> $DIR/methods.rs:34:21
20 34 | fn to_something(self) -> u32 { 0 }
23 error: methods called `new` usually take no self; consider choosing a less ambiguous name
24 --> $DIR/methods.rs:36:12
29 error: methods called `new` usually return `Self`
30 --> $DIR/methods.rs:36:5
35 = note: `-D clippy::new-ret-no-self` implied by `-D warnings`
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
40 104 | let _ = opt.map(|x| x + 1)
43 106 | | .unwrap_or(0); // should lint even though this call is on a separate line
44 | |____________________________^
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)`
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
52 108 | let _ = opt.map(|x| {
56 111 | | ).unwrap_or(0);
57 | |____________________________^
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
62 112 | let _ = opt.map(|x| x + 1)
67 | |__________________^
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
72 117 | let _ = opt.map(|x| Some(x + 1)).unwrap_or(None);
73 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
75 = note: replace `map(|x| Some(x + 1)).unwrap_or(None)` with `and_then(|x| Some(x + 1))`
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
80 119 | let _ = opt.map(|x| {
84 122 | | ).unwrap_or(None);
85 | |_____________________^
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
92 124 | | .map(|x| Some(x + 1))
93 125 | | .unwrap_or(None);
94 | |________________________^
96 = note: replace `map(|x| Some(x + 1)).unwrap_or(None)` with `and_then(|x| Some(x + 1))`
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
101 131 | let _ = opt.map(|x| x + 1)
104 133 | | .unwrap_or_else(|| 0); // should lint even though this call is on a separate line
105 | |____________________________________^
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)`
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
113 135 | let _ = opt.map(|x| {
117 138 | | ).unwrap_or_else(|| 0);
118 | |____________________________________^
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
123 139 | let _ = opt.map(|x| x + 1)
125 140 | | .unwrap_or_else(||
128 | |_________________^
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
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))`
136 = note: `-D clippy::option-map-or-none` implied by `-D warnings`
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
141 150 | let _ = opt.map_or(None, |x| {
146 | |_________________^
147 help: try using and_then instead
149 150 | let _ = opt.and_then(|x| {
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
157 163 | let _ = res.map(|x| x + 1)
160 165 | | .unwrap_or_else(|e| 0); // should lint even though this call is on a separate line
161 | |_____________________________________^
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)`
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
169 167 | let _ = res.map(|x| {
173 170 | | ).unwrap_or_else(|e| 0);
174 | |_____________________________________^
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
179 171 | let _ = res.map(|x| x + 1)
181 172 | | .unwrap_or_else(|e|
184 | |_________________^
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
189 234 | let _ = v.iter().filter(|&x| *x < 0).next();
190 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
192 = note: `-D clippy::filter-next` implied by `-D warnings`
193 = note: replace `filter(|&x| *x < 0).next()` with `find(|&x| *x < 0)`
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
198 237 | let _ = v.iter().filter(|&x| {
203 | |___________________________^
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
208 252 | let _ = v.iter().find(|&x| *x < 0).is_some();
209 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
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)`
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
217 255 | let _ = v.iter().find(|&x| {
222 | |______________________________^
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
227 261 | let _ = v.iter().position(|&x| x < 0).is_some();
228 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
230 = note: replace `position(|&x| x < 0).is_some()` with `any(|&x| x < 0)`
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
235 264 | let _ = v.iter().position(|&x| {
240 | |______________________________^
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
245 270 | let _ = v.iter().rposition(|&x| x < 0).is_some();
246 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
248 = note: replace `rposition(|&x| x < 0).is_some()` with `any(|&x| x < 0)`
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
253 273 | let _ = v.iter().rposition(|&x| {
258 | |______________________________^
260 error: use of `unwrap_or` followed by a function call
261 --> $DIR/methods.rs:308:22
263 308 | with_constructor.unwrap_or(make());
264 | ^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(make)`
266 = note: `-D clippy::or-fun-call` implied by `-D warnings`
268 error: use of `unwrap_or` followed by a call to `new`
269 --> $DIR/methods.rs:311:5
271 311 | with_new.unwrap_or(Vec::new());
272 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `with_new.unwrap_or_default()`
274 error: use of `unwrap_or` followed by a function call
275 --> $DIR/methods.rs:314:21
277 314 | with_const_args.unwrap_or(Vec::with_capacity(12));
278 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| Vec::with_capacity(12))`
280 error: use of `unwrap_or` followed by a function call
281 --> $DIR/methods.rs:317:14
283 317 | with_err.unwrap_or(make());
284 | ^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|_| make())`
286 error: use of `unwrap_or` followed by a function call
287 --> $DIR/methods.rs:320:19
289 320 | with_err_args.unwrap_or(Vec::with_capacity(12));
290 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|_| Vec::with_capacity(12))`
292 error: use of `unwrap_or` followed by a call to `default`
293 --> $DIR/methods.rs:323:5
295 323 | with_default_trait.unwrap_or(Default::default());
296 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `with_default_trait.unwrap_or_default()`
298 error: use of `unwrap_or` followed by a call to `default`
299 --> $DIR/methods.rs:326:5
301 326 | with_default_type.unwrap_or(u64::default());
302 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `with_default_type.unwrap_or_default()`
304 error: use of `unwrap_or` followed by a function call
305 --> $DIR/methods.rs:329:14
307 329 | with_vec.unwrap_or(vec![]);
308 | ^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| < [ _ ] > :: into_vec ( box [ $ ( $ x ) , * ] ))`
310 error: use of `unwrap_or` followed by a function call
311 --> $DIR/methods.rs:334:21
313 334 | without_default.unwrap_or(Foo::new());
314 | ^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(Foo::new)`
316 error: use of `or_insert` followed by a function call
317 --> $DIR/methods.rs:337:19
319 337 | map.entry(42).or_insert(String::new());
320 | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `or_insert_with(String::new)`
322 error: use of `or_insert` followed by a function call
323 --> $DIR/methods.rs:340:21
325 340 | btree.entry(42).or_insert(String::new());
326 | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `or_insert_with(String::new)`
328 error: use of `unwrap_or` followed by a function call
329 --> $DIR/methods.rs:343:21
331 343 | let _ = stringy.unwrap_or("".to_owned());
332 | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| "".to_owned())`
334 error: `error_code` is shadowed by `123_i32`
335 --> $DIR/methods.rs:377:9
337 377 | let error_code = 123_i32;
340 = note: `-D clippy::shadow-unrelated` implied by `-D warnings`
341 note: initialization happens here
342 --> $DIR/methods.rs:377:22
344 377 | let error_code = 123_i32;
346 note: previous binding is here
347 --> $DIR/methods.rs:364:9
349 364 | let error_code = 123_i32;
352 error: use of `expect` followed by a function call
353 --> $DIR/methods.rs:366:26
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))`
358 = note: `-D clippy::expect-fun-call` implied by `-D warnings`
360 error: use of `expect` followed by a function call
361 --> $DIR/methods.rs:369:26
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()))`
366 error: use of `expect` followed by a function call
367 --> $DIR/methods.rs:379:25
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))`
372 error: use of `expect` followed by a function call
373 --> $DIR/methods.rs:382:25
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()))`
378 error: called `.iter().nth()` on a Vec. Calling `.get()` is both faster and more readable
379 --> $DIR/methods.rs:406:23
381 406 | let bad_vec = some_vec.iter().nth(3);
382 | ^^^^^^^^^^^^^^^^^^^^^^
384 = note: `-D clippy::iter-nth` implied by `-D warnings`
386 error: called `.iter().nth()` on a slice. Calling `.get()` is both faster and more readable
387 --> $DIR/methods.rs:407:26
389 407 | let bad_slice = &some_vec[..].iter().nth(3);
390 | ^^^^^^^^^^^^^^^^^^^^^^^^^^
392 error: called `.iter().nth()` on a slice. Calling `.get()` is both faster and more readable
393 --> $DIR/methods.rs:408:31
395 408 | let bad_boxed_slice = boxed_slice.iter().nth(3);
396 | ^^^^^^^^^^^^^^^^^^^^^^^^^
398 error: called `.iter().nth()` on a VecDeque. Calling `.get()` is both faster and more readable
399 --> $DIR/methods.rs:409:29
401 409 | let bad_vec_deque = some_vec_deque.iter().nth(3);
402 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
404 error: called `.iter_mut().nth()` on a Vec. Calling `.get_mut()` is both faster and more readable
405 --> $DIR/methods.rs:414:23
407 414 | let bad_vec = some_vec.iter_mut().nth(3);
408 | ^^^^^^^^^^^^^^^^^^^^^^^^^^
410 error: called `.iter_mut().nth()` on a slice. Calling `.get_mut()` is both faster and more readable
411 --> $DIR/methods.rs:417:26
413 417 | let bad_slice = &some_vec[..].iter_mut().nth(3);
414 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
416 error: called `.iter_mut().nth()` on a VecDeque. Calling `.get_mut()` is both faster and more readable
417 --> $DIR/methods.rs:420:29
419 420 | let bad_vec_deque = some_vec_deque.iter_mut().nth(3);
420 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
422 error: called `skip(x).next()` on an iterator. This is more succinctly expressed by calling `nth(x)`
423 --> $DIR/methods.rs:432:13
425 432 | let _ = some_vec.iter().skip(42).next();
426 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
428 = note: `-D clippy::iter-skip-next` implied by `-D warnings`
430 error: called `skip(x).next()` on an iterator. This is more succinctly expressed by calling `nth(x)`
431 --> $DIR/methods.rs:433:13
433 433 | let _ = some_vec.iter().cycle().skip(42).next();
434 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
436 error: called `skip(x).next()` on an iterator. This is more succinctly expressed by calling `nth(x)`
437 --> $DIR/methods.rs:434:13
439 434 | let _ = (1..10).skip(10).next();
440 | ^^^^^^^^^^^^^^^^^^^^^^^
442 error: called `skip(x).next()` on an iterator. This is more succinctly expressed by calling `nth(x)`
443 --> $DIR/methods.rs:435:14
445 435 | let _ = &some_vec[..].iter().skip(3).next();
446 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
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
451 444 | let _ = opt.unwrap();
454 = note: `-D clippy::option-unwrap-used` implied by `-D warnings`
456 error: aborting due to 56 previous errors