]> git.lizzy.rs Git - rust.git/blob - tests/ui/methods.stderr
Auto merge of #3790 - ljedrz:HirIdify_intravisit, r=phansch
[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:69: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:73: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:77: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:157:13
33    |
34 LL |       let _ = opt.map(|x| x + 1)
35    |  _____________^
36 LL | |
37 LL | |                .unwrap_or(0); // should lint even though this call is on a separate line
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:161: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:165: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:170: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:172: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:176: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_else(g)` on an Option value. This can be done more directly by calling `map_or_else(g, f)` instead
93   --> $DIR/methods.rs:184:13
94    |
95 LL |       let _ = opt.map(|x| x + 1)
96    |  _____________^
97 LL | |
98 LL | |                .unwrap_or_else(|| 0); // should lint even though this call is on a separate line
99    | |____________________________________^
100    |
101    = note: `-D clippy::option-map-unwrap-or-else` implied by `-D warnings`
102    = note: replace `map(|x| x + 1).unwrap_or_else(|| 0)` with `map_or_else(|| 0, |x| x + 1)`
103
104 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
105   --> $DIR/methods.rs:188:13
106    |
107 LL |       let _ = opt.map(|x| {
108    |  _____________^
109 LL | |                         x + 1
110 LL | |                     }
111 LL | |               ).unwrap_or_else(|| 0);
112    | |____________________________________^
113
114 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
115   --> $DIR/methods.rs:192:13
116    |
117 LL |       let _ = opt.map(|x| x + 1)
118    |  _____________^
119 LL | |                .unwrap_or_else(||
120 LL | |                     0
121 LL | |                 );
122    | |_________________^
123
124 error: called `map_or(None, f)` on an Option value. This can be done more directly by calling `and_then(f)` instead
125   --> $DIR/methods.rs:201:13
126    |
127 LL |     let _ = opt.map_or(None, |x| Some(x + 1));
128    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using and_then instead: `opt.and_then(|x| Some(x + 1))`
129    |
130    = note: `-D clippy::option-map-or-none` implied by `-D warnings`
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:203:13
134    |
135 LL |       let _ = opt.map_or(None, |x| {
136    |  _____________^
137 LL | |                         Some(x + 1)
138 LL | |                        }
139 LL | |                 );
140    | |_________________^
141 help: try using and_then instead
142    |
143 LL |     let _ = opt.and_then(|x| {
144 LL |                         Some(x + 1)
145 LL |                        });
146    |
147
148 error: called `filter(p).next()` on an `Iterator`. This is more succinctly expressed by calling `.find(p)` instead.
149   --> $DIR/methods.rs:229:13
150    |
151 LL |     let _ = v.iter().filter(|&x| *x < 0).next();
152    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
153    |
154    = note: `-D clippy::filter-next` implied by `-D warnings`
155    = note: replace `filter(|&x| *x < 0).next()` with `find(|&x| *x < 0)`
156
157 error: called `filter(p).next()` on an `Iterator`. This is more succinctly expressed by calling `.find(p)` instead.
158   --> $DIR/methods.rs:232:13
159    |
160 LL |       let _ = v.iter().filter(|&x| {
161    |  _____________^
162 LL | |                                 *x < 0
163 LL | |                             }
164 LL | |                    ).next();
165    | |___________________________^
166
167 error: called `is_some()` after searching an `Iterator` with find. This is more succinctly expressed by calling `any()`.
168   --> $DIR/methods.rs:248:13
169    |
170 LL |     let _ = v.iter().find(|&x| *x < 0).is_some();
171    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
172    |
173    = note: `-D clippy::search-is-some` implied by `-D warnings`
174    = note: replace `find(|&x| *x < 0).is_some()` with `any(|&x| *x < 0)`
175
176 error: called `is_some()` after searching an `Iterator` with find. This is more succinctly expressed by calling `any()`.
177   --> $DIR/methods.rs:251:13
178    |
179 LL |       let _ = v.iter().find(|&x| {
180    |  _____________^
181 LL | |                               *x < 0
182 LL | |                           }
183 LL | |                    ).is_some();
184    | |______________________________^
185
186 error: called `is_some()` after searching an `Iterator` with position. This is more succinctly expressed by calling `any()`.
187   --> $DIR/methods.rs:257:13
188    |
189 LL |     let _ = v.iter().position(|&x| x < 0).is_some();
190    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
191    |
192    = note: replace `position(|&x| x < 0).is_some()` with `any(|&x| x < 0)`
193
194 error: called `is_some()` after searching an `Iterator` with position. This is more succinctly expressed by calling `any()`.
195   --> $DIR/methods.rs:260:13
196    |
197 LL |       let _ = v.iter().position(|&x| {
198    |  _____________^
199 LL | |                                   x < 0
200 LL | |                               }
201 LL | |                    ).is_some();
202    | |______________________________^
203
204 error: called `is_some()` after searching an `Iterator` with rposition. This is more succinctly expressed by calling `any()`.
205   --> $DIR/methods.rs:266:13
206    |
207 LL |     let _ = v.iter().rposition(|&x| x < 0).is_some();
208    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
209    |
210    = note: replace `rposition(|&x| x < 0).is_some()` with `any(|&x| x < 0)`
211
212 error: called `is_some()` after searching an `Iterator` with rposition. This is more succinctly expressed by calling `any()`.
213   --> $DIR/methods.rs:269:13
214    |
215 LL |       let _ = v.iter().rposition(|&x| {
216    |  _____________^
217 LL | |                                    x < 0
218 LL | |                                }
219 LL | |                    ).is_some();
220    | |______________________________^
221
222 error: use of `unwrap_or` followed by a function call
223   --> $DIR/methods.rs:306:22
224    |
225 LL |     with_constructor.unwrap_or(make());
226    |                      ^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(make)`
227    |
228    = note: `-D clippy::or-fun-call` implied by `-D warnings`
229
230 error: use of `unwrap_or` followed by a call to `new`
231   --> $DIR/methods.rs:309:5
232    |
233 LL |     with_new.unwrap_or(Vec::new());
234    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `with_new.unwrap_or_default()`
235
236 error: use of `unwrap_or` followed by a function call
237   --> $DIR/methods.rs:312:21
238    |
239 LL |     with_const_args.unwrap_or(Vec::with_capacity(12));
240    |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| Vec::with_capacity(12))`
241
242 error: use of `unwrap_or` followed by a function call
243   --> $DIR/methods.rs:315:14
244    |
245 LL |     with_err.unwrap_or(make());
246    |              ^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|_| make())`
247
248 error: use of `unwrap_or` followed by a function call
249   --> $DIR/methods.rs:318:19
250    |
251 LL |     with_err_args.unwrap_or(Vec::with_capacity(12));
252    |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|_| Vec::with_capacity(12))`
253
254 error: use of `unwrap_or` followed by a call to `default`
255   --> $DIR/methods.rs:321:5
256    |
257 LL |     with_default_trait.unwrap_or(Default::default());
258    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `with_default_trait.unwrap_or_default()`
259
260 error: use of `unwrap_or` followed by a call to `default`
261   --> $DIR/methods.rs:324:5
262    |
263 LL |     with_default_type.unwrap_or(u64::default());
264    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `with_default_type.unwrap_or_default()`
265
266 error: use of `unwrap_or` followed by a function call
267   --> $DIR/methods.rs:327:14
268    |
269 LL |     with_vec.unwrap_or(vec![]);
270    |              ^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| vec![])`
271
272 error: use of `unwrap_or` followed by a function call
273   --> $DIR/methods.rs:332:21
274    |
275 LL |     without_default.unwrap_or(Foo::new());
276    |                     ^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(Foo::new)`
277
278 error: use of `or_insert` followed by a function call
279   --> $DIR/methods.rs:335:19
280    |
281 LL |     map.entry(42).or_insert(String::new());
282    |                   ^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `or_insert_with(String::new)`
283
284 error: use of `or_insert` followed by a function call
285   --> $DIR/methods.rs:338:21
286    |
287 LL |     btree.entry(42).or_insert(String::new());
288    |                     ^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `or_insert_with(String::new)`
289
290 error: use of `unwrap_or` followed by a function call
291   --> $DIR/methods.rs:341:21
292    |
293 LL |     let _ = stringy.unwrap_or("".to_owned());
294    |                     ^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| "".to_owned())`
295
296 error: called `.iter().nth()` on a Vec. Calling `.get()` is both faster and more readable
297   --> $DIR/methods.rs:352:23
298    |
299 LL |         let bad_vec = some_vec.iter().nth(3);
300    |                       ^^^^^^^^^^^^^^^^^^^^^^
301    |
302    = note: `-D clippy::iter-nth` implied by `-D warnings`
303
304 error: called `.iter().nth()` on a slice. Calling `.get()` is both faster and more readable
305   --> $DIR/methods.rs:353:26
306    |
307 LL |         let bad_slice = &some_vec[..].iter().nth(3);
308    |                          ^^^^^^^^^^^^^^^^^^^^^^^^^^
309
310 error: called `.iter().nth()` on a slice. Calling `.get()` is both faster and more readable
311   --> $DIR/methods.rs:354:31
312    |
313 LL |         let bad_boxed_slice = boxed_slice.iter().nth(3);
314    |                               ^^^^^^^^^^^^^^^^^^^^^^^^^
315
316 error: called `.iter().nth()` on a VecDeque. Calling `.get()` is both faster and more readable
317   --> $DIR/methods.rs:355:29
318    |
319 LL |         let bad_vec_deque = some_vec_deque.iter().nth(3);
320    |                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
321
322 error: called `.iter_mut().nth()` on a Vec. Calling `.get_mut()` is both faster and more readable
323   --> $DIR/methods.rs:360:23
324    |
325 LL |         let bad_vec = some_vec.iter_mut().nth(3);
326    |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^
327
328 error: called `.iter_mut().nth()` on a slice. Calling `.get_mut()` is both faster and more readable
329   --> $DIR/methods.rs:363:26
330    |
331 LL |         let bad_slice = &some_vec[..].iter_mut().nth(3);
332    |                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
333
334 error: called `.iter_mut().nth()` on a VecDeque. Calling `.get_mut()` is both faster and more readable
335   --> $DIR/methods.rs:366:29
336    |
337 LL |         let bad_vec_deque = some_vec_deque.iter_mut().nth(3);
338    |                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
339
340 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
341   --> $DIR/methods.rs:378:13
342    |
343 LL |     let _ = opt.unwrap();
344    |             ^^^^^^^^^^^^
345    |
346    = note: `-D clippy::option-unwrap-used` implied by `-D warnings`
347
348 error: aborting due to 43 previous errors
349