fork/rust

git clone https://git.julia.blue/fork/rust

borsAuto merge of #103046 - JanBeh:PR_clarify_cmp_terminology, r=workingjubilee3bcad65fbf6

master
12.7 KiB264 linesraw
1error: `find(..).map(..)` can be simplified as `find_map(..)`
2  --> $DIR/manual_find_map.rs:8:19
3   |
4LL |     let _ = (0..).find(|n| to_opt(*n).is_some()).map(|a| to_opt(a).unwrap());
5   |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `find_map(|a| to_opt(a))`
6   |
7note: the suggestion might change the behavior of the program when merging `filter` and `map`, because this expression potentially contains side effects and will only execute once
8  --> $DIR/manual_find_map.rs:8:28
9   |
10LL |     let _ = (0..).find(|n| to_opt(*n).is_some()).map(|a| to_opt(a).unwrap());
11   |                            ^^^^^^^^^^
12   = note: `-D clippy::manual-find-map` implied by `-D warnings`
13   = help: to override `-D warnings` add `#[allow(clippy::manual_find_map)]`
14
15error: `find(..).map(..)` can be simplified as `find_map(..)`
16  --> $DIR/manual_find_map.rs:11:19
17   |
18LL |     let _ = (0..).find(|&n| to_opt(n).is_some()).map(|a| to_opt(a).expect("hi"));
19   |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `find_map(|a| to_opt(a))`
20   |
21note: the suggestion might change the behavior of the program when merging `filter` and `map`, because this expression potentially contains side effects and will only execute once
22  --> $DIR/manual_find_map.rs:11:29
23   |
24LL |     let _ = (0..).find(|&n| to_opt(n).is_some()).map(|a| to_opt(a).expect("hi"));
25   |                             ^^^^^^^^^
26
27error: `find(..).map(..)` can be simplified as `find_map(..)`
28  --> $DIR/manual_find_map.rs:14:19
29   |
30LL |     let _ = (0..).find(|&n| to_res(n).is_ok()).map(|a| to_res(a).unwrap_or(1));
31   |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `find_map(|a| to_res(a).ok())`
32   |
33note: the suggestion might change the behavior of the program when merging `filter` and `map`, because this expression potentially contains side effects and will only execute once
34  --> $DIR/manual_find_map.rs:14:29
35   |
36LL |     let _ = (0..).find(|&n| to_res(n).is_ok()).map(|a| to_res(a).unwrap_or(1));
37   |                             ^^^^^^^^^
38
39error: `find(..).map(..)` can be simplified as `find_map(..)`
40  --> $DIR/manual_find_map.rs:17:10
41   |
42LL |           .find(|&x| to_ref(to_opt(x)).is_some())
43   |  __________^
44LL | |         .map(|y| to_ref(to_opt(y)).unwrap());
45   | |____________________________________________^ help: try: `find_map(|y| *to_ref(to_opt(y)))`
46   |
47note: the suggestion might change the behavior of the program when merging `filter` and `map`, because this expression potentially contains side effects and will only execute once
48  --> $DIR/manual_find_map.rs:17:20
49   |
50LL |         .find(|&x| to_ref(to_opt(x)).is_some())
51   |                    ^^^^^^^^^^^^^^^^^
52
53error: `find(..).map(..)` can be simplified as `find_map(..)`
54  --> $DIR/manual_find_map.rs:20:10
55   |
56LL |           .find(|x| to_ref(to_opt(*x)).is_some())
57   |  __________^
58LL | |         .map(|y| to_ref(to_opt(y)).unwrap());
59   | |____________________________________________^ help: try: `find_map(|y| *to_ref(to_opt(y)))`
60   |
61note: the suggestion might change the behavior of the program when merging `filter` and `map`, because this expression potentially contains side effects and will only execute once
62  --> $DIR/manual_find_map.rs:20:19
63   |
64LL |         .find(|x| to_ref(to_opt(*x)).is_some())
65   |                   ^^^^^^^^^^^^^^^^^^
66
67error: `find(..).map(..)` can be simplified as `find_map(..)`
68  --> $DIR/manual_find_map.rs:24:10
69   |
70LL |           .find(|&x| to_ref(to_res(x)).is_ok())
71   |  __________^
72LL | |         .map(|y| to_ref(to_res(y)).unwrap());
73   | |____________________________________________^ help: try: `find_map(|y| to_ref(to_res(y)).ok())`
74   |
75note: the suggestion might change the behavior of the program when merging `filter` and `map`, because this expression potentially contains side effects and will only execute once
76  --> $DIR/manual_find_map.rs:24:20
77   |
78LL |         .find(|&x| to_ref(to_res(x)).is_ok())
79   |                    ^^^^^^^^^^^^^^^^^
80
81error: `find(..).map(..)` can be simplified as `find_map(..)`
82  --> $DIR/manual_find_map.rs:27:10
83   |
84LL |           .find(|x| to_ref(to_res(*x)).is_ok())
85   |  __________^
86LL | |         .map(|y| to_ref(to_res(y)).unwrap());
87   | |____________________________________________^ help: try: `find_map(|y| to_ref(to_res(y)).ok())`
88   |
89note: the suggestion might change the behavior of the program when merging `filter` and `map`, because this expression potentially contains side effects and will only execute once
90  --> $DIR/manual_find_map.rs:27:19
91   |
92LL |         .find(|x| to_ref(to_res(*x)).is_ok())
93   |                   ^^^^^^^^^^^^^^^^^^
94
95error: `find(..).map(..)` can be simplified as `find_map(..)`
96  --> $DIR/manual_find_map.rs:33:26
97   |
98LL |     iter::<Option<u8>>().find(|x| x.is_some()).map(|x| x.unwrap());
99   |                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `find_map(|x| x)`
100
101error: `find(..).map(..)` can be simplified as `find_map(..)`
102  --> $DIR/manual_find_map.rs:34:27
103   |
104LL |     iter::<&Option<u8>>().find(|x| x.is_some()).map(|x| x.unwrap());
105   |                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `find_map(|x| *x)`
106
107error: `find(..).map(..)` can be simplified as `find_map(..)`
108  --> $DIR/manual_find_map.rs:35:28
109   |
110LL |     iter::<&&Option<u8>>().find(|x| x.is_some()).map(|x| x.unwrap());
111   |                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `find_map(|x| **x)`
112
113error: `find(..).map(..)` can be simplified as `find_map(..)`
114  --> $DIR/manual_find_map.rs:36:27
115   |
116LL |     iter::<Option<&u8>>().find(|x| x.is_some()).map(|x| x.cloned().unwrap());
117   |                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `find_map(|x| x.cloned())`
118
119error: `find(..).map(..)` can be simplified as `find_map(..)`
120  --> $DIR/manual_find_map.rs:37:28
121   |
122LL |     iter::<&Option<&u8>>().find(|x| x.is_some()).map(|x| x.cloned().unwrap());
123   |                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `find_map(|x| x.cloned())`
124
125error: `find(..).map(..)` can be simplified as `find_map(..)`
126  --> $DIR/manual_find_map.rs:38:31
127   |
128LL |     iter::<&Option<String>>().find(|x| x.is_some()).map(|x| x.as_deref().unwrap());
129   |                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `find_map(|x| x.as_deref())`
130
131error: `find(..).map(..)` can be simplified as `find_map(..)`
132  --> $DIR/manual_find_map.rs:39:31
133   |
134LL |     iter::<Option<&String>>().find(|&x| to_ref(x).is_some()).map(|y| to_ref(y).cloned().unwrap());
135   |                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `find_map(|y| to_ref(y).cloned())`
136   |
137note: the suggestion might change the behavior of the program when merging `filter` and `map`, because this expression potentially contains side effects and will only execute once
138  --> $DIR/manual_find_map.rs:39:41
139   |
140LL |     iter::<Option<&String>>().find(|&x| to_ref(x).is_some()).map(|y| to_ref(y).cloned().unwrap());
141   |                                         ^^^^^^^^^
142
143error: `find(..).map(..)` can be simplified as `find_map(..)`
144  --> $DIR/manual_find_map.rs:41:30
145   |
146LL |     iter::<Result<u8, ()>>().find(|x| x.is_ok()).map(|x| x.unwrap());
147   |                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `find_map(|x| x.ok())`
148
149error: `find(..).map(..)` can be simplified as `find_map(..)`
150  --> $DIR/manual_find_map.rs:42:31
151   |
152LL |     iter::<&Result<u8, ()>>().find(|x| x.is_ok()).map(|x| x.unwrap());
153   |                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `find_map(|x| x.ok())`
154
155error: `find(..).map(..)` can be simplified as `find_map(..)`
156  --> $DIR/manual_find_map.rs:43:32
157   |
158LL |     iter::<&&Result<u8, ()>>().find(|x| x.is_ok()).map(|x| x.unwrap());
159   |                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `find_map(|x| x.ok())`
160
161error: `find(..).map(..)` can be simplified as `find_map(..)`
162  --> $DIR/manual_find_map.rs:44:31
163   |
164LL |     iter::<Result<&u8, ()>>().find(|x| x.is_ok()).map(|x| x.cloned().unwrap());
165   |                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `find_map(|x| x.cloned().ok())`
166
167error: `find(..).map(..)` can be simplified as `find_map(..)`
168  --> $DIR/manual_find_map.rs:45:32
169   |
170LL |     iter::<&Result<&u8, ()>>().find(|x| x.is_ok()).map(|x| x.cloned().unwrap());
171   |                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `find_map(|x| x.cloned().ok())`
172
173error: `find(..).map(..)` can be simplified as `find_map(..)`
174  --> $DIR/manual_find_map.rs:46:35
175   |
176LL |     iter::<&Result<String, ()>>().find(|x| x.is_ok()).map(|x| x.as_deref().unwrap());
177   |                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `find_map(|x| x.as_deref().ok())`
178
179error: `find(..).map(..)` can be simplified as `find_map(..)`
180  --> $DIR/manual_find_map.rs:47:35
181   |
182LL |     iter::<Result<&String, ()>>().find(|&x| to_ref(x).is_ok()).map(|y| to_ref(y).cloned().unwrap());
183   |                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `find_map(|y| to_ref(y).cloned().ok())`
184   |
185note: the suggestion might change the behavior of the program when merging `filter` and `map`, because this expression potentially contains side effects and will only execute once
186  --> $DIR/manual_find_map.rs:47:45
187   |
188LL |     iter::<Result<&String, ()>>().find(|&x| to_ref(x).is_ok()).map(|y| to_ref(y).cloned().unwrap());
189   |                                             ^^^^^^^^^
190
191error: `find(..).map(..)` can be simplified as `find_map(..)`
192  --> $DIR/manual_find_map.rs:95:10
193   |
194LL |           .find(|f| f.option_field.is_some())
195   |  __________^
196LL | |         .map(|f| f.option_field.clone().unwrap());
197   | |_________________________________________________^ help: try: `find_map(|f| f.option_field.clone())`
198
199error: `find(..).map(..)` can be simplified as `find_map(..)`
200  --> $DIR/manual_find_map.rs:100:10
201   |
202LL |           .find(|f| f.ref_field.is_some())
203   |  __________^
204LL | |         .map(|f| f.ref_field.cloned().unwrap());
205   | |_______________________________________________^ help: try: `find_map(|f| f.ref_field.cloned())`
206
207error: `find(..).map(..)` can be simplified as `find_map(..)`
208  --> $DIR/manual_find_map.rs:105:10
209   |
210LL |           .find(|f| f.ref_field.is_some())
211   |  __________^
212LL | |         .map(|f| f.ref_field.copied().unwrap());
213   | |_______________________________________________^ help: try: `find_map(|f| f.ref_field.copied())`
214
215error: `find(..).map(..)` can be simplified as `find_map(..)`
216  --> $DIR/manual_find_map.rs:110:10
217   |
218LL |           .find(|f| f.result_field.is_ok())
219   |  __________^
220LL | |         .map(|f| f.result_field.clone().unwrap());
221   | |_________________________________________________^ help: try: `find_map(|f| f.result_field.clone().ok())`
222
223error: `find(..).map(..)` can be simplified as `find_map(..)`
224  --> $DIR/manual_find_map.rs:115:10
225   |
226LL |           .find(|f| f.result_field.is_ok())
227   |  __________^
228LL | |         .map(|f| f.result_field.as_ref().unwrap());
229   | |__________________________________________________^ help: try: `find_map(|f| f.result_field.as_ref().ok())`
230
231error: `find(..).map(..)` can be simplified as `find_map(..)`
232  --> $DIR/manual_find_map.rs:120:10
233   |
234LL |           .find(|f| f.result_field.is_ok())
235   |  __________^
236LL | |         .map(|f| f.result_field.as_deref().unwrap());
237   | |____________________________________________________^ help: try: `find_map(|f| f.result_field.as_deref().ok())`
238
239error: `find(..).map(..)` can be simplified as `find_map(..)`
240  --> $DIR/manual_find_map.rs:125:10
241   |
242LL |           .find(|f| f.result_field.is_ok())
243   |  __________^
244LL | |         .map(|f| f.result_field.as_mut().unwrap());
245   | |__________________________________________________^ help: try: `find_map(|f| f.result_field.as_mut().ok())`
246
247error: `find(..).map(..)` can be simplified as `find_map(..)`
248  --> $DIR/manual_find_map.rs:130:10
249   |
250LL |           .find(|f| f.result_field.is_ok())
251   |  __________^
252LL | |         .map(|f| f.result_field.as_deref_mut().unwrap());
253   | |________________________________________________________^ help: try: `find_map(|f| f.result_field.as_deref_mut().ok())`
254
255error: `find(..).map(..)` can be simplified as `find_map(..)`
256  --> $DIR/manual_find_map.rs:135:10
257   |
258LL |           .find(|f| f.result_field.is_ok())
259   |  __________^
260LL | |         .map(|f| f.result_field.to_owned().unwrap());
261   | |____________________________________________________^ help: try: `find_map(|f| f.result_field.to_owned().ok())`
262
263error: aborting due to 30 previous errors
264