fork/rust

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

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

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