@@ -417,10 +417,11 @@ mod atomics {
417417 use super :: * ;
418418
419419 macro_rules! impl_traits_for_atomics {
420- ( $( $atomics: ident) ,* $( , ) ?) => {
420+ ( $( $atomics: ident [ $primitives : ident ] ) ,* $( , ) ?) => {
421421 $(
422422 impl_known_layout!( $atomics) ;
423- impl_for_transparent_wrapper!( => TryFromBytes for $atomics) ;
423+ impl_for_transmute_from!( => TryFromBytes for $atomics [ UnsafeCell <$primitives>] ) ;
424+ // impl_for_transparent_wrapper!(=> TryFromBytes for $atomics);
424425 impl_for_transparent_wrapper!( => FromZeros for $atomics) ;
425426 impl_for_transparent_wrapper!( => FromBytes for $atomics) ;
426427 impl_for_transparent_wrapper!( => IntoBytes for $atomics) ;
@@ -435,11 +436,12 @@ mod atomics {
435436
436437 use super :: * ;
437438
438- impl_traits_for_atomics ! ( AtomicU8 , AtomicI8 ) ;
439+ impl_traits_for_atomics ! ( AtomicU8 [ u8 ] , AtomicI8 [ i8 ] ) ;
439440
440441 impl_known_layout ! ( AtomicBool ) ;
441442
442- impl_for_transparent_wrapper ! ( => TryFromBytes for AtomicBool ) ;
443+ // impl_for_transparent_wrapper!(=> TryFromBytes for AtomicBool);
444+ impl_for_transmute_from ! ( => TryFromBytes for AtomicBool [ UnsafeCell <bool >] ) ;
443445 impl_for_transparent_wrapper ! ( => FromZeros for AtomicBool ) ;
444446 impl_for_transparent_wrapper ! ( => IntoBytes for AtomicBool ) ;
445447
@@ -472,6 +474,7 @@ mod atomics {
472474 /// All of these pass an atomic type and that type's native equivalent, as
473475 /// required by the macro safety preconditions.
474476 unsafe_impl_transparent_wrapper_for_atomic!( AtomicU8 [ u8 ] , AtomicI8 [ i8 ] , AtomicBool [ bool ] ) ;
477+ unsafe_impl_transmute_from_for_atomic!( AtomicU8 [ u8 ] , AtomicI8 [ i8 ] , AtomicBool [ bool ] ) ;
475478 }
476479 }
477480
@@ -482,13 +485,14 @@ mod atomics {
482485
483486 use super :: * ;
484487
485- impl_traits_for_atomics ! ( AtomicU16 , AtomicI16 ) ;
488+ impl_traits_for_atomics ! ( AtomicU16 [ u16 ] , AtomicI16 [ i16 ] ) ;
486489
487490 safety_comment ! {
488491 /// SAFETY:
489492 /// All of these pass an atomic type and that type's native equivalent, as
490493 /// required by the macro safety preconditions.
491494 unsafe_impl_transparent_wrapper_for_atomic!( AtomicU16 [ u16 ] , AtomicI16 [ i16 ] ) ;
495+ unsafe_impl_transmute_from_for_atomic!( AtomicU16 [ u16 ] , AtomicI16 [ i16 ] ) ;
492496 }
493497 }
494498
@@ -499,13 +503,14 @@ mod atomics {
499503
500504 use super :: * ;
501505
502- impl_traits_for_atomics ! ( AtomicU32 , AtomicI32 ) ;
506+ impl_traits_for_atomics ! ( AtomicU32 [ u32 ] , AtomicI32 [ i32 ] ) ;
503507
504508 safety_comment ! {
505509 /// SAFETY:
506510 /// All of these pass an atomic type and that type's native equivalent, as
507511 /// required by the macro safety preconditions.
508512 unsafe_impl_transparent_wrapper_for_atomic!( AtomicU32 [ u32 ] , AtomicI32 [ i32 ] ) ;
513+ unsafe_impl_transmute_from_for_atomic!( AtomicU32 [ u32 ] , AtomicI32 [ i32 ] ) ;
509514 }
510515 }
511516
@@ -516,13 +521,14 @@ mod atomics {
516521
517522 use super :: * ;
518523
519- impl_traits_for_atomics ! ( AtomicU64 , AtomicI64 ) ;
524+ impl_traits_for_atomics ! ( AtomicU64 [ u64 ] , AtomicI64 [ i64 ] ) ;
520525
521526 safety_comment ! {
522527 /// SAFETY:
523528 /// All of these pass an atomic type and that type's native equivalent, as
524529 /// required by the macro safety preconditions.
525530 unsafe_impl_transparent_wrapper_for_atomic!( AtomicU64 [ u64 ] , AtomicI64 [ i64 ] ) ;
531+ unsafe_impl_transmute_from_for_atomic!( AtomicU64 [ u64 ] , AtomicI64 [ i64 ] ) ;
526532 }
527533 }
528534
@@ -533,13 +539,14 @@ mod atomics {
533539
534540 use super :: * ;
535541
536- impl_traits_for_atomics ! ( AtomicUsize , AtomicIsize ) ;
542+ impl_traits_for_atomics ! ( AtomicUsize [ usize ] , AtomicIsize [ isize ] ) ;
537543
538544 impl_known_layout ! ( T => AtomicPtr <T >) ;
539545
540546 // TODO(#170): Implement `FromBytes` and `IntoBytes` once we implement
541547 // those traits for `*mut T`.
542- impl_for_transparent_wrapper ! ( T => TryFromBytes for AtomicPtr <T >) ;
548+ // impl_for_transparent_wrapper!(T => TryFromBytes for AtomicPtr<T>);
549+ impl_for_transmute_from ! ( T => TryFromBytes for AtomicPtr <T > [ UnsafeCell <* mut T >] ) ;
543550 impl_for_transparent_wrapper ! ( T => FromZeros for AtomicPtr <T >) ;
544551
545552 safety_comment ! {
@@ -548,6 +555,9 @@ mod atomics {
548555 /// required by the macro safety preconditions.
549556 unsafe_impl_transparent_wrapper_for_atomic!( AtomicUsize [ usize ] , AtomicIsize [ isize ] ) ;
550557 unsafe_impl_transparent_wrapper_for_atomic!( T => AtomicPtr <T > [ * mut T ] ) ;
558+
559+ unsafe_impl_transmute_from_for_atomic!( AtomicUsize [ usize ] , AtomicIsize [ isize ] ) ;
560+ unsafe_impl_transmute_from_for_atomic!( T => AtomicPtr <T > [ * mut T ] ) ;
551561 }
552562 }
553563}
@@ -578,7 +588,7 @@ safety_comment! {
578588}
579589
580590impl_for_transparent_wrapper ! ( T : Immutable => Immutable for Wrapping <T >) ;
581- impl_for_transparent_wrapper ! ( T : TryFromBytes => TryFromBytes for Wrapping <T >) ;
591+ impl_for_transmute_from ! ( T : TryFromBytes => TryFromBytes for Wrapping <T >[ T ] ) ;
582592impl_for_transparent_wrapper ! ( T : FromZeros => FromZeros for Wrapping <T >) ;
583593impl_for_transparent_wrapper ! ( T : FromBytes => FromBytes for Wrapping <T >) ;
584594impl_for_transparent_wrapper ! ( T : IntoBytes => IntoBytes for Wrapping <T >) ;
@@ -599,7 +609,7 @@ impl_for_transparent_wrapper!(T: Unaligned => Unaligned for CoreMaybeUninit<T>);
599609assert_unaligned ! ( CoreMaybeUninit <( ) >, CoreMaybeUninit <u8 >) ;
600610
601611impl_for_transparent_wrapper ! ( T : ?Sized + Immutable => Immutable for ManuallyDrop <T >) ;
602- impl_for_transparent_wrapper ! ( T : ?Sized + TryFromBytes => TryFromBytes for ManuallyDrop <T >) ;
612+ impl_for_transmute_from ! ( T : ?Sized + TryFromBytes => TryFromBytes for ManuallyDrop <T > [ T ] ) ;
603613impl_for_transparent_wrapper ! ( T : ?Sized + FromZeros => FromZeros for ManuallyDrop <T >) ;
604614impl_for_transparent_wrapper ! ( T : ?Sized + FromBytes => FromBytes for ManuallyDrop <T >) ;
605615impl_for_transparent_wrapper ! ( T : ?Sized + IntoBytes => IntoBytes for ManuallyDrop <T >) ;
0 commit comments