@@ -2346,17 +2346,12 @@ assert_eq!(
2346
2346
#[ rustc_const_stable( feature = "const_int_conversion" , since = "1.44.0" ) ]
2347
2347
// SAFETY: const sound because integers are plain old datatypes so we can always
2348
2348
// transmute them to arrays of bytes
2349
- #[ allow_internal_unstable( const_fn_union ) ]
2349
+ #[ allow_internal_unstable( const_fn_transmute ) ]
2350
2350
#[ inline]
2351
2351
pub const fn to_ne_bytes( self ) -> [ u8 ; mem:: size_of:: <Self >( ) ] {
2352
- #[ repr( C ) ]
2353
- union Bytes {
2354
- val: $SelfT,
2355
- bytes: [ u8 ; mem:: size_of:: <$SelfT>( ) ] ,
2356
- }
2357
2352
// SAFETY: integers are plain old datatypes so we can always transmute them to
2358
2353
// arrays of bytes
2359
- unsafe { Bytes { val : self } . bytes }
2354
+ unsafe { mem :: transmute ( self ) }
2360
2355
}
2361
2356
}
2362
2357
@@ -2464,16 +2459,11 @@ fn read_ne_", stringify!($SelfT), "(input: &mut &[u8]) -> ", stringify!($SelfT),
2464
2459
#[ rustc_const_stable( feature = "const_int_conversion" , since = "1.44.0" ) ]
2465
2460
// SAFETY: const sound because integers are plain old datatypes so we can always
2466
2461
// transmute to them
2467
- #[ allow_internal_unstable( const_fn_union ) ]
2462
+ #[ allow_internal_unstable( const_fn_transmute ) ]
2468
2463
#[ inline]
2469
2464
pub const fn from_ne_bytes( bytes: [ u8 ; mem:: size_of:: <Self >( ) ] ) -> Self {
2470
- #[ repr( C ) ]
2471
- union Bytes {
2472
- val: $SelfT,
2473
- bytes: [ u8 ; mem:: size_of:: <$SelfT>( ) ] ,
2474
- }
2475
2465
// SAFETY: integers are plain old datatypes so we can always transmute to them
2476
- unsafe { Bytes { bytes } . val }
2466
+ unsafe { mem :: transmute ( bytes) }
2477
2467
}
2478
2468
}
2479
2469
@@ -4368,17 +4358,12 @@ assert_eq!(
4368
4358
#[ rustc_const_stable( feature = "const_int_conversion" , since = "1.44.0" ) ]
4369
4359
// SAFETY: const sound because integers are plain old datatypes so we can always
4370
4360
// transmute them to arrays of bytes
4371
- #[ allow_internal_unstable( const_fn_union ) ]
4361
+ #[ allow_internal_unstable( const_fn_transmute ) ]
4372
4362
#[ inline]
4373
4363
pub const fn to_ne_bytes( self ) -> [ u8 ; mem:: size_of:: <Self >( ) ] {
4374
- #[ repr( C ) ]
4375
- union Bytes {
4376
- val: $SelfT,
4377
- bytes: [ u8 ; mem:: size_of:: <$SelfT>( ) ] ,
4378
- }
4379
4364
// SAFETY: integers are plain old datatypes so we can always transmute them to
4380
4365
// arrays of bytes
4381
- unsafe { Bytes { val : self } . bytes }
4366
+ unsafe { mem :: transmute ( self ) }
4382
4367
}
4383
4368
}
4384
4369
@@ -4486,16 +4471,11 @@ fn read_ne_", stringify!($SelfT), "(input: &mut &[u8]) -> ", stringify!($SelfT),
4486
4471
#[ rustc_const_stable( feature = "const_int_conversion" , since = "1.44.0" ) ]
4487
4472
// SAFETY: const sound because integers are plain old datatypes so we can always
4488
4473
// transmute to them
4489
- #[ allow_internal_unstable( const_fn_union ) ]
4474
+ #[ allow_internal_unstable( const_fn_transmute ) ]
4490
4475
#[ inline]
4491
4476
pub const fn from_ne_bytes( bytes: [ u8 ; mem:: size_of:: <Self >( ) ] ) -> Self {
4492
- #[ repr( C ) ]
4493
- union Bytes {
4494
- val: $SelfT,
4495
- bytes: [ u8 ; mem:: size_of:: <$SelfT>( ) ] ,
4496
- }
4497
4477
// SAFETY: integers are plain old datatypes so we can always transmute to them
4498
- unsafe { Bytes { bytes } . val }
4478
+ unsafe { mem :: transmute ( bytes) }
4499
4479
}
4500
4480
}
4501
4481
0 commit comments