]> git.lizzy.rs Git - rust.git/blob - src/tools/clippy/tests/ui/cast.stderr
Auto merge of #105650 - cassaundra:float-literal-suggestion, r=pnkfelix
[rust.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:14:5
3    |
4 LL |     x0 as f32;
5    |     ^^^^^^^^^
6    |
7    = note: `-D clippy::cast-precision-loss` implied by `-D warnings`
8
9 error: casting `i64` to `f32` causes a loss of precision (`i64` is 64 bits wide, but `f32`'s mantissa is only 23 bits wide)
10   --> $DIR/cast.rs:16:5
11    |
12 LL |     x1 as f32;
13    |     ^^^^^^^^^
14
15 error: casting `i64` to `f64` causes a loss of precision (`i64` is 64 bits wide, but `f64`'s mantissa is only 52 bits wide)
16   --> $DIR/cast.rs:17:5
17    |
18 LL |     x1 as f64;
19    |     ^^^^^^^^^
20
21 error: casting `u32` to `f32` causes a loss of precision (`u32` is 32 bits wide, but `f32`'s mantissa is only 23 bits wide)
22   --> $DIR/cast.rs:19:5
23    |
24 LL |     x2 as f32;
25    |     ^^^^^^^^^
26
27 error: casting `u64` to `f32` causes a loss of precision (`u64` is 64 bits wide, but `f32`'s mantissa is only 23 bits wide)
28   --> $DIR/cast.rs:21:5
29    |
30 LL |     x3 as f32;
31    |     ^^^^^^^^^
32
33 error: casting `u64` to `f64` causes a loss of precision (`u64` is 64 bits wide, but `f64`'s mantissa is only 52 bits wide)
34   --> $DIR/cast.rs:22:5
35    |
36 LL |     x3 as f64;
37    |     ^^^^^^^^^
38
39 error: casting `f32` to `i32` may truncate the value
40   --> $DIR/cast.rs:24:5
41    |
42 LL |     1f32 as i32;
43    |     ^^^^^^^^^^^
44    |
45    = help: if this is intentional allow the lint with `#[allow(clippy::cast_precision_loss)]` ...
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
52 error: casting `f32` to `u32` may truncate the value
53   --> $DIR/cast.rs:25:5
54    |
55 LL |     1f32 as u32;
56    |     ^^^^^^^^^^^
57    |
58    = help: if this is intentional allow the lint with `#[allow(clippy::cast_precision_loss)]` ...
59 help: ... or use `try_from` and handle the error accordingly
60    |
61 LL |     u32::try_from(1f32);
62    |     ~~~~~~~~~~~~~~~~~~~
63
64 error: casting `f32` to `u32` may lose the sign of the value
65   --> $DIR/cast.rs:25:5
66    |
67 LL |     1f32 as u32;
68    |     ^^^^^^^^^^^
69    |
70    = note: `-D clippy::cast-sign-loss` implied by `-D warnings`
71
72 error: casting `f64` to `f32` may truncate the value
73   --> $DIR/cast.rs:26:5
74    |
75 LL |     1f64 as f32;
76    |     ^^^^^^^^^^^
77    |
78    = help: if this is intentional allow the lint with `#[allow(clippy::cast_precision_loss)]` ...
79 help: ... or use `try_from` and handle the error accordingly
80    |
81 LL |     f32::try_from(1f64);
82    |     ~~~~~~~~~~~~~~~~~~~
83
84 error: casting `i32` to `i8` may truncate the value
85   --> $DIR/cast.rs:27:5
86    |
87 LL |     1i32 as i8;
88    |     ^^^^^^^^^^
89    |
90    = help: if this is intentional allow the lint with `#[allow(clippy::cast_precision_loss)]` ...
91 help: ... or use `try_from` and handle the error accordingly
92    |
93 LL |     i8::try_from(1i32);
94    |     ~~~~~~~~~~~~~~~~~~
95
96 error: casting `i32` to `u8` may truncate the value
97   --> $DIR/cast.rs:28:5
98    |
99 LL |     1i32 as u8;
100    |     ^^^^^^^^^^
101    |
102    = help: if this is intentional allow the lint with `#[allow(clippy::cast_precision_loss)]` ...
103 help: ... or use `try_from` and handle the error accordingly
104    |
105 LL |     u8::try_from(1i32);
106    |     ~~~~~~~~~~~~~~~~~~
107
108 error: casting `f64` to `isize` may truncate the value
109   --> $DIR/cast.rs:29:5
110    |
111 LL |     1f64 as isize;
112    |     ^^^^^^^^^^^^^
113    |
114    = help: if this is intentional allow the lint with `#[allow(clippy::cast_precision_loss)]` ...
115 help: ... or use `try_from` and handle the error accordingly
116    |
117 LL |     isize::try_from(1f64);
118    |     ~~~~~~~~~~~~~~~~~~~~~
119
120 error: casting `f64` to `usize` may truncate the value
121   --> $DIR/cast.rs:30:5
122    |
123 LL |     1f64 as usize;
124    |     ^^^^^^^^^^^^^
125    |
126    = help: if this is intentional allow the lint with `#[allow(clippy::cast_precision_loss)]` ...
127 help: ... or use `try_from` and handle the error accordingly
128    |
129 LL |     usize::try_from(1f64);
130    |     ~~~~~~~~~~~~~~~~~~~~~
131
132 error: casting `f64` to `usize` may lose the sign of the value
133   --> $DIR/cast.rs:30:5
134    |
135 LL |     1f64 as usize;
136    |     ^^^^^^^^^^^^^
137
138 error: casting `u32` to `u16` may truncate the value
139   --> $DIR/cast.rs:31:5
140    |
141 LL |     1f32 as u32 as u16;
142    |     ^^^^^^^^^^^^^^^^^^
143    |
144    = help: if this is intentional allow the lint with `#[allow(clippy::cast_precision_loss)]` ...
145 help: ... or use `try_from` and handle the error accordingly
146    |
147 LL |     u16::try_from(1f32 as u32);
148    |     ~~~~~~~~~~~~~~~~~~~~~~~~~~
149
150 error: casting `f32` to `u32` may truncate the value
151   --> $DIR/cast.rs:31:5
152    |
153 LL |     1f32 as u32 as u16;
154    |     ^^^^^^^^^^^
155    |
156    = help: if this is intentional allow the lint with `#[allow(clippy::cast_precision_loss)]` ...
157 help: ... or use `try_from` and handle the error accordingly
158    |
159 LL |     u32::try_from(1f32) as u16;
160    |     ~~~~~~~~~~~~~~~~~~~
161
162 error: casting `f32` to `u32` may lose the sign of the value
163   --> $DIR/cast.rs:31:5
164    |
165 LL |     1f32 as u32 as u16;
166    |     ^^^^^^^^^^^
167
168 error: casting `u8` to `i8` may wrap around the value
169   --> $DIR/cast.rs:33:5
170    |
171 LL |     1u8 as i8;
172    |     ^^^^^^^^^
173    |
174    = note: `-D clippy::cast-possible-wrap` implied by `-D warnings`
175
176 error: casting `u16` to `i16` may wrap around the value
177   --> $DIR/cast.rs:34:5
178    |
179 LL |     1u16 as i16;
180    |     ^^^^^^^^^^^
181
182 error: casting `u32` to `i32` may wrap around the value
183   --> $DIR/cast.rs:35:5
184    |
185 LL |     1u32 as i32;
186    |     ^^^^^^^^^^^
187
188 error: casting `u64` to `i64` may wrap around the value
189   --> $DIR/cast.rs:36:5
190    |
191 LL |     1u64 as i64;
192    |     ^^^^^^^^^^^
193
194 error: casting `usize` to `isize` may wrap around the value
195   --> $DIR/cast.rs:37:5
196    |
197 LL |     1usize as isize;
198    |     ^^^^^^^^^^^^^^^
199
200 error: casting `i32` to `u32` may lose the sign of the value
201   --> $DIR/cast.rs:40:5
202    |
203 LL |     -1i32 as u32;
204    |     ^^^^^^^^^^^^
205
206 error: casting `isize` to `usize` may lose the sign of the value
207   --> $DIR/cast.rs:42:5
208    |
209 LL |     -1isize as usize;
210    |     ^^^^^^^^^^^^^^^^
211
212 error: casting `i64` to `i8` may truncate the value
213   --> $DIR/cast.rs:109:5
214    |
215 LL |     (-99999999999i64).min(1) as i8; // should be linted because signed
216    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
217    |
218    = help: if this is intentional allow the lint with `#[allow(clippy::cast_precision_loss)]` ...
219 help: ... or use `try_from` and handle the error accordingly
220    |
221 LL |     i8::try_from((-99999999999i64).min(1)); // should be linted because signed
222    |     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
223
224 error: casting `u64` to `u8` may truncate the value
225   --> $DIR/cast.rs:121:5
226    |
227 LL |     999999u64.clamp(0, 256) as u8; // should still be linted
228    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
229    |
230    = help: if this is intentional allow the lint with `#[allow(clippy::cast_precision_loss)]` ...
231 help: ... or use `try_from` and handle the error accordingly
232    |
233 LL |     u8::try_from(999999u64.clamp(0, 256)); // should still be linted
234    |     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
235
236 error: casting `main::E2` to `u8` may truncate the value
237   --> $DIR/cast.rs:142:21
238    |
239 LL |             let _ = self as u8;
240    |                     ^^^^^^^^^^
241    |
242    = help: if this is intentional allow the lint with `#[allow(clippy::cast_precision_loss)]` ...
243 help: ... or use `try_from` and handle the error accordingly
244    |
245 LL |             let _ = u8::try_from(self);
246    |                     ~~~~~~~~~~~~~~~~~~
247
248 error: casting `main::E2::B` to `u8` will truncate the value
249   --> $DIR/cast.rs:143:21
250    |
251 LL |             let _ = Self::B as u8;
252    |                     ^^^^^^^^^^^^^
253    |
254    = note: `-D clippy::cast-enum-truncation` implied by `-D warnings`
255
256 error: casting `main::E5` to `i8` may truncate the value
257   --> $DIR/cast.rs:179:21
258    |
259 LL |             let _ = self as i8;
260    |                     ^^^^^^^^^^
261    |
262    = help: if this is intentional allow the lint with `#[allow(clippy::cast_precision_loss)]` ...
263 help: ... or use `try_from` and handle the error accordingly
264    |
265 LL |             let _ = i8::try_from(self);
266    |                     ~~~~~~~~~~~~~~~~~~
267
268 error: casting `main::E5::A` to `i8` will truncate the value
269   --> $DIR/cast.rs:180:21
270    |
271 LL |             let _ = Self::A as i8;
272    |                     ^^^^^^^^^^^^^
273
274 error: casting `main::E6` to `i16` may truncate the value
275   --> $DIR/cast.rs:194:21
276    |
277 LL |             let _ = self as i16;
278    |                     ^^^^^^^^^^^
279    |
280    = help: if this is intentional allow the lint with `#[allow(clippy::cast_precision_loss)]` ...
281 help: ... or use `try_from` and handle the error accordingly
282    |
283 LL |             let _ = i16::try_from(self);
284    |                     ~~~~~~~~~~~~~~~~~~~
285
286 error: casting `main::E7` to `usize` may truncate the value on targets with 32-bit wide pointers
287   --> $DIR/cast.rs:209:21
288    |
289 LL |             let _ = self as usize;
290    |                     ^^^^^^^^^^^^^
291    |
292    = help: if this is intentional allow the lint with `#[allow(clippy::cast_precision_loss)]` ...
293 help: ... or use `try_from` and handle the error accordingly
294    |
295 LL |             let _ = usize::try_from(self);
296    |                     ~~~~~~~~~~~~~~~~~~~~~
297
298 error: casting `main::E10` to `u16` may truncate the value
299   --> $DIR/cast.rs:250:21
300    |
301 LL |             let _ = self as u16;
302    |                     ^^^^^^^^^^^
303    |
304    = help: if this is intentional allow the lint with `#[allow(clippy::cast_precision_loss)]` ...
305 help: ... or use `try_from` and handle the error accordingly
306    |
307 LL |             let _ = u16::try_from(self);
308    |                     ~~~~~~~~~~~~~~~~~~~
309
310 error: casting `u32` to `u8` may truncate the value
311   --> $DIR/cast.rs:258:13
312    |
313 LL |     let c = (q >> 16) as u8;
314    |             ^^^^^^^^^^^^^^^
315    |
316    = help: if this is intentional allow the lint with `#[allow(clippy::cast_precision_loss)]` ...
317 help: ... or use `try_from` and handle the error accordingly
318    |
319 LL |     let c = u8::try_from((q >> 16));
320    |             ~~~~~~~~~~~~~~~~~~~~~~~
321
322 error: casting `u32` to `u8` may truncate the value
323   --> $DIR/cast.rs:261:13
324    |
325 LL |     let c = (q / 1000) as u8;
326    |             ^^^^^^^^^^^^^^^^
327    |
328    = help: if this is intentional allow the lint with `#[allow(clippy::cast_precision_loss)]` ...
329 help: ... or use `try_from` and handle the error accordingly
330    |
331 LL |     let c = u8::try_from((q / 1000));
332    |             ~~~~~~~~~~~~~~~~~~~~~~~~
333
334 error: aborting due to 36 previous errors
335