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:38:5
4 38 | 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:49:17
12 49 | 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:51:21
20 51 | 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:53:12
26 53 | fn new(self) -> Self { unimplemented!(); }
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:121:13
32 121 | let _ = opt.map(|x| x + 1)
35 123 | | .unwrap_or(0); // should lint even though this call is on a separate line
36 | |____________________________^
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)`
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:125:13
44 125 | let _ = opt.map(|x| {
48 128 | | ).unwrap_or(0);
49 | |____________________________^
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:129:13
54 129 | let _ = opt.map(|x| x + 1)
59 | |__________________^
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:134:13
64 134 | let _ = opt.map(|x| Some(x + 1)).unwrap_or(None);
65 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
67 = note: replace `map(|x| Some(x + 1)).unwrap_or(None)` with `and_then(|x| Some(x + 1))`
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:136:13
72 136 | let _ = opt.map(|x| {
76 139 | | ).unwrap_or(None);
77 | |_____________________^
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:140:13
84 141 | | .map(|x| Some(x + 1))
85 142 | | .unwrap_or(None);
86 | |________________________^
88 = note: replace `map(|x| Some(x + 1)).unwrap_or(None)` with `and_then(|x| Some(x + 1))`
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:148:13
93 148 | let _ = opt.map(|x| x + 1)
96 150 | | .unwrap_or_else(|| 0); // should lint even though this call is on a separate line
97 | |____________________________________^
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)`
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:152:13
105 152 | let _ = opt.map(|x| {
109 155 | | ).unwrap_or_else(|| 0);
110 | |____________________________________^
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:156:13
115 156 | let _ = opt.map(|x| x + 1)
117 157 | | .unwrap_or_else(||
120 | |_________________^
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:165:13
125 165 | let _ = opt.map_or(None, |x| Some(x + 1));
126 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using and_then instead: `opt.and_then(|x| Some(x + 1))`
128 = note: `-D clippy::option-map-or-none` implied by `-D warnings`
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:167:13
133 167 | let _ = opt.map_or(None, |x| {
138 | |_________________^
139 help: try using and_then instead
141 167 | let _ = opt.and_then(|x| {
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:180:13
149 180 | let _ = res.map(|x| x + 1)
152 182 | | .unwrap_or_else(|e| 0); // should lint even though this call is on a separate line
153 | |_____________________________________^
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)`
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:184:13
161 184 | let _ = res.map(|x| {
165 187 | | ).unwrap_or_else(|e| 0);
166 | |_____________________________________^
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:188:13
171 188 | let _ = res.map(|x| x + 1)
173 189 | | .unwrap_or_else(|e|
176 | |_________________^
178 error: called `filter(p).next()` on an `Iterator`. This is more succinctly expressed by calling `.find(p)` instead.
179 --> $DIR/methods.rs:251:13
181 251 | let _ = v.iter().filter(|&x| *x < 0).next();
182 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
184 = note: `-D clippy::filter-next` implied by `-D warnings`
185 = note: replace `filter(|&x| *x < 0).next()` with `find(|&x| *x < 0)`
187 error: called `filter(p).next()` on an `Iterator`. This is more succinctly expressed by calling `.find(p)` instead.
188 --> $DIR/methods.rs:254:13
190 254 | let _ = v.iter().filter(|&x| {
195 | |___________________________^
197 error: called `is_some()` after searching an `Iterator` with find. This is more succinctly expressed by calling `any()`.
198 --> $DIR/methods.rs:269:13
200 269 | let _ = v.iter().find(|&x| *x < 0).is_some();
201 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
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)`
206 error: called `is_some()` after searching an `Iterator` with find. This is more succinctly expressed by calling `any()`.
207 --> $DIR/methods.rs:272:13
209 272 | let _ = v.iter().find(|&x| {
214 | |______________________________^
216 error: called `is_some()` after searching an `Iterator` with position. This is more succinctly expressed by calling `any()`.
217 --> $DIR/methods.rs:278:13
219 278 | let _ = v.iter().position(|&x| x < 0).is_some();
220 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
222 = note: replace `position(|&x| x < 0).is_some()` with `any(|&x| x < 0)`
224 error: called `is_some()` after searching an `Iterator` with position. This is more succinctly expressed by calling `any()`.
225 --> $DIR/methods.rs:281:13
227 281 | let _ = v.iter().position(|&x| {
232 | |______________________________^
234 error: called `is_some()` after searching an `Iterator` with rposition. This is more succinctly expressed by calling `any()`.
235 --> $DIR/methods.rs:287:13
237 287 | let _ = v.iter().rposition(|&x| x < 0).is_some();
238 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
240 = note: replace `rposition(|&x| x < 0).is_some()` with `any(|&x| x < 0)`
242 error: called `is_some()` after searching an `Iterator` with rposition. This is more succinctly expressed by calling `any()`.
243 --> $DIR/methods.rs:290:13
245 290 | let _ = v.iter().rposition(|&x| {
250 | |______________________________^
252 error: use of `unwrap_or` followed by a function call
253 --> $DIR/methods.rs:325:22
255 325 | with_constructor.unwrap_or(make());
256 | ^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(make)`
258 = note: `-D clippy::or-fun-call` implied by `-D warnings`
260 error: use of `unwrap_or` followed by a call to `new`
261 --> $DIR/methods.rs:328:5
263 328 | with_new.unwrap_or(Vec::new());
264 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `with_new.unwrap_or_default()`
266 error: use of `unwrap_or` followed by a function call
267 --> $DIR/methods.rs:331:21
269 331 | with_const_args.unwrap_or(Vec::with_capacity(12));
270 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| Vec::with_capacity(12))`
272 error: use of `unwrap_or` followed by a function call
273 --> $DIR/methods.rs:334:14
275 334 | with_err.unwrap_or(make());
276 | ^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|_| make())`
278 error: use of `unwrap_or` followed by a function call
279 --> $DIR/methods.rs:337:19
281 337 | with_err_args.unwrap_or(Vec::with_capacity(12));
282 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|_| Vec::with_capacity(12))`
284 error: use of `unwrap_or` followed by a call to `default`
285 --> $DIR/methods.rs:340:5
287 340 | with_default_trait.unwrap_or(Default::default());
288 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `with_default_trait.unwrap_or_default()`
290 error: use of `unwrap_or` followed by a call to `default`
291 --> $DIR/methods.rs:343:5
293 343 | with_default_type.unwrap_or(u64::default());
294 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `with_default_type.unwrap_or_default()`
296 error: use of `unwrap_or` followed by a function call
297 --> $DIR/methods.rs:346:14
299 346 | with_vec.unwrap_or(vec![]);
300 | ^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| vec![])`
302 error: use of `unwrap_or` followed by a function call
303 --> $DIR/methods.rs:351:21
305 351 | without_default.unwrap_or(Foo::new());
306 | ^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(Foo::new)`
308 error: use of `or_insert` followed by a function call
309 --> $DIR/methods.rs:354:19
311 354 | map.entry(42).or_insert(String::new());
312 | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `or_insert_with(String::new)`
314 error: use of `or_insert` followed by a function call
315 --> $DIR/methods.rs:357:21
317 357 | btree.entry(42).or_insert(String::new());
318 | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `or_insert_with(String::new)`
320 error: use of `unwrap_or` followed by a function call
321 --> $DIR/methods.rs:360:21
323 360 | let _ = stringy.unwrap_or("".to_owned());
324 | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| "".to_owned())`
326 error: called `.iter().nth()` on a Vec. Calling `.get()` is both faster and more readable
327 --> $DIR/methods.rs:371:23
329 371 | let bad_vec = some_vec.iter().nth(3);
330 | ^^^^^^^^^^^^^^^^^^^^^^
332 = note: `-D clippy::iter-nth` implied by `-D warnings`
334 error: called `.iter().nth()` on a slice. Calling `.get()` is both faster and more readable
335 --> $DIR/methods.rs:372:26
337 372 | let bad_slice = &some_vec[..].iter().nth(3);
338 | ^^^^^^^^^^^^^^^^^^^^^^^^^^
340 error: called `.iter().nth()` on a slice. Calling `.get()` is both faster and more readable
341 --> $DIR/methods.rs:373:31
343 373 | let bad_boxed_slice = boxed_slice.iter().nth(3);
344 | ^^^^^^^^^^^^^^^^^^^^^^^^^
346 error: called `.iter().nth()` on a VecDeque. Calling `.get()` is both faster and more readable
347 --> $DIR/methods.rs:374:29
349 374 | let bad_vec_deque = some_vec_deque.iter().nth(3);
350 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
352 error: called `.iter_mut().nth()` on a Vec. Calling `.get_mut()` is both faster and more readable
353 --> $DIR/methods.rs:379:23
355 379 | let bad_vec = some_vec.iter_mut().nth(3);
356 | ^^^^^^^^^^^^^^^^^^^^^^^^^^
358 error: called `.iter_mut().nth()` on a slice. Calling `.get_mut()` is both faster and more readable
359 --> $DIR/methods.rs:382:26
361 382 | let bad_slice = &some_vec[..].iter_mut().nth(3);
362 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
364 error: called `.iter_mut().nth()` on a VecDeque. Calling `.get_mut()` is both faster and more readable
365 --> $DIR/methods.rs:385:29
367 385 | let bad_vec_deque = some_vec_deque.iter_mut().nth(3);
368 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
370 error: called `skip(x).next()` on an iterator. This is more succinctly expressed by calling `nth(x)`
371 --> $DIR/methods.rs:397:13
373 397 | let _ = some_vec.iter().skip(42).next();
374 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
376 = note: `-D clippy::iter-skip-next` implied by `-D warnings`
378 error: called `skip(x).next()` on an iterator. This is more succinctly expressed by calling `nth(x)`
379 --> $DIR/methods.rs:398:13
381 398 | let _ = some_vec.iter().cycle().skip(42).next();
382 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
384 error: called `skip(x).next()` on an iterator. This is more succinctly expressed by calling `nth(x)`
385 --> $DIR/methods.rs:399:13
387 399 | let _ = (1..10).skip(10).next();
388 | ^^^^^^^^^^^^^^^^^^^^^^^
390 error: called `skip(x).next()` on an iterator. This is more succinctly expressed by calling `nth(x)`
391 --> $DIR/methods.rs:400:14
393 400 | let _ = &some_vec[..].iter().skip(3).next();
394 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
396 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
397 --> $DIR/methods.rs:409:13
399 409 | let _ = opt.unwrap();
402 = note: `-D clippy::option-unwrap-used` implied by `-D warnings`
404 error: aborting due to 50 previous errors