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)
7 = note: `-D clippy::cast-precision-loss` implied by `-D warnings`
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)
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)
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)
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)
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)
39 error: casting `f32` to `i32` may truncate the value
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
49 LL | i32::try_from(1f32);
52 error: casting `f32` to `u32` may truncate the value
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
61 LL | u32::try_from(1f32);
64 error: casting `f32` to `u32` may lose the sign of the value
70 = note: `-D clippy::cast-sign-loss` implied by `-D warnings`
72 error: casting `f64` to `f32` may truncate the value
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
81 LL | f32::try_from(1f64);
84 error: casting `i32` to `i8` may truncate the value
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
93 LL | i8::try_from(1i32);
96 error: casting `i32` to `u8` may truncate the value
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
105 LL | u8::try_from(1i32);
108 error: casting `f64` to `isize` may truncate the value
109 --> $DIR/cast.rs:29:5
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
117 LL | isize::try_from(1f64);
118 | ~~~~~~~~~~~~~~~~~~~~~
120 error: casting `f64` to `usize` may truncate the value
121 --> $DIR/cast.rs:30:5
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
129 LL | usize::try_from(1f64);
130 | ~~~~~~~~~~~~~~~~~~~~~
132 error: casting `f64` to `usize` may lose the sign of the value
133 --> $DIR/cast.rs:30:5
138 error: casting `u32` to `u16` may truncate the value
139 --> $DIR/cast.rs:31:5
141 LL | 1f32 as u32 as u16;
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
147 LL | u16::try_from(1f32 as u32);
148 | ~~~~~~~~~~~~~~~~~~~~~~~~~~
150 error: casting `f32` to `u32` may truncate the value
151 --> $DIR/cast.rs:31:5
153 LL | 1f32 as u32 as u16;
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
159 LL | u32::try_from(1f32) as u16;
160 | ~~~~~~~~~~~~~~~~~~~
162 error: casting `f32` to `u32` may lose the sign of the value
163 --> $DIR/cast.rs:31:5
165 LL | 1f32 as u32 as u16;
168 error: casting `u8` to `i8` may wrap around the value
169 --> $DIR/cast.rs:33:5
174 = note: `-D clippy::cast-possible-wrap` implied by `-D warnings`
176 error: casting `u16` to `i16` may wrap around the value
177 --> $DIR/cast.rs:34:5
182 error: casting `u32` to `i32` may wrap around the value
183 --> $DIR/cast.rs:35:5
188 error: casting `u64` to `i64` may wrap around the value
189 --> $DIR/cast.rs:36:5
194 error: casting `usize` to `isize` may wrap around the value
195 --> $DIR/cast.rs:37:5
197 LL | 1usize as isize;
200 error: casting `i32` to `u32` may lose the sign of the value
201 --> $DIR/cast.rs:40:5
206 error: casting `isize` to `usize` may lose the sign of the value
207 --> $DIR/cast.rs:42:5
209 LL | -1isize as usize;
212 error: casting `i64` to `i8` may truncate the value
213 --> $DIR/cast.rs:109:5
215 LL | (-99999999999i64).min(1) as i8; // should be linted because signed
216 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
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
221 LL | i8::try_from((-99999999999i64).min(1)); // should be linted because signed
222 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
224 error: casting `u64` to `u8` may truncate the value
225 --> $DIR/cast.rs:121:5
227 LL | 999999u64.clamp(0, 256) as u8; // should still be linted
228 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
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
233 LL | u8::try_from(999999u64.clamp(0, 256)); // should still be linted
234 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
236 error: casting `main::E2` to `u8` may truncate the value
237 --> $DIR/cast.rs:142:21
239 LL | let _ = self as u8;
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
245 LL | let _ = u8::try_from(self);
248 error: casting `main::E2::B` to `u8` will truncate the value
249 --> $DIR/cast.rs:143:21
251 LL | let _ = Self::B as u8;
254 = note: `-D clippy::cast-enum-truncation` implied by `-D warnings`
256 error: casting `main::E5` to `i8` may truncate the value
257 --> $DIR/cast.rs:179:21
259 LL | let _ = self as i8;
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
265 LL | let _ = i8::try_from(self);
268 error: casting `main::E5::A` to `i8` will truncate the value
269 --> $DIR/cast.rs:180:21
271 LL | let _ = Self::A as i8;
274 error: casting `main::E6` to `i16` may truncate the value
275 --> $DIR/cast.rs:194:21
277 LL | let _ = self as i16;
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
283 LL | let _ = i16::try_from(self);
284 | ~~~~~~~~~~~~~~~~~~~
286 error: casting `main::E7` to `usize` may truncate the value on targets with 32-bit wide pointers
287 --> $DIR/cast.rs:209:21
289 LL | let _ = self as usize;
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
295 LL | let _ = usize::try_from(self);
296 | ~~~~~~~~~~~~~~~~~~~~~
298 error: casting `main::E10` to `u16` may truncate the value
299 --> $DIR/cast.rs:250:21
301 LL | let _ = self as u16;
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
307 LL | let _ = u16::try_from(self);
308 | ~~~~~~~~~~~~~~~~~~~
310 error: casting `u32` to `u8` may truncate the value
311 --> $DIR/cast.rs:258:13
313 LL | let c = (q >> 16) as u8;
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
319 LL | let c = u8::try_from((q >> 16));
320 | ~~~~~~~~~~~~~~~~~~~~~~~
322 error: casting `u32` to `u8` may truncate the value
323 --> $DIR/cast.rs:261:13
325 LL | let c = (q / 1000) as u8;
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
331 LL | let c = u8::try_from((q / 1000));
332 | ~~~~~~~~~~~~~~~~~~~~~~~~
334 error: aborting due to 36 previous errors