@@ -44,10 +44,6 @@ LL | 1f32 as i32;
44
44
|
45
45
= help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ...
46
46
= note: `-D clippy::cast-possible-truncation` implied by `-D warnings`
47
- help: ... or use `try_from` and handle the error accordingly
48
- |
49
- LL | i32::try_from(1f32);
50
- | ~~~~~~~~~~~~~~~~~~~
51
47
52
48
error: casting `f32` to `u32` may truncate the value
53
49
--> $DIR/cast.rs:25:5
@@ -56,10 +52,6 @@ LL | 1f32 as u32;
56
52
| ^^^^^^^^^^^
57
53
|
58
54
= help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ...
59
- help: ... or use `try_from` and handle the error accordingly
60
- |
61
- LL | u32::try_from(1f32);
62
- | ~~~~~~~~~~~~~~~~~~~
63
55
64
56
error: casting `f32` to `u32` may lose the sign of the value
65
57
--> $DIR/cast.rs:25:5
@@ -76,10 +68,6 @@ LL | 1f64 as f32;
76
68
| ^^^^^^^^^^^
77
69
|
78
70
= help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ...
79
- help: ... or use `try_from` and handle the error accordingly
80
- |
81
- LL | f32::try_from(1f64);
82
- | ~~~~~~~~~~~~~~~~~~~
83
71
84
72
error: casting `i32` to `i8` may truncate the value
85
73
--> $DIR/cast.rs:27:5
@@ -112,10 +100,6 @@ LL | 1f64 as isize;
112
100
| ^^^^^^^^^^^^^
113
101
|
114
102
= help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ...
115
- help: ... or use `try_from` and handle the error accordingly
116
- |
117
- LL | isize::try_from(1f64);
118
- | ~~~~~~~~~~~~~~~~~~~~~
119
103
120
104
error: casting `f64` to `usize` may truncate the value
121
105
--> $DIR/cast.rs:30:5
@@ -124,10 +108,6 @@ LL | 1f64 as usize;
124
108
| ^^^^^^^^^^^^^
125
109
|
126
110
= help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ...
127
- help: ... or use `try_from` and handle the error accordingly
128
- |
129
- LL | usize::try_from(1f64);
130
- | ~~~~~~~~~~~~~~~~~~~~~
131
111
132
112
error: casting `f64` to `usize` may lose the sign of the value
133
113
--> $DIR/cast.rs:30:5
@@ -154,63 +134,101 @@ LL | 1f32 as u32 as u16;
154
134
| ^^^^^^^^^^^
155
135
|
156
136
= help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ...
157
- help: ... or use `try_from` and handle the error accordingly
158
- |
159
- LL | u32::try_from(1f32) as u16;
160
- | ~~~~~~~~~~~~~~~~~~~
161
137
162
138
error: casting `f32` to `u32` may lose the sign of the value
163
139
--> $DIR/cast.rs:31:5
164
140
|
165
141
LL | 1f32 as u32 as u16;
166
142
| ^^^^^^^^^^^
167
143
144
+ error: casting `i32` to `i8` may truncate the value
145
+ --> $DIR/cast.rs:33:22
146
+ |
147
+ LL | let _x: i8 = 1i32 as _;
148
+ | ^^^^^^^^^
149
+ |
150
+ = help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ...
151
+ help: ... or use `try_from` and handle the error accordingly
152
+ |
153
+ LL | let _x: i8 = 1i32.try_into();
154
+ | ~~~~~~~~~~~~~~~
155
+
156
+ error: casting `f32` to `i32` may truncate the value
157
+ --> $DIR/cast.rs:34:9
158
+ |
159
+ LL | 1f32 as i32;
160
+ | ^^^^^^^^^^^
161
+ |
162
+ = help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ...
163
+
164
+ error: casting `f64` to `i32` may truncate the value
165
+ --> $DIR/cast.rs:35:9
166
+ |
167
+ LL | 1f64 as i32;
168
+ | ^^^^^^^^^^^
169
+ |
170
+ = help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ...
171
+
172
+ error: casting `f32` to `u8` may truncate the value
173
+ --> $DIR/cast.rs:36:9
174
+ |
175
+ LL | 1f32 as u8;
176
+ | ^^^^^^^^^^
177
+ |
178
+ = help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ...
179
+
180
+ error: casting `f32` to `u8` may lose the sign of the value
181
+ --> $DIR/cast.rs:36:9
182
+ |
183
+ LL | 1f32 as u8;
184
+ | ^^^^^^^^^^
185
+
168
186
error: casting `u8` to `i8` may wrap around the value
169
- --> $DIR/cast.rs:33 :5
187
+ --> $DIR/cast.rs:39 :5
170
188
|
171
189
LL | 1u8 as i8;
172
190
| ^^^^^^^^^
173
191
|
174
192
= note: `-D clippy::cast-possible-wrap` implied by `-D warnings`
175
193
176
194
error: casting `u16` to `i16` may wrap around the value
177
- --> $DIR/cast.rs:34 :5
195
+ --> $DIR/cast.rs:40 :5
178
196
|
179
197
LL | 1u16 as i16;
180
198
| ^^^^^^^^^^^
181
199
182
200
error: casting `u32` to `i32` may wrap around the value
183
- --> $DIR/cast.rs:35 :5
201
+ --> $DIR/cast.rs:41 :5
184
202
|
185
203
LL | 1u32 as i32;
186
204
| ^^^^^^^^^^^
187
205
188
206
error: casting `u64` to `i64` may wrap around the value
189
- --> $DIR/cast.rs:36 :5
207
+ --> $DIR/cast.rs:42 :5
190
208
|
191
209
LL | 1u64 as i64;
192
210
| ^^^^^^^^^^^
193
211
194
212
error: casting `usize` to `isize` may wrap around the value
195
- --> $DIR/cast.rs:37 :5
213
+ --> $DIR/cast.rs:43 :5
196
214
|
197
215
LL | 1usize as isize;
198
216
| ^^^^^^^^^^^^^^^
199
217
200
218
error: casting `i32` to `u32` may lose the sign of the value
201
- --> $DIR/cast.rs:40 :5
219
+ --> $DIR/cast.rs:46 :5
202
220
|
203
221
LL | -1i32 as u32;
204
222
| ^^^^^^^^^^^^
205
223
206
224
error: casting `isize` to `usize` may lose the sign of the value
207
- --> $DIR/cast.rs:42 :5
225
+ --> $DIR/cast.rs:48 :5
208
226
|
209
227
LL | -1isize as usize;
210
228
| ^^^^^^^^^^^^^^^^
211
229
212
230
error: casting `i64` to `i8` may truncate the value
213
- --> $DIR/cast.rs:109 :5
231
+ --> $DIR/cast.rs:115 :5
214
232
|
215
233
LL | (-99999999999i64).min(1) as i8; // should be linted because signed
216
234
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -222,7 +240,7 @@ LL | i8::try_from((-99999999999i64).min(1)); // should be linted because sig
222
240
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
223
241
224
242
error: casting `u64` to `u8` may truncate the value
225
- --> $DIR/cast.rs:121 :5
243
+ --> $DIR/cast.rs:127 :5
226
244
|
227
245
LL | 999999u64.clamp(0, 256) as u8; // should still be linted
228
246
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -234,7 +252,7 @@ LL | u8::try_from(999999u64.clamp(0, 256)); // should still be linted
234
252
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
235
253
236
254
error: casting `main::E2` to `u8` may truncate the value
237
- --> $DIR/cast.rs:142 :21
255
+ --> $DIR/cast.rs:148 :21
238
256
|
239
257
LL | let _ = self as u8;
240
258
| ^^^^^^^^^^
@@ -246,15 +264,15 @@ LL | let _ = u8::try_from(self);
246
264
| ~~~~~~~~~~~~~~~~~~
247
265
248
266
error: casting `main::E2::B` to `u8` will truncate the value
249
- --> $DIR/cast.rs:143 :21
267
+ --> $DIR/cast.rs:149 :21
250
268
|
251
269
LL | let _ = Self::B as u8;
252
270
| ^^^^^^^^^^^^^
253
271
|
254
272
= note: `-D clippy::cast-enum-truncation` implied by `-D warnings`
255
273
256
274
error: casting `main::E5` to `i8` may truncate the value
257
- --> $DIR/cast.rs:179 :21
275
+ --> $DIR/cast.rs:185 :21
258
276
|
259
277
LL | let _ = self as i8;
260
278
| ^^^^^^^^^^
@@ -266,13 +284,13 @@ LL | let _ = i8::try_from(self);
266
284
| ~~~~~~~~~~~~~~~~~~
267
285
268
286
error: casting `main::E5::A` to `i8` will truncate the value
269
- --> $DIR/cast.rs:180 :21
287
+ --> $DIR/cast.rs:186 :21
270
288
|
271
289
LL | let _ = Self::A as i8;
272
290
| ^^^^^^^^^^^^^
273
291
274
292
error: casting `main::E6` to `i16` may truncate the value
275
- --> $DIR/cast.rs:194 :21
293
+ --> $DIR/cast.rs:200 :21
276
294
|
277
295
LL | let _ = self as i16;
278
296
| ^^^^^^^^^^^
@@ -284,7 +302,7 @@ LL | let _ = i16::try_from(self);
284
302
| ~~~~~~~~~~~~~~~~~~~
285
303
286
304
error: casting `main::E7` to `usize` may truncate the value on targets with 32-bit wide pointers
287
- --> $DIR/cast.rs:209 :21
305
+ --> $DIR/cast.rs:215 :21
288
306
|
289
307
LL | let _ = self as usize;
290
308
| ^^^^^^^^^^^^^
@@ -296,7 +314,7 @@ LL | let _ = usize::try_from(self);
296
314
| ~~~~~~~~~~~~~~~~~~~~~
297
315
298
316
error: casting `main::E10` to `u16` may truncate the value
299
- --> $DIR/cast.rs:250 :21
317
+ --> $DIR/cast.rs:256 :21
300
318
|
301
319
LL | let _ = self as u16;
302
320
| ^^^^^^^^^^^
@@ -308,28 +326,28 @@ LL | let _ = u16::try_from(self);
308
326
| ~~~~~~~~~~~~~~~~~~~
309
327
310
328
error: casting `u32` to `u8` may truncate the value
311
- --> $DIR/cast.rs:258 :13
329
+ --> $DIR/cast.rs:264 :13
312
330
|
313
331
LL | let c = (q >> 16) as u8;
314
332
| ^^^^^^^^^^^^^^^
315
333
|
316
334
= help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ...
317
335
help: ... or use `try_from` and handle the error accordingly
318
336
|
319
- LL | let c = u8::try_from(( q >> 16) );
320
- | ~~~~~~~~~~~~~~~~~~~~~~~
337
+ LL | let c = u8::try_from(q >> 16);
338
+ | ~~~~~~~~~~~~~~~~~~~~~
321
339
322
340
error: casting `u32` to `u8` may truncate the value
323
- --> $DIR/cast.rs:261 :13
341
+ --> $DIR/cast.rs:267 :13
324
342
|
325
343
LL | let c = (q / 1000) as u8;
326
344
| ^^^^^^^^^^^^^^^^
327
345
|
328
346
= help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ...
329
347
help: ... or use `try_from` and handle the error accordingly
330
348
|
331
- LL | let c = u8::try_from(( q / 1000) );
332
- | ~~~~~~~~~~~~~~~~~~~~~~~~
349
+ LL | let c = u8::try_from(q / 1000);
350
+ | ~~~~~~~~~~~~~~~~~~~~~~
333
351
334
- error: aborting due to 36 previous errors
352
+ error: aborting due to 41 previous errors
335
353
0 commit comments