@@ -148,8 +148,56 @@ error: transmute from a `i128` to a `f128`
148
148
LL | let _: f128 = unsafe { std::mem::transmute(0_i128) };
149
149
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `f128::from_bits(0_i128 as u128)`
150
150
151
+ error: transmute from a `u16` to a `f16`
152
+ --> tests/ui/transmute.rs:142:39
153
+ |
154
+ LL | const VALUE16: f16 = unsafe { std::mem::transmute(0_u16) };
155
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `f16::from_bits(0_u16)`
156
+
157
+ error: transmute from a `u32` to a `f32`
158
+ --> tests/ui/transmute.rs:144:39
159
+ |
160
+ LL | const VALUE32: f32 = unsafe { std::mem::transmute(0_u32) };
161
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `f32::from_bits(0_u32)`
162
+
163
+ error: transmute from a `i64` to a `f64`
164
+ --> tests/ui/transmute.rs:146:39
165
+ |
166
+ LL | const VALUE64: f64 = unsafe { std::mem::transmute(0_i64) };
167
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `f64::from_bits(0_i64 as u64)`
168
+
169
+ error: transmute from a `i128` to a `f128`
170
+ --> tests/ui/transmute.rs:148:41
171
+ |
172
+ LL | const VALUE128: f128 = unsafe { std::mem::transmute(0_i128) };
173
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `f128::from_bits(0_i128 as u128)`
174
+
175
+ error: transmute from a `i16` to a `f16`
176
+ --> tests/ui/transmute.rs:152:22
177
+ |
178
+ LL | unsafe { std::mem::transmute(v) }
179
+ | ^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `f16::from_bits(v as u16)`
180
+
181
+ error: transmute from a `i32` to a `f32`
182
+ --> tests/ui/transmute.rs:157:22
183
+ |
184
+ LL | unsafe { std::mem::transmute(v) }
185
+ | ^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `f32::from_bits(v as u32)`
186
+
187
+ error: transmute from a `u64` to a `f64`
188
+ --> tests/ui/transmute.rs:162:22
189
+ |
190
+ LL | unsafe { std::mem::transmute(v) }
191
+ | ^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `f64::from_bits(v)`
192
+
193
+ error: transmute from a `u128` to a `f128`
194
+ --> tests/ui/transmute.rs:167:22
195
+ |
196
+ LL | unsafe { std::mem::transmute(v) }
197
+ | ^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `f128::from_bits(v)`
198
+
151
199
error: transmute from a `u8` to a `[u8; 1]`
152
- --> tests/ui/transmute.rs:168 :30
200
+ --> tests/ui/transmute.rs:176 :30
153
201
|
154
202
LL | let _: [u8; 1] = std::mem::transmute(0u8);
155
203
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0u8.to_ne_bytes()`
@@ -158,97 +206,121 @@ LL | let _: [u8; 1] = std::mem::transmute(0u8);
158
206
= help: to override `-D warnings` add `#[allow(clippy::transmute_num_to_bytes)]`
159
207
160
208
error: transmute from a `u32` to a `[u8; 4]`
161
- --> tests/ui/transmute.rs:171 :30
209
+ --> tests/ui/transmute.rs:179 :30
162
210
|
163
211
LL | let _: [u8; 4] = std::mem::transmute(0u32);
164
212
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0u32.to_ne_bytes()`
165
213
166
214
error: transmute from a `u128` to a `[u8; 16]`
167
- --> tests/ui/transmute.rs:173 :31
215
+ --> tests/ui/transmute.rs:181 :31
168
216
|
169
217
LL | let _: [u8; 16] = std::mem::transmute(0u128);
170
218
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0u128.to_ne_bytes()`
171
219
172
220
error: transmute from a `i8` to a `[u8; 1]`
173
- --> tests/ui/transmute.rs:175 :30
221
+ --> tests/ui/transmute.rs:183 :30
174
222
|
175
223
LL | let _: [u8; 1] = std::mem::transmute(0i8);
176
224
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0i8.to_ne_bytes()`
177
225
178
226
error: transmute from a `i32` to a `[u8; 4]`
179
- --> tests/ui/transmute.rs:177 :30
227
+ --> tests/ui/transmute.rs:185 :30
180
228
|
181
229
LL | let _: [u8; 4] = std::mem::transmute(0i32);
182
230
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0i32.to_ne_bytes()`
183
231
184
232
error: transmute from a `i128` to a `[u8; 16]`
185
- --> tests/ui/transmute.rs:179 :31
233
+ --> tests/ui/transmute.rs:187 :31
186
234
|
187
235
LL | let _: [u8; 16] = std::mem::transmute(0i128);
188
236
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0i128.to_ne_bytes()`
189
237
190
238
error: transmute from a `f16` to a `[u8; 2]`
191
- --> tests/ui/transmute.rs:182 :30
239
+ --> tests/ui/transmute.rs:190 :30
192
240
|
193
241
LL | let _: [u8; 2] = std::mem::transmute(0.0f16);
194
242
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0.0f16.to_ne_bytes()`
195
243
196
244
error: transmute from a `f32` to a `[u8; 4]`
197
- --> tests/ui/transmute.rs:184 :30
245
+ --> tests/ui/transmute.rs:192 :30
198
246
|
199
247
LL | let _: [u8; 4] = std::mem::transmute(0.0f32);
200
248
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0.0f32.to_ne_bytes()`
201
249
202
250
error: transmute from a `f64` to a `[u8; 8]`
203
- --> tests/ui/transmute.rs:186 :30
251
+ --> tests/ui/transmute.rs:194 :30
204
252
|
205
253
LL | let _: [u8; 8] = std::mem::transmute(0.0f64);
206
254
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0.0f64.to_ne_bytes()`
207
255
208
256
error: transmute from a `f128` to a `[u8; 16]`
209
- --> tests/ui/transmute.rs:188 :31
257
+ --> tests/ui/transmute.rs:196 :31
210
258
|
211
259
LL | let _: [u8; 16] = std::mem::transmute(0.0f128);
212
260
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0.0f128.to_ne_bytes()`
213
261
214
262
error: transmute from a `u8` to a `[u8; 1]`
215
- --> tests/ui/transmute.rs:194 :30
263
+ --> tests/ui/transmute.rs:202 :30
216
264
|
217
265
LL | let _: [u8; 1] = std::mem::transmute(0u8);
218
266
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0u8.to_ne_bytes()`
219
267
220
268
error: transmute from a `u32` to a `[u8; 4]`
221
- --> tests/ui/transmute.rs:196 :30
269
+ --> tests/ui/transmute.rs:204 :30
222
270
|
223
271
LL | let _: [u8; 4] = std::mem::transmute(0u32);
224
272
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0u32.to_ne_bytes()`
225
273
226
274
error: transmute from a `u128` to a `[u8; 16]`
227
- --> tests/ui/transmute.rs:198 :31
275
+ --> tests/ui/transmute.rs:206 :31
228
276
|
229
277
LL | let _: [u8; 16] = std::mem::transmute(0u128);
230
278
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0u128.to_ne_bytes()`
231
279
232
280
error: transmute from a `i8` to a `[u8; 1]`
233
- --> tests/ui/transmute.rs:200 :30
281
+ --> tests/ui/transmute.rs:208 :30
234
282
|
235
283
LL | let _: [u8; 1] = std::mem::transmute(0i8);
236
284
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0i8.to_ne_bytes()`
237
285
238
286
error: transmute from a `i32` to a `[u8; 4]`
239
- --> tests/ui/transmute.rs:202 :30
287
+ --> tests/ui/transmute.rs:210 :30
240
288
|
241
289
LL | let _: [u8; 4] = std::mem::transmute(0i32);
242
290
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0i32.to_ne_bytes()`
243
291
244
292
error: transmute from a `i128` to a `[u8; 16]`
245
- --> tests/ui/transmute.rs:204 :31
293
+ --> tests/ui/transmute.rs:212 :31
246
294
|
247
295
LL | let _: [u8; 16] = std::mem::transmute(0i128);
248
296
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0i128.to_ne_bytes()`
249
297
298
+ error: transmute from a `f16` to a `[u8; 2]`
299
+ --> tests/ui/transmute.rs:215:30
300
+ |
301
+ LL | let _: [u8; 2] = std::mem::transmute(0.0f16);
302
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0.0f16.to_ne_bytes()`
303
+
304
+ error: transmute from a `f32` to a `[u8; 4]`
305
+ --> tests/ui/transmute.rs:217:30
306
+ |
307
+ LL | let _: [u8; 4] = std::mem::transmute(0.0f32);
308
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0.0f32.to_ne_bytes()`
309
+
310
+ error: transmute from a `f64` to a `[u8; 8]`
311
+ --> tests/ui/transmute.rs:219:30
312
+ |
313
+ LL | let _: [u8; 8] = std::mem::transmute(0.0f64);
314
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0.0f64.to_ne_bytes()`
315
+
316
+ error: transmute from a `f128` to a `[u8; 16]`
317
+ --> tests/ui/transmute.rs:221:31
318
+ |
319
+ LL | let _: [u8; 16] = std::mem::transmute(0.0f128);
320
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0.0f128.to_ne_bytes()`
321
+
250
322
error: transmute from a `&[u8]` to a `&str`
251
- --> tests/ui/transmute.rs:218 :28
323
+ --> tests/ui/transmute.rs:230 :28
252
324
|
253
325
LL | let _: &str = unsafe { std::mem::transmute(B) };
254
326
| ^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::str::from_utf8(B).unwrap()`
@@ -257,16 +329,16 @@ LL | let _: &str = unsafe { std::mem::transmute(B) };
257
329
= help: to override `-D warnings` add `#[allow(clippy::transmute_bytes_to_str)]`
258
330
259
331
error: transmute from a `&mut [u8]` to a `&mut str`
260
- --> tests/ui/transmute.rs:221 :32
332
+ --> tests/ui/transmute.rs:233 :32
261
333
|
262
334
LL | let _: &mut str = unsafe { std::mem::transmute(mb) };
263
335
| ^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::str::from_utf8_mut(mb).unwrap()`
264
336
265
337
error: transmute from a `&[u8]` to a `&str`
266
- --> tests/ui/transmute.rs:223 :30
338
+ --> tests/ui/transmute.rs:235 :30
267
339
|
268
340
LL | const _: &str = unsafe { std::mem::transmute(B) };
269
341
| ^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::str::from_utf8_unchecked(B)`
270
342
271
- error: aborting due to 42 previous errors
343
+ error: aborting due to 54 previous errors
272
344
0 commit comments