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:44:5
4 LL | 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:55:17
12 LL | 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:57:21
20 LL | 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:59:12
26 LL | 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:120:13
32 LL | let _ = opt.map(|x| x + 1)
35 LL | | .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:124:13
44 LL | let _ = opt.map(|x| {
48 LL | | ).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:128:13
54 LL | 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:133:13
64 LL | 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:135:13
72 LL | let _ = opt.map(|x| {
76 LL | | ).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:139:13
84 LL | | .map(|x| Some(x + 1))
85 LL | | .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:147:13
93 LL | let _ = opt.map(|x| x + 1)
96 LL | | .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:151:13
105 LL | let _ = opt.map(|x| {
109 LL | | ).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:155:13
115 LL | let _ = opt.map(|x| x + 1)
117 LL | | .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:164:13
125 LL | 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:166:13
133 LL | let _ = opt.map_or(None, |x| {
138 | |_________________^
139 help: try using and_then instead
141 LL | let _ = opt.and_then(|x| {
146 error: called `filter(p).next()` on an `Iterator`. This is more succinctly expressed by calling `.find(p)` instead.
147 --> $DIR/methods.rs:191:13
149 LL | let _ = v.iter().filter(|&x| *x < 0).next();
150 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
152 = note: `-D clippy::filter-next` implied by `-D warnings`
153 = note: replace `filter(|&x| *x < 0).next()` with `find(|&x| *x < 0)`
155 error: called `filter(p).next()` on an `Iterator`. This is more succinctly expressed by calling `.find(p)` instead.
156 --> $DIR/methods.rs:194:13
158 LL | let _ = v.iter().filter(|&x| {
163 | |___________________________^
165 error: called `is_some()` after searching an `Iterator` with find. This is more succinctly expressed by calling `any()`.
166 --> $DIR/methods.rs:209:13
168 LL | let _ = v.iter().find(|&x| *x < 0).is_some();
169 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
171 = note: `-D clippy::search-is-some` implied by `-D warnings`
172 = note: replace `find(|&x| *x < 0).is_some()` with `any(|&x| *x < 0)`
174 error: called `is_some()` after searching an `Iterator` with find. This is more succinctly expressed by calling `any()`.
175 --> $DIR/methods.rs:212:13
177 LL | let _ = v.iter().find(|&x| {
182 | |______________________________^
184 error: called `is_some()` after searching an `Iterator` with position. This is more succinctly expressed by calling `any()`.
185 --> $DIR/methods.rs:218:13
187 LL | let _ = v.iter().position(|&x| x < 0).is_some();
188 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
190 = note: replace `position(|&x| x < 0).is_some()` with `any(|&x| x < 0)`
192 error: called `is_some()` after searching an `Iterator` with position. This is more succinctly expressed by calling `any()`.
193 --> $DIR/methods.rs:221:13
195 LL | let _ = v.iter().position(|&x| {
200 | |______________________________^
202 error: called `is_some()` after searching an `Iterator` with rposition. This is more succinctly expressed by calling `any()`.
203 --> $DIR/methods.rs:227:13
205 LL | let _ = v.iter().rposition(|&x| x < 0).is_some();
206 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
208 = note: replace `rposition(|&x| x < 0).is_some()` with `any(|&x| x < 0)`
210 error: called `is_some()` after searching an `Iterator` with rposition. This is more succinctly expressed by calling `any()`.
211 --> $DIR/methods.rs:230:13
213 LL | let _ = v.iter().rposition(|&x| {
218 | |______________________________^
220 error: use of `unwrap_or` followed by a function call
221 --> $DIR/methods.rs:265:22
223 LL | with_constructor.unwrap_or(make());
224 | ^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(make)`
226 = note: `-D clippy::or-fun-call` implied by `-D warnings`
228 error: use of `unwrap_or` followed by a call to `new`
229 --> $DIR/methods.rs:268:5
231 LL | with_new.unwrap_or(Vec::new());
232 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `with_new.unwrap_or_default()`
234 error: use of `unwrap_or` followed by a function call
235 --> $DIR/methods.rs:271:21
237 LL | with_const_args.unwrap_or(Vec::with_capacity(12));
238 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| Vec::with_capacity(12))`
240 error: use of `unwrap_or` followed by a function call
241 --> $DIR/methods.rs:274:14
243 LL | with_err.unwrap_or(make());
244 | ^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|_| make())`
246 error: use of `unwrap_or` followed by a function call
247 --> $DIR/methods.rs:277:19
249 LL | with_err_args.unwrap_or(Vec::with_capacity(12));
250 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|_| Vec::with_capacity(12))`
252 error: use of `unwrap_or` followed by a call to `default`
253 --> $DIR/methods.rs:280:5
255 LL | with_default_trait.unwrap_or(Default::default());
256 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `with_default_trait.unwrap_or_default()`
258 error: use of `unwrap_or` followed by a call to `default`
259 --> $DIR/methods.rs:283:5
261 LL | with_default_type.unwrap_or(u64::default());
262 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `with_default_type.unwrap_or_default()`
264 error: use of `unwrap_or` followed by a function call
265 --> $DIR/methods.rs:286:14
267 LL | with_vec.unwrap_or(vec![]);
268 | ^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| vec![])`
270 error: use of `unwrap_or` followed by a function call
271 --> $DIR/methods.rs:291:21
273 LL | without_default.unwrap_or(Foo::new());
274 | ^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(Foo::new)`
276 error: use of `or_insert` followed by a function call
277 --> $DIR/methods.rs:294:19
279 LL | map.entry(42).or_insert(String::new());
280 | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `or_insert_with(String::new)`
282 error: use of `or_insert` followed by a function call
283 --> $DIR/methods.rs:297:21
285 LL | btree.entry(42).or_insert(String::new());
286 | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `or_insert_with(String::new)`
288 error: use of `unwrap_or` followed by a function call
289 --> $DIR/methods.rs:300:21
291 LL | let _ = stringy.unwrap_or("".to_owned());
292 | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| "".to_owned())`
294 error: called `.iter().nth()` on a Vec. Calling `.get()` is both faster and more readable
295 --> $DIR/methods.rs:311:23
297 LL | let bad_vec = some_vec.iter().nth(3);
298 | ^^^^^^^^^^^^^^^^^^^^^^
300 = note: `-D clippy::iter-nth` implied by `-D warnings`
302 error: called `.iter().nth()` on a slice. Calling `.get()` is both faster and more readable
303 --> $DIR/methods.rs:312:26
305 LL | let bad_slice = &some_vec[..].iter().nth(3);
306 | ^^^^^^^^^^^^^^^^^^^^^^^^^^
308 error: called `.iter().nth()` on a slice. Calling `.get()` is both faster and more readable
309 --> $DIR/methods.rs:313:31
311 LL | let bad_boxed_slice = boxed_slice.iter().nth(3);
312 | ^^^^^^^^^^^^^^^^^^^^^^^^^
314 error: called `.iter().nth()` on a VecDeque. Calling `.get()` is both faster and more readable
315 --> $DIR/methods.rs:314:29
317 LL | let bad_vec_deque = some_vec_deque.iter().nth(3);
318 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
320 error: called `.iter_mut().nth()` on a Vec. Calling `.get_mut()` is both faster and more readable
321 --> $DIR/methods.rs:319:23
323 LL | let bad_vec = some_vec.iter_mut().nth(3);
324 | ^^^^^^^^^^^^^^^^^^^^^^^^^^
326 error: called `.iter_mut().nth()` on a slice. Calling `.get_mut()` is both faster and more readable
327 --> $DIR/methods.rs:322:26
329 LL | let bad_slice = &some_vec[..].iter_mut().nth(3);
330 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
332 error: called `.iter_mut().nth()` on a VecDeque. Calling `.get_mut()` is both faster and more readable
333 --> $DIR/methods.rs:325:29
335 LL | let bad_vec_deque = some_vec_deque.iter_mut().nth(3);
336 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
338 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
339 --> $DIR/methods.rs:337:13
341 LL | let _ = opt.unwrap();
344 = note: `-D clippy::option-unwrap-used` implied by `-D warnings`
346 error: aborting due to 43 previous errors