diff options
Diffstat (limited to 'library/std/src/net')
| -rw-r--r-- | library/std/src/net/ip.rs | 9 | ||||
| -rw-r--r-- | library/std/src/net/ip/tests.rs | 6 | ||||
| -rw-r--r-- | library/std/src/net/tcp.rs | 2 | ||||
| -rw-r--r-- | library/std/src/net/udp.rs | 2 |
4 files changed, 13 insertions, 6 deletions
diff --git a/library/std/src/net/ip.rs b/library/std/src/net/ip.rs index bb3ece4c273..87bbd33bc01 100644 --- a/library/std/src/net/ip.rs +++ b/library/std/src/net/ip.rs @@ -263,8 +263,9 @@ impl IpAddr { /// assert_eq!(IpAddr::V4(Ipv4Addr::new(203, 0, 113, 6)).is_ipv4(), true); /// assert_eq!(IpAddr::V6(Ipv6Addr::new(0x2001, 0xdb8, 0, 0, 0, 0, 0, 0)).is_ipv4(), false); /// ``` + #[rustc_const_stable(feature = "const_ip", since = "1.50.0")] #[stable(feature = "ipaddr_checker", since = "1.16.0")] - pub fn is_ipv4(&self) -> bool { + pub const fn is_ipv4(&self) -> bool { matches!(self, IpAddr::V4(_)) } @@ -281,8 +282,9 @@ impl IpAddr { /// assert_eq!(IpAddr::V4(Ipv4Addr::new(203, 0, 113, 6)).is_ipv6(), false); /// assert_eq!(IpAddr::V6(Ipv6Addr::new(0x2001, 0xdb8, 0, 0, 0, 0, 0, 0)).is_ipv6(), true); /// ``` + #[rustc_const_stable(feature = "const_ip", since = "1.50.0")] #[stable(feature = "ipaddr_checker", since = "1.16.0")] - pub fn is_ipv6(&self) -> bool { + pub const fn is_ipv6(&self) -> bool { matches!(self, IpAddr::V6(_)) } } @@ -1043,8 +1045,7 @@ impl Ipv6Addr { /// ``` #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_stable(feature = "const_ipv6", since = "1.32.0")] - #[cfg_attr(not(bootstrap), rustc_allow_const_fn_unstable(const_fn_transmute))] - #[cfg_attr(bootstrap, allow_internal_unstable(const_fn_transmute))] + #[rustc_allow_const_fn_unstable(const_fn_transmute)] pub const fn new(a: u16, b: u16, c: u16, d: u16, e: u16, f: u16, g: u16, h: u16) -> Ipv6Addr { let addr16 = [ a.to_be(), diff --git a/library/std/src/net/ip/tests.rs b/library/std/src/net/ip/tests.rs index d9fbdd1b5e7..44fb3adf070 100644 --- a/library/std/src/net/ip/tests.rs +++ b/library/std/src/net/ip/tests.rs @@ -936,4 +936,10 @@ fn ip_const() { const IS_MULTICAST: bool = IP_ADDRESS.is_multicast(); assert!(!IS_MULTICAST); + + const IS_IP_V4: bool = IP_ADDRESS.is_ipv4(); + assert!(IS_IP_V4); + + const IS_IP_V6: bool = IP_ADDRESS.is_ipv6(); + assert!(!IS_IP_V6); } diff --git a/library/std/src/net/tcp.rs b/library/std/src/net/tcp.rs index 58c6343ea34..325acf0b979 100644 --- a/library/std/src/net/tcp.rs +++ b/library/std/src/net/tcp.rs @@ -1,6 +1,6 @@ #![deny(unsafe_op_in_unsafe_fn)] -#[cfg(all(test, not(any(target_os = "cloudabi", target_os = "emscripten"))))] +#[cfg(all(test, not(target_os = "emscripten")))] mod tests; use crate::io::prelude::*; diff --git a/library/std/src/net/udp.rs b/library/std/src/net/udp.rs index 17e3e4497c4..2377a76a33d 100644 --- a/library/std/src/net/udp.rs +++ b/library/std/src/net/udp.rs @@ -1,4 +1,4 @@ -#[cfg(all(test, not(any(target_os = "cloudabi", target_os = "emscripten", target_env = "sgx"))))] +#[cfg(all(test, not(any(target_os = "emscripten", target_env = "sgx"))))] mod tests; use crate::fmt; |
