From 26fb1341651c4e0ae4d58c675db3ca2a0d6e12c2 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Fri, 6 Sep 2024 11:03:41 -0700 Subject: [PATCH] Relocate cfg attrs out of parse_ip_impl and parse_socket_impl --- serde/src/de/impls.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/serde/src/de/impls.rs b/serde/src/de/impls.rs index 303d0516d..2db681cdb 100644 --- a/serde/src/de/impls.rs +++ b/serde/src/de/impls.rs @@ -1583,6 +1583,7 @@ map_impl! { //////////////////////////////////////////////////////////////////////////////// +#[cfg(any(feature = "std", not(no_core_net)))] macro_rules! parse_ip_impl { ( $(#[$attr:meta])* @@ -1735,16 +1736,17 @@ impl<'de> Deserialize<'de> for net::IpAddr { } } +#[cfg(any(feature = "std", not(no_core_net)))] parse_ip_impl! { - #[cfg(any(feature = "std", not(no_core_net)))] net::Ipv4Addr, "IPv4 address", 4 } +#[cfg(any(feature = "std", not(no_core_net)))] parse_ip_impl! { - #[cfg(any(feature = "std", not(no_core_net)))] net::Ipv6Addr, "IPv6 address", 16 } +#[cfg(any(feature = "std", not(no_core_net)))] macro_rules! parse_socket_impl { ( $(#[$attr:meta])* @@ -1786,14 +1788,14 @@ impl<'de> Deserialize<'de> for net::SocketAddr { } } +#[cfg(any(feature = "std", not(no_core_net)))] parse_socket_impl! { - #[cfg(any(feature = "std", not(no_core_net)))] net::SocketAddrV4, "IPv4 socket address", |(ip, port)| net::SocketAddrV4::new(ip, port), } +#[cfg(any(feature = "std", not(no_core_net)))] parse_socket_impl! { - #[cfg(any(feature = "std", not(no_core_net)))] net::SocketAddrV6, "IPv6 socket address", |(ip, port)| net::SocketAddrV6::new(ip, port, 0, 0), }