@@ -2,16 +2,25 @@ error: this `map_or` can be simplified
2
2
--> tests/ui/unnecessary_map_or.rs:13:13
3
3
|
4
4
LL | let _ = Some(5).map_or(false, |n| n == 5);
5
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use a standard comparison instead: `Some(5) == Some(5)`
5
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6
6
|
7
7
= note: `-D clippy::unnecessary-map-or` implied by `-D warnings`
8
8
= help: to override `-D warnings` add `#[allow(clippy::unnecessary_map_or)]`
9
+ help: use a standard comparison instead
10
+ |
11
+ LL | let _ = Some(5) == Some(5);
12
+ | ~~~~~~~~~~~~~~~~~~
9
13
10
14
error: this `map_or` can be simplified
11
15
--> tests/ui/unnecessary_map_or.rs:14:13
12
16
|
13
17
LL | let _ = Some(5).map_or(true, |n| n != 5);
14
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use a standard comparison instead: `Some(5) != Some(5)`
18
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
19
+ |
20
+ help: use a standard comparison instead
21
+ |
22
+ LL | let _ = Some(5) != Some(5);
23
+ | ~~~~~~~~~~~~~~~~~~
15
24
16
25
error: this `map_or` can be simplified
17
26
--> tests/ui/unnecessary_map_or.rs:15:13
@@ -21,7 +30,12 @@ LL | let _ = Some(5).map_or(false, |n| {
21
30
LL | | let _ = 1;
22
31
LL | | n == 5
23
32
LL | | });
24
- | |______^ help: use a standard comparison instead: `Some(5) == Some(5)`
33
+ | |______^
34
+ |
35
+ help: use a standard comparison instead
36
+ |
37
+ LL | let _ = Some(5) == Some(5);
38
+ | ~~~~~~~~~~~~~~~~~~
25
39
26
40
error: this `map_or` can be simplified
27
41
--> tests/ui/unnecessary_map_or.rs:19:13
@@ -35,113 +49,207 @@ LL | | });
35
49
|
36
50
help: use is_some_and instead
37
51
|
38
- LL ~ let _ = Some(5).is_some_and(|n| {
39
- LL + let _ = n;
40
- LL + 6 >= 5
41
- LL ~ });
52
+ LL - let _ = Some(5).map_or(false, |n| {
53
+ LL + let _ = Some(5).is_some_and(|n| {
42
54
|
43
55
44
56
error: this `map_or` can be simplified
45
57
--> tests/ui/unnecessary_map_or.rs:23:13
46
58
|
47
59
LL | let _ = Some(vec![5]).map_or(false, |n| n == [5]);
48
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use is_some_and instead: `Some(vec![5]).is_some_and(|n| n == [5])`
60
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
61
+ |
62
+ help: use is_some_and instead
63
+ |
64
+ LL - let _ = Some(vec![5]).map_or(false, |n| n == [5]);
65
+ LL + let _ = Some(vec![5]).is_some_and(|n| n == [5]);
66
+ |
49
67
50
68
error: this `map_or` can be simplified
51
69
--> tests/ui/unnecessary_map_or.rs:24:13
52
70
|
53
71
LL | let _ = Some(vec![1]).map_or(false, |n| vec![2] == n);
54
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use is_some_and instead: `Some(vec![1]).is_some_and(|n| vec![2] == n)`
72
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
73
+ |
74
+ help: use is_some_and instead
75
+ |
76
+ LL - let _ = Some(vec![1]).map_or(false, |n| vec![2] == n);
77
+ LL + let _ = Some(vec![1]).is_some_and(|n| vec![2] == n);
78
+ |
55
79
56
80
error: this `map_or` can be simplified
57
81
--> tests/ui/unnecessary_map_or.rs:25:13
58
82
|
59
83
LL | let _ = Some(5).map_or(false, |n| n == n);
60
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use is_some_and instead: `Some(5).is_some_and(|n| n == n)`
84
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
85
+ |
86
+ help: use is_some_and instead
87
+ |
88
+ LL - let _ = Some(5).map_or(false, |n| n == n);
89
+ LL + let _ = Some(5).is_some_and(|n| n == n);
90
+ |
61
91
62
92
error: this `map_or` can be simplified
63
93
--> tests/ui/unnecessary_map_or.rs:26:13
64
94
|
65
95
LL | let _ = Some(5).map_or(false, |n| n == if 2 > 1 { n } else { 0 });
66
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use is_some_and instead: `Some(5).is_some_and(|n| n == if 2 > 1 { n } else { 0 })`
96
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
97
+ |
98
+ help: use is_some_and instead
99
+ |
100
+ LL - let _ = Some(5).map_or(false, |n| n == if 2 > 1 { n } else { 0 });
101
+ LL + let _ = Some(5).is_some_and(|n| n == if 2 > 1 { n } else { 0 });
102
+ |
67
103
68
104
error: this `map_or` can be simplified
69
105
--> tests/ui/unnecessary_map_or.rs:27:13
70
106
|
71
107
LL | let _ = Ok::<Vec<i32>, i32>(vec![5]).map_or(false, |n| n == [5]);
72
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use is_ok_and instead: `Ok::<Vec<i32>, i32>(vec![5]).is_ok_and(|n| n == [5])`
108
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
109
+ |
110
+ help: use is_ok_and instead
111
+ |
112
+ LL - let _ = Ok::<Vec<i32>, i32>(vec![5]).map_or(false, |n| n == [5]);
113
+ LL + let _ = Ok::<Vec<i32>, i32>(vec![5]).is_ok_and(|n| n == [5]);
114
+ |
73
115
74
116
error: this `map_or` can be simplified
75
117
--> tests/ui/unnecessary_map_or.rs:28:13
76
118
|
77
119
LL | let _ = Ok::<i32, i32>(5).map_or(false, |n| n == 5);
78
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use a standard comparison instead: `Ok::<i32, i32>(5) == Ok(5)`
120
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
121
+ |
122
+ help: use a standard comparison instead
123
+ |
124
+ LL | let _ = Ok::<i32, i32>(5) == Ok(5);
125
+ | ~~~~~~~~~~~~~~~~~~~~~~~~~~
79
126
80
127
error: this `map_or` can be simplified
81
128
--> tests/ui/unnecessary_map_or.rs:29:13
82
129
|
83
130
LL | let _ = Some(5).map_or(false, |n| n == 5).then(|| 1);
84
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use a standard comparison instead: `(Some(5) == Some(5))`
131
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
132
+ |
133
+ help: use a standard comparison instead
134
+ |
135
+ LL | let _ = (Some(5) == Some(5)).then(|| 1);
136
+ | ~~~~~~~~~~~~~~~~~~~~
85
137
86
138
error: this `map_or` can be simplified
87
139
--> tests/ui/unnecessary_map_or.rs:30:13
88
140
|
89
141
LL | let _ = Some(5).map_or(true, |n| n == 5);
90
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use is_none_or instead: `Some(5).is_none_or(|n| n == 5)`
142
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
143
+ |
144
+ help: use is_none_or instead
145
+ |
146
+ LL - let _ = Some(5).map_or(true, |n| n == 5);
147
+ LL + let _ = Some(5).is_none_or(|n| n == 5);
148
+ |
91
149
92
150
error: this `map_or` can be simplified
93
151
--> tests/ui/unnecessary_map_or.rs:31:13
94
152
|
95
153
LL | let _ = Some(5).map_or(true, |n| 5 == n);
96
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use is_none_or instead: `Some(5).is_none_or(|n| 5 == n)`
154
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
155
+ |
156
+ help: use is_none_or instead
157
+ |
158
+ LL - let _ = Some(5).map_or(true, |n| 5 == n);
159
+ LL + let _ = Some(5).is_none_or(|n| 5 == n);
160
+ |
97
161
98
162
error: this `map_or` can be simplified
99
163
--> tests/ui/unnecessary_map_or.rs:32:14
100
164
|
101
165
LL | let _ = !Some(5).map_or(false, |n| n == 5);
102
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use a standard comparison instead: `(Some(5) == Some(5))`
166
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
167
+ |
168
+ help: use a standard comparison instead
169
+ |
170
+ LL | let _ = !(Some(5) == Some(5));
171
+ | ~~~~~~~~~~~~~~~~~~~~
103
172
104
173
error: this `map_or` can be simplified
105
174
--> tests/ui/unnecessary_map_or.rs:33:13
106
175
|
107
176
LL | let _ = Some(5).map_or(false, |n| n == 5) || false;
108
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use a standard comparison instead: `(Some(5) == Some(5))`
177
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
178
+ |
179
+ help: use a standard comparison instead
180
+ |
181
+ LL | let _ = (Some(5) == Some(5)) || false;
182
+ | ~~~~~~~~~~~~~~~~~~~~
109
183
110
184
error: this `map_or` can be simplified
111
185
--> tests/ui/unnecessary_map_or.rs:34:13
112
186
|
113
187
LL | let _ = Some(5).map_or(false, |n| n == 5) as usize;
114
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use a standard comparison instead: `(Some(5) == Some(5))`
188
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
189
+ |
190
+ help: use a standard comparison instead
191
+ |
192
+ LL | let _ = (Some(5) == Some(5)) as usize;
193
+ | ~~~~~~~~~~~~~~~~~~~~
115
194
116
195
error: this `map_or` can be simplified
117
196
--> tests/ui/unnecessary_map_or.rs:58:13
118
197
|
119
198
LL | let _ = r.map_or(false, |x| x == 7);
120
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use is_ok_and instead: `r.is_ok_and(|x| x == 7)`
199
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
200
+ |
201
+ help: use is_ok_and instead
202
+ |
203
+ LL - let _ = r.map_or(false, |x| x == 7);
204
+ LL + let _ = r.is_ok_and(|x| x == 7);
205
+ |
121
206
122
207
error: this `map_or` can be simplified
123
208
--> tests/ui/unnecessary_map_or.rs:63:13
124
209
|
125
210
LL | let _ = r.map_or(false, func);
126
- | ^^^^^^^^^^^^^^^^^^^^^ help: use is_ok_and instead: `r.is_ok_and(func)`
211
+ | ^^^^^^^^^^^^^^^^^^^^^
212
+ |
213
+ help: use is_ok_and instead
214
+ |
215
+ LL - let _ = r.map_or(false, func);
216
+ LL + let _ = r.is_ok_and(func);
217
+ |
127
218
128
219
error: this `map_or` can be simplified
129
220
--> tests/ui/unnecessary_map_or.rs:64:13
130
221
|
131
222
LL | let _ = Some(5).map_or(false, func);
132
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use is_some_and instead: `Some(5).is_some_and(func)`
223
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
224
+ |
225
+ help: use is_some_and instead
226
+ |
227
+ LL - let _ = Some(5).map_or(false, func);
228
+ LL + let _ = Some(5).is_some_and(func);
229
+ |
133
230
134
231
error: this `map_or` can be simplified
135
232
--> tests/ui/unnecessary_map_or.rs:65:13
136
233
|
137
234
LL | let _ = Some(5).map_or(true, func);
138
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use is_none_or instead: `Some(5).is_none_or(func)`
235
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^
236
+ |
237
+ help: use is_none_or instead
238
+ |
239
+ LL - let _ = Some(5).map_or(true, func);
240
+ LL + let _ = Some(5).is_none_or(func);
241
+ |
139
242
140
243
error: this `map_or` can be simplified
141
244
--> tests/ui/unnecessary_map_or.rs:70:13
142
245
|
143
246
LL | let _ = r.map_or(false, |x| x == 8);
144
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use a standard comparison instead: `r == Ok(8)`
247
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
248
+ |
249
+ help: use a standard comparison instead
250
+ |
251
+ LL | let _ = r == Ok(8);
252
+ | ~~~~~~~~~~
145
253
146
254
error: aborting due to 21 previous errors
147
255
0 commit comments