Skip to content

Commit 0d79306

Browse files
committed
Update atomic_impl macros to have same input syntax in all cfgs
1 parent 37faaf2 commit 0d79306

File tree

2 files changed

+46
-32
lines changed

2 files changed

+46
-32
lines changed

serde/src/de/impls.rs

+23-16
Original file line numberDiff line numberDiff line change
@@ -2662,7 +2662,7 @@ where
26622662

26632663
#[cfg(all(feature = "std", no_target_has_atomic, not(no_std_atomic)))]
26642664
macro_rules! atomic_impl {
2665-
($($ty:ident)*) => {
2665+
($($ty:ident $size:expr)*) => {
26662666
$(
26672667
impl<'de> Deserialize<'de> for $ty {
26682668
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
@@ -2678,7 +2678,7 @@ macro_rules! atomic_impl {
26782678

26792679
#[cfg(all(feature = "std", not(no_target_has_atomic)))]
26802680
macro_rules! atomic_impl {
2681-
($($ty:ident $size:expr),*) => {
2681+
($($ty:ident $size:expr)*) => {
26822682
$(
26832683
#[cfg(target_has_atomic = $size)]
26842684
impl<'de> Deserialize<'de> for $ty {
@@ -2695,28 +2695,35 @@ macro_rules! atomic_impl {
26952695

26962696
#[cfg(all(feature = "std", no_target_has_atomic, not(no_std_atomic)))]
26972697
atomic_impl! {
2698-
AtomicBool
2699-
AtomicI8 AtomicI16 AtomicI32 AtomicIsize
2700-
AtomicU8 AtomicU16 AtomicU32 AtomicUsize
2698+
AtomicBool "8"
2699+
AtomicI8 "8"
2700+
AtomicI16 "16"
2701+
AtomicI32 "32"
2702+
AtomicIsize "ptr"
2703+
AtomicU8 "8"
2704+
AtomicU16 "16"
2705+
AtomicU32 "32"
2706+
AtomicUsize "ptr"
27012707
}
27022708

27032709
#[cfg(all(feature = "std", no_target_has_atomic, not(no_std_atomic64)))]
27042710
atomic_impl! {
2705-
AtomicI64 AtomicU64
2711+
AtomicI64 "64"
2712+
AtomicU64 "64"
27062713
}
27072714

27082715
#[cfg(all(feature = "std", not(no_target_has_atomic)))]
27092716
atomic_impl! {
2710-
AtomicBool "8",
2711-
AtomicI8 "8",
2712-
AtomicI16 "16",
2713-
AtomicI32 "32",
2714-
AtomicI64 "64",
2715-
AtomicIsize "ptr",
2716-
AtomicU8 "8",
2717-
AtomicU16 "16",
2718-
AtomicU32 "32",
2719-
AtomicU64 "64",
2717+
AtomicBool "8"
2718+
AtomicI8 "8"
2719+
AtomicI16 "16"
2720+
AtomicI32 "32"
2721+
AtomicI64 "64"
2722+
AtomicIsize "ptr"
2723+
AtomicU8 "8"
2724+
AtomicU16 "16"
2725+
AtomicU32 "32"
2726+
AtomicU64 "64"
27202727
AtomicUsize "ptr"
27212728
}
27222729

serde/src/ser/impls.rs

+23-16
Original file line numberDiff line numberDiff line change
@@ -947,7 +947,7 @@ where
947947

948948
#[cfg(all(feature = "std", no_target_has_atomic, not(no_std_atomic)))]
949949
macro_rules! atomic_impl {
950-
($($ty:ident)*) => {
950+
($($ty:ident $size:expr)*) => {
951951
$(
952952
impl Serialize for $ty {
953953
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
@@ -964,7 +964,7 @@ macro_rules! atomic_impl {
964964

965965
#[cfg(all(feature = "std", not(no_target_has_atomic)))]
966966
macro_rules! atomic_impl {
967-
($($ty:ident $size:expr),*) => {
967+
($($ty:ident $size:expr)*) => {
968968
$(
969969
#[cfg(target_has_atomic = $size)]
970970
impl Serialize for $ty {
@@ -982,27 +982,34 @@ macro_rules! atomic_impl {
982982

983983
#[cfg(all(feature = "std", no_target_has_atomic, not(no_std_atomic)))]
984984
atomic_impl! {
985-
AtomicBool
986-
AtomicI8 AtomicI16 AtomicI32 AtomicIsize
987-
AtomicU8 AtomicU16 AtomicU32 AtomicUsize
985+
AtomicBool "8"
986+
AtomicI8 "8"
987+
AtomicI16 "16"
988+
AtomicI32 "32"
989+
AtomicIsize "ptr"
990+
AtomicU8 "8"
991+
AtomicU16 "16"
992+
AtomicU32 "32"
993+
AtomicUsize "ptr"
988994
}
989995

990996
#[cfg(all(feature = "std", no_target_has_atomic, not(no_std_atomic64)))]
991997
atomic_impl! {
992-
AtomicI64 AtomicU64
998+
AtomicI64 "64"
999+
AtomicU64 "64"
9931000
}
9941001

9951002
#[cfg(all(feature = "std", not(no_target_has_atomic)))]
9961003
atomic_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",
1004+
AtomicBool "8"
1005+
AtomicI8 "8"
1006+
AtomicI16 "16"
1007+
AtomicI32 "32"
1008+
AtomicI64 "64"
1009+
AtomicIsize "ptr"
1010+
AtomicU8 "8"
1011+
AtomicU16 "16"
1012+
AtomicU32 "32"
1013+
AtomicU64 "64"
10071014
AtomicUsize "ptr"
10081015
}

0 commit comments

Comments
 (0)