@@ -945,10 +945,11 @@ where
945945
946946////////////////////////////////////////////////////////////////////////////////
947947
948- #[ cfg( all( feature = "std" , no_target_has_atomic , not( no_std_atomic) ) ) ]
948+ #[ cfg( all( feature = "std" , not( no_std_atomic) ) ) ]
949949macro_rules! atomic_impl {
950- ( $( $ty: ident) * ) => {
950+ ( $( $ty: ident $size : expr ) * ) => {
951951 $(
952+ #[ cfg( any( no_target_has_atomic, target_has_atomic = $size) ) ]
952953 impl Serialize for $ty {
953954 fn serialize<S >( & self , serializer: S ) -> Result <S :: Ok , S :: Error >
954955 where
@@ -962,47 +963,21 @@ macro_rules! atomic_impl {
962963 }
963964}
964965
965- #[ cfg( all( feature = "std" , not( no_target_has_atomic) ) ) ]
966- macro_rules! atomic_impl {
967- ( $( $ty: ident $size: expr) ,* ) => {
968- $(
969- #[ cfg( target_has_atomic = $size) ]
970- impl Serialize for $ty {
971- fn serialize<S >( & self , serializer: S ) -> Result <S :: Ok , S :: Error >
972- where
973- S : Serializer ,
974- {
975- // Matches the atomic ordering used in libcore for the Debug impl
976- self . load( Ordering :: Relaxed ) . serialize( serializer)
977- }
978- }
979- ) *
980- }
981- }
982-
983- #[ cfg( all( feature = "std" , no_target_has_atomic, not( no_std_atomic) ) ) ]
966+ #[ cfg( all( feature = "std" , not( no_std_atomic) ) ) ]
984967atomic_impl ! {
985- AtomicBool
986- AtomicI8 AtomicI16 AtomicI32 AtomicIsize
987- AtomicU8 AtomicU16 AtomicU32 AtomicUsize
988- }
989-
990- #[ cfg( all( feature = "std" , no_target_has_atomic, not( no_std_atomic64) ) ) ]
991- atomic_impl ! {
992- AtomicI64 AtomicU64
968+ AtomicBool "8"
969+ AtomicI8 "8"
970+ AtomicI16 "16"
971+ AtomicI32 "32"
972+ AtomicIsize "ptr"
973+ AtomicU8 "8"
974+ AtomicU16 "16"
975+ AtomicU32 "32"
976+ AtomicUsize "ptr"
993977}
994978
995- #[ cfg( all( feature = "std" , not( no_target_has_atomic ) ) ) ]
979+ #[ cfg( all( feature = "std" , not( no_std_atomic64 ) ) ) ]
996980atomic_impl ! {
997- AtomicBool "8" ,
998- AtomicI8 "8" ,
999- AtomicI16 "16" ,
1000- AtomicI32 "32" ,
1001- AtomicI64 "64" ,
1002- AtomicIsize "ptr" ,
1003- AtomicU8 "8" ,
1004- AtomicU16 "16" ,
1005- AtomicU32 "32" ,
1006- AtomicU64 "64" ,
1007- AtomicUsize "ptr"
981+ AtomicI64 "64"
982+ AtomicU64 "64"
1008983}
0 commit comments