]> git.proxmox.com Git - rustc.git/blob - src/tools/clippy/tests/ui/cast.stderr
New upstream version 1.74.1+dfsg1
[rustc.git] / src / tools / clippy / tests / ui / cast.stderr
1 error: casting `i32` to `f32` causes a loss of precision (`i32` is 32 bits wide, but `f32`'s mantissa is only 23 bits wide)
2 --> $DIR/cast.rs:16:5
3 |
4 LL | x0 as f32;
5 | ^^^^^^^^^
6 |
7 = note: `-D clippy::cast-precision-loss` implied by `-D warnings`
8 = help: to override `-D warnings` add `#[allow(clippy::cast_precision_loss)]`
9
10 error: casting `i64` to `f32` causes a loss of precision (`i64` is 64 bits wide, but `f32`'s mantissa is only 23 bits wide)
11 --> $DIR/cast.rs:20:5
12 |
13 LL | x1 as f32;
14 | ^^^^^^^^^
15
16 error: casting `i64` to `f64` causes a loss of precision (`i64` is 64 bits wide, but `f64`'s mantissa is only 52 bits wide)
17 --> $DIR/cast.rs:22:5
18 |
19 LL | x1 as f64;
20 | ^^^^^^^^^
21
22 error: casting `u32` to `f32` causes a loss of precision (`u32` is 32 bits wide, but `f32`'s mantissa is only 23 bits wide)
23 --> $DIR/cast.rs:25:5
24 |
25 LL | x2 as f32;
26 | ^^^^^^^^^
27
28 error: casting `u64` to `f32` causes a loss of precision (`u64` is 64 bits wide, but `f32`'s mantissa is only 23 bits wide)
29 --> $DIR/cast.rs:28:5
30 |
31 LL | x3 as f32;
32 | ^^^^^^^^^
33
34 error: casting `u64` to `f64` causes a loss of precision (`u64` is 64 bits wide, but `f64`'s mantissa is only 52 bits wide)
35 --> $DIR/cast.rs:30:5
36 |
37 LL | x3 as f64;
38 | ^^^^^^^^^
39
40 error: casting `f32` to `i32` may truncate the value
41 --> $DIR/cast.rs:33:5
42 |
43 LL | 1f32 as i32;
44 | ^^^^^^^^^^^
45 |
46 = help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ...
47 = note: `-D clippy::cast-possible-truncation` implied by `-D warnings`
48 = help: to override `-D warnings` add `#[allow(clippy::cast_possible_truncation)]`
49
50 error: casting `f32` to `u32` may truncate the value
51 --> $DIR/cast.rs:35:5
52 |
53 LL | 1f32 as u32;
54 | ^^^^^^^^^^^
55 |
56 = help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ...
57
58 error: casting `f32` to `u32` may lose the sign of the value
59 --> $DIR/cast.rs:35:5
60 |
61 LL | 1f32 as u32;
62 | ^^^^^^^^^^^
63 |
64 = note: `-D clippy::cast-sign-loss` implied by `-D warnings`
65 = help: to override `-D warnings` add `#[allow(clippy::cast_sign_loss)]`
66
67 error: casting `f64` to `f32` may truncate the value
68 --> $DIR/cast.rs:39:5
69 |
70 LL | 1f64 as f32;
71 | ^^^^^^^^^^^
72 |
73 = help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ...
74
75 error: casting `i32` to `i8` may truncate the value
76 --> $DIR/cast.rs:41:5
77 |
78 LL | 1i32 as i8;
79 | ^^^^^^^^^^
80 |
81 = help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ...
82 help: ... or use `try_from` and handle the error accordingly
83 |
84 LL | i8::try_from(1i32);
85 | ~~~~~~~~~~~~~~~~~~
86
87 error: casting `i32` to `u8` may truncate the value
88 --> $DIR/cast.rs:43:5
89 |
90 LL | 1i32 as u8;
91 | ^^^^^^^^^^
92 |
93 = help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ...
94 help: ... or use `try_from` and handle the error accordingly
95 |
96 LL | u8::try_from(1i32);
97 | ~~~~~~~~~~~~~~~~~~
98
99 error: casting `f64` to `isize` may truncate the value
100 --> $DIR/cast.rs:45:5
101 |
102 LL | 1f64 as isize;
103 | ^^^^^^^^^^^^^
104 |
105 = help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ...
106
107 error: casting `f64` to `usize` may truncate the value
108 --> $DIR/cast.rs:47:5
109 |
110 LL | 1f64 as usize;
111 | ^^^^^^^^^^^^^
112 |
113 = help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ...
114
115 error: casting `f64` to `usize` may lose the sign of the value
116 --> $DIR/cast.rs:47:5
117 |
118 LL | 1f64 as usize;
119 | ^^^^^^^^^^^^^
120
121 error: casting `u32` to `u16` may truncate the value
122 --> $DIR/cast.rs:50:5
123 |
124 LL | 1f32 as u32 as u16;
125 | ^^^^^^^^^^^^^^^^^^
126 |
127 = help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ...
128 help: ... or use `try_from` and handle the error accordingly
129 |
130 LL | u16::try_from(1f32 as u32);
131 | ~~~~~~~~~~~~~~~~~~~~~~~~~~
132
133 error: casting `f32` to `u32` may truncate the value
134 --> $DIR/cast.rs:50:5
135 |
136 LL | 1f32 as u32 as u16;
137 | ^^^^^^^^^^^
138 |
139 = help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ...
140
141 error: casting `f32` to `u32` may lose the sign of the value
142 --> $DIR/cast.rs:50:5
143 |
144 LL | 1f32 as u32 as u16;
145 | ^^^^^^^^^^^
146
147 error: casting `i32` to `i8` may truncate the value
148 --> $DIR/cast.rs:55:22
149 |
150 LL | let _x: i8 = 1i32 as _;
151 | ^^^^^^^^^
152 |
153 = help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ...
154 help: ... or use `try_from` and handle the error accordingly
155 |
156 LL | let _x: i8 = 1i32.try_into();
157 | ~~~~~~~~~~~~~~~
158
159 error: casting `f32` to `i32` may truncate the value
160 --> $DIR/cast.rs:57:9
161 |
162 LL | 1f32 as i32;
163 | ^^^^^^^^^^^
164 |
165 = help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ...
166
167 error: casting `f64` to `i32` may truncate the value
168 --> $DIR/cast.rs:59:9
169 |
170 LL | 1f64 as i32;
171 | ^^^^^^^^^^^
172 |
173 = help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ...
174
175 error: casting `f32` to `u8` may truncate the value
176 --> $DIR/cast.rs:61:9
177 |
178 LL | 1f32 as u8;
179 | ^^^^^^^^^^
180 |
181 = help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ...
182
183 error: casting `f32` to `u8` may lose the sign of the value
184 --> $DIR/cast.rs:61:9
185 |
186 LL | 1f32 as u8;
187 | ^^^^^^^^^^
188
189 error: casting `u8` to `i8` may wrap around the value
190 --> $DIR/cast.rs:66:5
191 |
192 LL | 1u8 as i8;
193 | ^^^^^^^^^
194 |
195 = note: `-D clippy::cast-possible-wrap` implied by `-D warnings`
196 = help: to override `-D warnings` add `#[allow(clippy::cast_possible_wrap)]`
197
198 error: casting `u16` to `i16` may wrap around the value
199 --> $DIR/cast.rs:69:5
200 |
201 LL | 1u16 as i16;
202 | ^^^^^^^^^^^
203
204 error: casting `u32` to `i32` may wrap around the value
205 --> $DIR/cast.rs:71:5
206 |
207 LL | 1u32 as i32;
208 | ^^^^^^^^^^^
209
210 error: casting `u64` to `i64` may wrap around the value
211 --> $DIR/cast.rs:73:5
212 |
213 LL | 1u64 as i64;
214 | ^^^^^^^^^^^
215
216 error: casting `usize` to `isize` may wrap around the value
217 --> $DIR/cast.rs:75:5
218 |
219 LL | 1usize as isize;
220 | ^^^^^^^^^^^^^^^
221
222 error: casting `usize` to `i8` may truncate the value
223 --> $DIR/cast.rs:78:5
224 |
225 LL | 1usize as i8;
226 | ^^^^^^^^^^^^
227 |
228 = help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ...
229 help: ... or use `try_from` and handle the error accordingly
230 |
231 LL | i8::try_from(1usize);
232 | ~~~~~~~~~~~~~~~~~~~~
233
234 error: casting `usize` to `i16` may truncate the value
235 --> $DIR/cast.rs:81:5
236 |
237 LL | 1usize as i16;
238 | ^^^^^^^^^^^^^
239 |
240 = help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ...
241 help: ... or use `try_from` and handle the error accordingly
242 |
243 LL | i16::try_from(1usize);
244 | ~~~~~~~~~~~~~~~~~~~~~
245
246 error: casting `usize` to `i16` may wrap around the value on targets with 16-bit wide pointers
247 --> $DIR/cast.rs:81:5
248 |
249 LL | 1usize as i16;
250 | ^^^^^^^^^^^^^
251 |
252 = note: `usize` and `isize` may be as small as 16 bits on some platforms
253 = note: for more information see https://doc.rust-lang.org/reference/types/numeric.html#machine-dependent-integer-types
254
255 error: casting `usize` to `i32` may truncate the value on targets with 64-bit wide pointers
256 --> $DIR/cast.rs:86:5
257 |
258 LL | 1usize as i32;
259 | ^^^^^^^^^^^^^
260 |
261 = help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ...
262 help: ... or use `try_from` and handle the error accordingly
263 |
264 LL | i32::try_from(1usize);
265 | ~~~~~~~~~~~~~~~~~~~~~
266
267 error: casting `usize` to `i32` may wrap around the value on targets with 32-bit wide pointers
268 --> $DIR/cast.rs:86:5
269 |
270 LL | 1usize as i32;
271 | ^^^^^^^^^^^^^
272
273 error: casting `usize` to `i64` may wrap around the value on targets with 64-bit wide pointers
274 --> $DIR/cast.rs:90:5
275 |
276 LL | 1usize as i64;
277 | ^^^^^^^^^^^^^
278
279 error: casting `u16` to `isize` may wrap around the value on targets with 16-bit wide pointers
280 --> $DIR/cast.rs:95:5
281 |
282 LL | 1u16 as isize;
283 | ^^^^^^^^^^^^^
284 |
285 = note: `usize` and `isize` may be as small as 16 bits on some platforms
286 = note: for more information see https://doc.rust-lang.org/reference/types/numeric.html#machine-dependent-integer-types
287
288 error: casting `u32` to `isize` may wrap around the value on targets with 32-bit wide pointers
289 --> $DIR/cast.rs:99:5
290 |
291 LL | 1u32 as isize;
292 | ^^^^^^^^^^^^^
293
294 error: casting `u64` to `isize` may truncate the value on targets with 32-bit wide pointers
295 --> $DIR/cast.rs:102:5
296 |
297 LL | 1u64 as isize;
298 | ^^^^^^^^^^^^^
299 |
300 = help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ...
301 help: ... or use `try_from` and handle the error accordingly
302 |
303 LL | isize::try_from(1u64);
304 | ~~~~~~~~~~~~~~~~~~~~~
305
306 error: casting `u64` to `isize` may wrap around the value on targets with 64-bit wide pointers
307 --> $DIR/cast.rs:102:5
308 |
309 LL | 1u64 as isize;
310 | ^^^^^^^^^^^^^
311
312 error: casting `i32` to `u32` may lose the sign of the value
313 --> $DIR/cast.rs:107:5
314 |
315 LL | -1i32 as u32;
316 | ^^^^^^^^^^^^
317
318 error: casting `isize` to `usize` may lose the sign of the value
319 --> $DIR/cast.rs:110:5
320 |
321 LL | -1isize as usize;
322 | ^^^^^^^^^^^^^^^^
323
324 error: casting `i64` to `i8` may truncate the value
325 --> $DIR/cast.rs:179:5
326 |
327 LL | (-99999999999i64).min(1) as i8;
328 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
329 |
330 = help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ...
331 help: ... or use `try_from` and handle the error accordingly
332 |
333 LL | i8::try_from((-99999999999i64).min(1));
334 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
335
336 error: casting `u64` to `u8` may truncate the value
337 --> $DIR/cast.rs:193:5
338 |
339 LL | 999999u64.clamp(0, 256) as u8;
340 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
341 |
342 = help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ...
343 help: ... or use `try_from` and handle the error accordingly
344 |
345 LL | u8::try_from(999999u64.clamp(0, 256));
346 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
347
348 error: casting `main::E2` to `u8` may truncate the value
349 --> $DIR/cast.rs:216:21
350 |
351 LL | let _ = self as u8;
352 | ^^^^^^^^^^
353 |
354 = help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ...
355 help: ... or use `try_from` and handle the error accordingly
356 |
357 LL | let _ = u8::try_from(self);
358 | ~~~~~~~~~~~~~~~~~~
359
360 error: casting `main::E2::B` to `u8` will truncate the value
361 --> $DIR/cast.rs:218:21
362 |
363 LL | let _ = Self::B as u8;
364 | ^^^^^^^^^^^^^
365 |
366 = note: `-D clippy::cast-enum-truncation` implied by `-D warnings`
367 = help: to override `-D warnings` add `#[allow(clippy::cast_enum_truncation)]`
368
369 error: casting `main::E5` to `i8` may truncate the value
370 --> $DIR/cast.rs:260:21
371 |
372 LL | let _ = self as i8;
373 | ^^^^^^^^^^
374 |
375 = help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ...
376 help: ... or use `try_from` and handle the error accordingly
377 |
378 LL | let _ = i8::try_from(self);
379 | ~~~~~~~~~~~~~~~~~~
380
381 error: casting `main::E5::A` to `i8` will truncate the value
382 --> $DIR/cast.rs:262:21
383 |
384 LL | let _ = Self::A as i8;
385 | ^^^^^^^^^^^^^
386
387 error: casting `main::E6` to `i16` may truncate the value
388 --> $DIR/cast.rs:279:21
389 |
390 LL | let _ = self as i16;
391 | ^^^^^^^^^^^
392 |
393 = help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ...
394 help: ... or use `try_from` and handle the error accordingly
395 |
396 LL | let _ = i16::try_from(self);
397 | ~~~~~~~~~~~~~~~~~~~
398
399 error: casting `main::E7` to `usize` may truncate the value on targets with 32-bit wide pointers
400 --> $DIR/cast.rs:298:21
401 |
402 LL | let _ = self as usize;
403 | ^^^^^^^^^^^^^
404 |
405 = help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ...
406 help: ... or use `try_from` and handle the error accordingly
407 |
408 LL | let _ = usize::try_from(self);
409 | ~~~~~~~~~~~~~~~~~~~~~
410
411 error: casting `main::E10` to `u16` may truncate the value
412 --> $DIR/cast.rs:345:21
413 |
414 LL | let _ = self as u16;
415 | ^^^^^^^^^^^
416 |
417 = help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ...
418 help: ... or use `try_from` and handle the error accordingly
419 |
420 LL | let _ = u16::try_from(self);
421 | ~~~~~~~~~~~~~~~~~~~
422
423 error: casting `u32` to `u8` may truncate the value
424 --> $DIR/cast.rs:356:13
425 |
426 LL | let c = (q >> 16) as u8;
427 | ^^^^^^^^^^^^^^^
428 |
429 = help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ...
430 help: ... or use `try_from` and handle the error accordingly
431 |
432 LL | let c = u8::try_from(q >> 16);
433 | ~~~~~~~~~~~~~~~~~~~~~
434
435 error: casting `u32` to `u8` may truncate the value
436 --> $DIR/cast.rs:360:13
437 |
438 LL | let c = (q / 1000) as u8;
439 | ^^^^^^^^^^^^^^^^
440 |
441 = help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ...
442 help: ... or use `try_from` and handle the error accordingly
443 |
444 LL | let c = u8::try_from(q / 1000);
445 | ~~~~~~~~~~~~~~~~~~~~~~
446
447 error: aborting due to 51 previous errors
448