clippy 0.0.161

A bunch of helpful lints to avoid common pitfalls in Rust
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
error: casting i32 to f32 causes a loss of precision (i32 is 32 bits wide, but f32's mantissa is only 23 bits wide)
 --> $DIR/cast.rs:8:5
  |
8 |     1i32 as f32;
  |     ^^^^^^^^^^^
  |
  = note: `-D cast-precision-loss` implied by `-D warnings`

error: casting i64 to f32 causes a loss of precision (i64 is 64 bits wide, but f32's mantissa is only 23 bits wide)
 --> $DIR/cast.rs:9:5
  |
9 |     1i64 as f32;
  |     ^^^^^^^^^^^

error: casting i64 to f64 causes a loss of precision (i64 is 64 bits wide, but f64's mantissa is only 52 bits wide)
  --> $DIR/cast.rs:10:5
   |
10 |     1i64 as f64;
   |     ^^^^^^^^^^^

error: casting u32 to f32 causes a loss of precision (u32 is 32 bits wide, but f32's mantissa is only 23 bits wide)
  --> $DIR/cast.rs:11:5
   |
11 |     1u32 as f32;
   |     ^^^^^^^^^^^

error: casting u64 to f32 causes a loss of precision (u64 is 64 bits wide, but f32's mantissa is only 23 bits wide)
  --> $DIR/cast.rs:12:5
   |
12 |     1u64 as f32;
   |     ^^^^^^^^^^^

error: casting u64 to f64 causes a loss of precision (u64 is 64 bits wide, but f64's mantissa is only 52 bits wide)
  --> $DIR/cast.rs:13:5
   |
13 |     1u64 as f64;
   |     ^^^^^^^^^^^

error: casting f32 to i32 may truncate the value
  --> $DIR/cast.rs:15:5
   |
15 |     1f32 as i32;
   |     ^^^^^^^^^^^
   |
   = note: `-D cast-possible-truncation` implied by `-D warnings`

error: casting f32 to u32 may truncate the value
  --> $DIR/cast.rs:16:5
   |
16 |     1f32 as u32;
   |     ^^^^^^^^^^^

error: casting f32 to u32 may lose the sign of the value
  --> $DIR/cast.rs:16:5
   |
16 |     1f32 as u32;
   |     ^^^^^^^^^^^
   |
   = note: `-D cast-sign-loss` implied by `-D warnings`

error: casting f64 to f32 may truncate the value
  --> $DIR/cast.rs:17:5
   |
17 |     1f64 as f32;
   |     ^^^^^^^^^^^

error: casting i32 to i8 may truncate the value
  --> $DIR/cast.rs:18:5
   |
18 |     1i32 as i8;
   |     ^^^^^^^^^^

error: casting i32 to u8 may lose the sign of the value
  --> $DIR/cast.rs:19:5
   |
19 |     1i32 as u8;
   |     ^^^^^^^^^^

error: casting i32 to u8 may truncate the value
  --> $DIR/cast.rs:19:5
   |
19 |     1i32 as u8;
   |     ^^^^^^^^^^

error: casting f64 to isize may truncate the value
  --> $DIR/cast.rs:20:5
   |
20 |     1f64 as isize;
   |     ^^^^^^^^^^^^^

error: casting f64 to usize may truncate the value
  --> $DIR/cast.rs:21:5
   |
21 |     1f64 as usize;
   |     ^^^^^^^^^^^^^

error: casting f64 to usize may lose the sign of the value
  --> $DIR/cast.rs:21:5
   |
21 |     1f64 as usize;
   |     ^^^^^^^^^^^^^

error: casting u8 to i8 may wrap around the value
  --> $DIR/cast.rs:23:5
   |
23 |     1u8 as i8;
   |     ^^^^^^^^^
   |
   = note: `-D cast-possible-wrap` implied by `-D warnings`

error: casting u16 to i16 may wrap around the value
  --> $DIR/cast.rs:24:5
   |
24 |     1u16 as i16;
   |     ^^^^^^^^^^^

error: casting u32 to i32 may wrap around the value
  --> $DIR/cast.rs:25:5
   |
25 |     1u32 as i32;
   |     ^^^^^^^^^^^

error: casting u64 to i64 may wrap around the value
  --> $DIR/cast.rs:26:5
   |
26 |     1u64 as i64;
   |     ^^^^^^^^^^^

error: casting usize to isize may wrap around the value
  --> $DIR/cast.rs:27:5
   |
27 |     1usize as isize;
   |     ^^^^^^^^^^^^^^^

error: casting i8 to i16 may become silently lossy if types change
  --> $DIR/cast.rs:29:5
   |
29 |     1i8 as i16;
   |     ^^^^^^^^^^ help: try: `i16::from(1i8)`
   |
   = note: `-D cast-lossless` implied by `-D warnings`

error: casting i8 to i32 may become silently lossy if types change
  --> $DIR/cast.rs:30:5
   |
30 |     1i8 as i32;
   |     ^^^^^^^^^^ help: try: `i32::from(1i8)`

error: casting i8 to i64 may become silently lossy if types change
  --> $DIR/cast.rs:31:5
   |
31 |     1i8 as i64;
   |     ^^^^^^^^^^ help: try: `i64::from(1i8)`

error: casting u8 to i16 may become silently lossy if types change
  --> $DIR/cast.rs:32:5
   |
32 |     1u8 as i16;
   |     ^^^^^^^^^^ help: try: `i16::from(1u8)`

error: casting u8 to i32 may become silently lossy if types change
  --> $DIR/cast.rs:33:5
   |
33 |     1u8 as i32;
   |     ^^^^^^^^^^ help: try: `i32::from(1u8)`

error: casting u8 to i64 may become silently lossy if types change
  --> $DIR/cast.rs:34:5
   |
34 |     1u8 as i64;
   |     ^^^^^^^^^^ help: try: `i64::from(1u8)`

error: casting u8 to u16 may become silently lossy if types change
  --> $DIR/cast.rs:35:5
   |
35 |     1u8 as u16;
   |     ^^^^^^^^^^ help: try: `u16::from(1u8)`

error: casting u8 to u32 may become silently lossy if types change
  --> $DIR/cast.rs:36:5
   |
36 |     1u8 as u32;
   |     ^^^^^^^^^^ help: try: `u32::from(1u8)`

error: casting u8 to u64 may become silently lossy if types change
  --> $DIR/cast.rs:37:5
   |
37 |     1u8 as u64;
   |     ^^^^^^^^^^ help: try: `u64::from(1u8)`

error: casting i16 to i32 may become silently lossy if types change
  --> $DIR/cast.rs:38:5
   |
38 |     1i16 as i32;
   |     ^^^^^^^^^^^ help: try: `i32::from(1i16)`

error: casting i16 to i64 may become silently lossy if types change
  --> $DIR/cast.rs:39:5
   |
39 |     1i16 as i64;
   |     ^^^^^^^^^^^ help: try: `i64::from(1i16)`

error: casting u16 to i32 may become silently lossy if types change
  --> $DIR/cast.rs:40:5
   |
40 |     1u16 as i32;
   |     ^^^^^^^^^^^ help: try: `i32::from(1u16)`

error: casting u16 to i64 may become silently lossy if types change
  --> $DIR/cast.rs:41:5
   |
41 |     1u16 as i64;
   |     ^^^^^^^^^^^ help: try: `i64::from(1u16)`

error: casting u16 to u32 may become silently lossy if types change
  --> $DIR/cast.rs:42:5
   |
42 |     1u16 as u32;
   |     ^^^^^^^^^^^ help: try: `u32::from(1u16)`

error: casting u16 to u64 may become silently lossy if types change
  --> $DIR/cast.rs:43:5
   |
43 |     1u16 as u64;
   |     ^^^^^^^^^^^ help: try: `u64::from(1u16)`

error: casting i32 to i64 may become silently lossy if types change
  --> $DIR/cast.rs:44:5
   |
44 |     1i32 as i64;
   |     ^^^^^^^^^^^ help: try: `i64::from(1i32)`

error: casting u32 to i64 may become silently lossy if types change
  --> $DIR/cast.rs:45:5
   |
45 |     1u32 as i64;
   |     ^^^^^^^^^^^ help: try: `i64::from(1u32)`

error: casting u32 to u64 may become silently lossy if types change
  --> $DIR/cast.rs:46:5
   |
46 |     1u32 as u64;
   |     ^^^^^^^^^^^ help: try: `u64::from(1u32)`

error: casting i8 to f32 may become silently lossy if types change
  --> $DIR/cast.rs:48:5
   |
48 |     1i8 as f32;
   |     ^^^^^^^^^^ help: try: `f32::from(1i8)`

error: casting i8 to f64 may become silently lossy if types change
  --> $DIR/cast.rs:49:5
   |
49 |     1i8 as f64;
   |     ^^^^^^^^^^ help: try: `f64::from(1i8)`

error: casting u8 to f32 may become silently lossy if types change
  --> $DIR/cast.rs:50:5
   |
50 |     1u8 as f32;
   |     ^^^^^^^^^^ help: try: `f32::from(1u8)`

error: casting u8 to f64 may become silently lossy if types change
  --> $DIR/cast.rs:51:5
   |
51 |     1u8 as f64;
   |     ^^^^^^^^^^ help: try: `f64::from(1u8)`

error: casting i16 to f32 may become silently lossy if types change
  --> $DIR/cast.rs:52:5
   |
52 |     1i16 as f32;
   |     ^^^^^^^^^^^ help: try: `f32::from(1i16)`

error: casting i16 to f64 may become silently lossy if types change
  --> $DIR/cast.rs:53:5
   |
53 |     1i16 as f64;
   |     ^^^^^^^^^^^ help: try: `f64::from(1i16)`

error: casting u16 to f32 may become silently lossy if types change
  --> $DIR/cast.rs:54:5
   |
54 |     1u16 as f32;
   |     ^^^^^^^^^^^ help: try: `f32::from(1u16)`

error: casting u16 to f64 may become silently lossy if types change
  --> $DIR/cast.rs:55:5
   |
55 |     1u16 as f64;
   |     ^^^^^^^^^^^ help: try: `f64::from(1u16)`

error: casting i32 to f64 may become silently lossy if types change
  --> $DIR/cast.rs:56:5
   |
56 |     1i32 as f64;
   |     ^^^^^^^^^^^ help: try: `f64::from(1i32)`

error: casting u32 to f64 may become silently lossy if types change
  --> $DIR/cast.rs:57:5
   |
57 |     1u32 as f64;
   |     ^^^^^^^^^^^ help: try: `f64::from(1u32)`

error: casting f32 to f64 may become silently lossy if types change
  --> $DIR/cast.rs:59:5
   |
59 |     1.0f32 as f64;
   |     ^^^^^^^^^^^^^ help: try: `f64::from(1.0f32)`

error: casting u8 to u16 may become silently lossy if types change
  --> $DIR/cast.rs:61:5
   |
61 |     (1u8 + 1u8) as u16;
   |     ^^^^^^^^^^^^^^^^^^ help: try: `u16::from(1u8 + 1u8)`

error: casting i32 to u32 may lose the sign of the value
  --> $DIR/cast.rs:63:5
   |
63 |     1i32 as u32;
   |     ^^^^^^^^^^^

error: casting isize to usize may lose the sign of the value
  --> $DIR/cast.rs:64:5
   |
64 |     1isize as usize;
   |     ^^^^^^^^^^^^^^^

error: casting isize to i8 may truncate the value
  --> $DIR/cast.rs:67:5
   |
67 |     1isize as i8;
   |     ^^^^^^^^^^^^

error: casting isize to f64 causes a loss of precision on targets with 64-bit wide pointers (isize is 64 bits wide, but f64's mantissa is only 52 bits wide)
  --> $DIR/cast.rs:68:5
   |
68 |     1isize as f64;
   |     ^^^^^^^^^^^^^

error: casting usize to f64 causes a loss of precision on targets with 64-bit wide pointers (usize is 64 bits wide, but f64's mantissa is only 52 bits wide)
  --> $DIR/cast.rs:69:5
   |
69 |     1usize as f64;
   |     ^^^^^^^^^^^^^

error: casting isize to f32 causes a loss of precision (isize is 32 or 64 bits wide, but f32's mantissa is only 23 bits wide)
  --> $DIR/cast.rs:70:5
   |
70 |     1isize as f32;
   |     ^^^^^^^^^^^^^

error: casting usize to f32 causes a loss of precision (usize is 32 or 64 bits wide, but f32's mantissa is only 23 bits wide)
  --> $DIR/cast.rs:71:5
   |
71 |     1usize as f32;
   |     ^^^^^^^^^^^^^

error: casting isize to i32 may truncate the value on targets with 64-bit wide pointers
  --> $DIR/cast.rs:72:5
   |
72 |     1isize as i32;
   |     ^^^^^^^^^^^^^

error: casting isize to u32 may lose the sign of the value
  --> $DIR/cast.rs:73:5
   |
73 |     1isize as u32;
   |     ^^^^^^^^^^^^^

error: casting isize to u32 may truncate the value on targets with 64-bit wide pointers
  --> $DIR/cast.rs:73:5
   |
73 |     1isize as u32;
   |     ^^^^^^^^^^^^^

error: casting usize to u32 may truncate the value on targets with 64-bit wide pointers
  --> $DIR/cast.rs:74:5
   |
74 |     1usize as u32;
   |     ^^^^^^^^^^^^^

error: casting usize to i32 may truncate the value on targets with 64-bit wide pointers
  --> $DIR/cast.rs:75:5
   |
75 |     1usize as i32;
   |     ^^^^^^^^^^^^^

error: casting usize to i32 may wrap around the value on targets with 32-bit wide pointers
  --> $DIR/cast.rs:75:5
   |
75 |     1usize as i32;
   |     ^^^^^^^^^^^^^

error: casting i64 to isize may truncate the value on targets with 32-bit wide pointers
  --> $DIR/cast.rs:77:5
   |
77 |     1i64 as isize;
   |     ^^^^^^^^^^^^^

error: casting i64 to usize may lose the sign of the value
  --> $DIR/cast.rs:78:5
   |
78 |     1i64 as usize;
   |     ^^^^^^^^^^^^^

error: casting i64 to usize may truncate the value on targets with 32-bit wide pointers
  --> $DIR/cast.rs:78:5
   |
78 |     1i64 as usize;
   |     ^^^^^^^^^^^^^

error: casting u64 to isize may truncate the value on targets with 32-bit wide pointers
  --> $DIR/cast.rs:79:5
   |
79 |     1u64 as isize;
   |     ^^^^^^^^^^^^^

error: casting u64 to isize may wrap around the value on targets with 64-bit wide pointers
  --> $DIR/cast.rs:79:5
   |
79 |     1u64 as isize;
   |     ^^^^^^^^^^^^^

error: casting u64 to usize may truncate the value on targets with 32-bit wide pointers
  --> $DIR/cast.rs:80:5
   |
80 |     1u64 as usize;
   |     ^^^^^^^^^^^^^

error: casting u32 to isize may wrap around the value on targets with 32-bit wide pointers
  --> $DIR/cast.rs:81:5
   |
81 |     1u32 as isize;
   |     ^^^^^^^^^^^^^

error: casting i32 to usize may lose the sign of the value
  --> $DIR/cast.rs:84:5
   |
84 |     1i32 as usize;
   |     ^^^^^^^^^^^^^

error: casting to the same type is unnecessary (`i32` -> `i32`)
  --> $DIR/cast.rs:86:5
   |
86 |     1i32 as i32;
   |     ^^^^^^^^^^^
   |
   = note: `-D unnecessary-cast` implied by `-D warnings`

error: casting to the same type is unnecessary (`f32` -> `f32`)
  --> $DIR/cast.rs:87:5
   |
87 |     1f32 as f32;
   |     ^^^^^^^^^^^

error: casting to the same type is unnecessary (`bool` -> `bool`)
  --> $DIR/cast.rs:88:5
   |
88 |     false as bool;
   |     ^^^^^^^^^^^^^

error: aborting due to 75 previous errors