]> git.lizzy.rs Git - rust.git/blob - tests/ui/methods.stderr
Merge branch 'master' into fix-3739
[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:35:5
3    |
4 LL | /     pub fn add(self, other: T) -> T {
5 LL | |         self
6 LL | |     }
7    | |_____^
8    |
9    = note: `-D clippy::should-implement-trait` implied by `-D warnings`
10
11 error: methods called `into_*` usually take self by value; consider choosing a less ambiguous name
12   --> $DIR/methods.rs:70:17
13    |
14 LL |     fn into_u16(&self) -> u16 {
15    |                 ^^^^^
16    |
17    = note: `-D clippy::wrong-self-convention` implied by `-D warnings`
18
19 error: methods called `to_*` usually take self by reference; consider choosing a less ambiguous name
20   --> $DIR/methods.rs:74:21
21    |
22 LL |     fn to_something(self) -> u32 {
23    |                     ^^^^
24
25 error: methods called `new` usually take no self; consider choosing a less ambiguous name
26   --> $DIR/methods.rs:78:12
27    |
28 LL |     fn new(self) -> Self {
29    |            ^^^^
30
31 error: called `map(f).unwrap_or(a)` on an Option value. This can be done more directly by calling `map_or(a, f)` instead
32   --> $DIR/methods.rs:158:13
33    |
34 LL |       let _ = opt.map(|x| x + 1)
35    |  _____________^
36 LL | |                 // Should lint even though this call is on a separate line.
37 LL | |                .unwrap_or(0);
38    | |____________________________^
39    |
40    = note: `-D clippy::option-map-unwrap-or` implied by `-D warnings`
41    = note: replace `map(|x| x + 1).unwrap_or(0)` with `map_or(0, |x| x + 1)`
42
43 error: called `map(f).unwrap_or(a)` on an Option value. This can be done more directly by calling `map_or(a, f)` instead
44   --> $DIR/methods.rs:162:13
45    |
46 LL |       let _ = opt.map(|x| {
47    |  _____________^
48 LL | |                         x + 1
49 LL | |                     }
50 LL | |               ).unwrap_or(0);
51    | |____________________________^
52
53 error: called `map(f).unwrap_or(a)` on an Option value. This can be done more directly by calling `map_or(a, f)` instead
54   --> $DIR/methods.rs:166:13
55    |
56 LL |       let _ = opt.map(|x| x + 1)
57    |  _____________^
58 LL | |                .unwrap_or({
59 LL | |                     0
60 LL | |                 });
61    | |__________________^
62
63 error: called `map(f).unwrap_or(None)` on an Option value. This can be done more directly by calling `and_then(f)` instead
64   --> $DIR/methods.rs:171:13
65    |
66 LL |     let _ = opt.map(|x| Some(x + 1)).unwrap_or(None);
67    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
68    |
69    = note: replace `map(|x| Some(x + 1)).unwrap_or(None)` with `and_then(|x| Some(x + 1))`
70
71 error: called `map(f).unwrap_or(None)` on an Option value. This can be done more directly by calling `and_then(f)` instead
72   --> $DIR/methods.rs:173:13
73    |
74 LL |       let _ = opt.map(|x| {
75    |  _____________^
76 LL | |         Some(x + 1)
77 LL | |     }
78 LL | |     ).unwrap_or(None);
79    | |_____________________^
80
81 error: called `map(f).unwrap_or(None)` on an Option value. This can be done more directly by calling `and_then(f)` instead
82   --> $DIR/methods.rs:177:13
83    |
84 LL |       let _ = opt
85    |  _____________^
86 LL | |         .map(|x| Some(x + 1))
87 LL | |         .unwrap_or(None);
88    | |________________________^
89    |
90    = note: replace `map(|x| Some(x + 1)).unwrap_or(None)` with `and_then(|x| Some(x + 1))`
91
92 error: called `map(f).unwrap_or(a)` on an Option value. This can be done more directly by calling `map_or(a, f)` instead
93   --> $DIR/methods.rs:188:13
94    |
95 LL |     let _ = Some("prefix").map(|p| format!("{}.", p)).unwrap_or(id);
96    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
97    |
98    = note: replace `map(|p| format!("{}.", p)).unwrap_or(id)` with `map_or(id, |p| format!("{}.", p))`
99
100 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
101   --> $DIR/methods.rs:192:13
102    |
103 LL |       let _ = opt.map(|x| x + 1)
104    |  _____________^
105 LL | |                 // Should lint even though this call is on a separate line.
106 LL | |                .unwrap_or_else(|| 0);
107    | |____________________________________^
108    |
109    = note: `-D clippy::option-map-unwrap-or-else` implied by `-D warnings`
110    = note: replace `map(|x| x + 1).unwrap_or_else(|| 0)` with `map_or_else(|| 0, |x| x + 1)`
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:196:13
114    |
115 LL |       let _ = opt.map(|x| {
116    |  _____________^
117 LL | |                         x + 1
118 LL | |                     }
119 LL | |               ).unwrap_or_else(|| 0);
120    | |____________________________________^
121
122 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
123   --> $DIR/methods.rs:200:13
124    |
125 LL |       let _ = opt.map(|x| x + 1)
126    |  _____________^
127 LL | |                .unwrap_or_else(||
128 LL | |                     0
129 LL | |                 );
130    | |_________________^
131
132 error: called `map_or(None, f)` on an Option value. This can be done more directly by calling `and_then(f)` instead
133   --> $DIR/methods.rs:210:13
134    |
135 LL |     let _ = opt.map_or(None, |x| Some(x + 1));
136    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using and_then instead: `opt.and_then(|x| Some(x + 1))`
137    |
138    = note: `-D clippy::option-map-or-none` implied by `-D warnings`
139
140 error: called `map_or(None, f)` on an Option value. This can be done more directly by calling `and_then(f)` instead
141   --> $DIR/methods.rs:212:13
142    |
143 LL |       let _ = opt.map_or(None, |x| {
144    |  _____________^
145 LL | |                         Some(x + 1)
146 LL | |                        }
147 LL | |                 );
148    | |_________________^
149 help: try using and_then instead
150    |
151 LL |     let _ = opt.and_then(|x| {
152 LL |                         Some(x + 1)
153 LL |                        });
154    |
155
156 error: called `filter(p).next()` on an `Iterator`. This is more succinctly expressed by calling `.find(p)` instead.
157   --> $DIR/methods.rs:238:13
158    |
159 LL |     let _ = v.iter().filter(|&x| *x < 0).next();
160    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
161    |
162    = note: `-D clippy::filter-next` implied by `-D warnings`
163    = note: replace `filter(|&x| *x < 0).next()` with `find(|&x| *x < 0)`
164
165 error: called `filter(p).next()` on an `Iterator`. This is more succinctly expressed by calling `.find(p)` instead.
166   --> $DIR/methods.rs:241:13
167    |
168 LL |       let _ = v.iter().filter(|&x| {
169    |  _____________^
170 LL | |                                 *x < 0
171 LL | |                             }
172 LL | |                    ).next();
173    | |___________________________^
174
175 error: called `is_some()` after searching an `Iterator` with find. This is more succinctly expressed by calling `any()`.
176   --> $DIR/methods.rs:257:13
177    |
178 LL |     let _ = v.iter().find(|&x| *x < 0).is_some();
179    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
180    |
181    = note: `-D clippy::search-is-some` implied by `-D warnings`
182    = note: replace `find(|&x| *x < 0).is_some()` with `any(|&x| *x < 0)`
183
184 error: called `is_some()` after searching an `Iterator` with find. This is more succinctly expressed by calling `any()`.
185   --> $DIR/methods.rs:260:13
186    |
187 LL |       let _ = v.iter().find(|&x| {
188    |  _____________^
189 LL | |                               *x < 0
190 LL | |                           }
191 LL | |                    ).is_some();
192    | |______________________________^
193
194 error: called `is_some()` after searching an `Iterator` with position. This is more succinctly expressed by calling `any()`.
195   --> $DIR/methods.rs:266:13
196    |
197 LL |     let _ = v.iter().position(|&x| x < 0).is_some();
198    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
199    |
200    = note: replace `position(|&x| x < 0).is_some()` with `any(|&x| x < 0)`
201
202 error: called `is_some()` after searching an `Iterator` with position. This is more succinctly expressed by calling `any()`.
203   --> $DIR/methods.rs:269:13
204    |
205 LL |       let _ = v.iter().position(|&x| {
206    |  _____________^
207 LL | |                                   x < 0
208 LL | |                               }
209 LL | |                    ).is_some();
210    | |______________________________^
211
212 error: called `is_some()` after searching an `Iterator` with rposition. This is more succinctly expressed by calling `any()`.
213   --> $DIR/methods.rs:275:13
214    |
215 LL |     let _ = v.iter().rposition(|&x| x < 0).is_some();
216    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
217    |
218    = note: replace `rposition(|&x| x < 0).is_some()` with `any(|&x| x < 0)`
219
220 error: called `is_some()` after searching an `Iterator` with rposition. This is more succinctly expressed by calling `any()`.
221   --> $DIR/methods.rs:278:13
222    |
223 LL |       let _ = v.iter().rposition(|&x| {
224    |  _____________^
225 LL | |                                    x < 0
226 LL | |                                }
227 LL | |                    ).is_some();
228    | |______________________________^
229
230 error: use of `unwrap_or` followed by a function call
231   --> $DIR/methods.rs:315:22
232    |
233 LL |     with_constructor.unwrap_or(make());
234    |                      ^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(make)`
235    |
236    = note: `-D clippy::or-fun-call` implied by `-D warnings`
237
238 error: use of `unwrap_or` followed by a call to `new`
239   --> $DIR/methods.rs:318:5
240    |
241 LL |     with_new.unwrap_or(Vec::new());
242    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `with_new.unwrap_or_default()`
243
244 error: use of `unwrap_or` followed by a function call
245   --> $DIR/methods.rs:321:21
246    |
247 LL |     with_const_args.unwrap_or(Vec::with_capacity(12));
248    |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| Vec::with_capacity(12))`
249
250 error: use of `unwrap_or` followed by a function call
251   --> $DIR/methods.rs:324:14
252    |
253 LL |     with_err.unwrap_or(make());
254    |              ^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|_| make())`
255
256 error: use of `unwrap_or` followed by a function call
257   --> $DIR/methods.rs:327:19
258    |
259 LL |     with_err_args.unwrap_or(Vec::with_capacity(12));
260    |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|_| Vec::with_capacity(12))`
261
262 error: use of `unwrap_or` followed by a call to `default`
263   --> $DIR/methods.rs:330:5
264    |
265 LL |     with_default_trait.unwrap_or(Default::default());
266    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `with_default_trait.unwrap_or_default()`
267
268 error: use of `unwrap_or` followed by a call to `default`
269   --> $DIR/methods.rs:333:5
270    |
271 LL |     with_default_type.unwrap_or(u64::default());
272    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `with_default_type.unwrap_or_default()`
273
274 error: use of `unwrap_or` followed by a function call
275   --> $DIR/methods.rs:336:14
276    |
277 LL |     with_vec.unwrap_or(vec![]);
278    |              ^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| vec![])`
279
280 error: use of `unwrap_or` followed by a function call
281   --> $DIR/methods.rs:341:21
282    |
283 LL |     without_default.unwrap_or(Foo::new());
284    |                     ^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(Foo::new)`
285
286 error: use of `or_insert` followed by a function call
287   --> $DIR/methods.rs:344:19
288    |
289 LL |     map.entry(42).or_insert(String::new());
290    |                   ^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `or_insert_with(String::new)`
291
292 error: use of `or_insert` followed by a function call
293   --> $DIR/methods.rs:347:21
294    |
295 LL |     btree.entry(42).or_insert(String::new());
296    |                     ^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `or_insert_with(String::new)`
297
298 error: use of `unwrap_or` followed by a function call
299   --> $DIR/methods.rs:350:21
300    |
301 LL |     let _ = stringy.unwrap_or("".to_owned());
302    |                     ^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| "".to_owned())`
303
304 error: called `.iter().nth()` on a Vec. Calling `.get()` is both faster and more readable
305   --> $DIR/methods.rs:361:23
306    |
307 LL |         let bad_vec = some_vec.iter().nth(3);
308    |                       ^^^^^^^^^^^^^^^^^^^^^^
309    |
310    = note: `-D clippy::iter-nth` implied by `-D warnings`
311
312 error: called `.iter().nth()` on a slice. Calling `.get()` is both faster and more readable
313   --> $DIR/methods.rs:362:26
314    |
315 LL |         let bad_slice = &some_vec[..].iter().nth(3);
316    |                          ^^^^^^^^^^^^^^^^^^^^^^^^^^
317
318 error: called `.iter().nth()` on a slice. Calling `.get()` is both faster and more readable
319   --> $DIR/methods.rs:363:31
320    |
321 LL |         let bad_boxed_slice = boxed_slice.iter().nth(3);
322    |                               ^^^^^^^^^^^^^^^^^^^^^^^^^
323
324 error: called `.iter().nth()` on a VecDeque. Calling `.get()` is both faster and more readable
325   --> $DIR/methods.rs:364:29
326    |
327 LL |         let bad_vec_deque = some_vec_deque.iter().nth(3);
328    |                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
329
330 error: called `.iter_mut().nth()` on a Vec. Calling `.get_mut()` is both faster and more readable
331   --> $DIR/methods.rs:369:23
332    |
333 LL |         let bad_vec = some_vec.iter_mut().nth(3);
334    |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^
335
336 error: called `.iter_mut().nth()` on a slice. Calling `.get_mut()` is both faster and more readable
337   --> $DIR/methods.rs:372:26
338    |
339 LL |         let bad_slice = &some_vec[..].iter_mut().nth(3);
340    |                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
341
342 error: called `.iter_mut().nth()` on a VecDeque. Calling `.get_mut()` is both faster and more readable
343   --> $DIR/methods.rs:375:29
344    |
345 LL |         let bad_vec_deque = some_vec_deque.iter_mut().nth(3);
346    |                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
347
348 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
349   --> $DIR/methods.rs:387:13
350    |
351 LL |     let _ = opt.unwrap();
352    |             ^^^^^^^^^^^^
353    |
354    = note: `-D clippy::option-unwrap-used` implied by `-D warnings`
355
356 error: aborting due to 44 previous errors
357