diff --git a/library/std/src/sys/unix/ext/net.rs b/library/std/src/sys/unix/ext/net.rs index ac8d6cf53ff..f664a072c65 100644 --- a/library/std/src/sys/unix/ext/net.rs +++ b/library/std/src/sys/unix/ext/net.rs @@ -443,6 +443,15 @@ impl UnixStream { /// } /// ``` #[unstable(feature = "peer_credentials_unix_socket", issue = "42839", reason = "unstable")] + #[cfg(any( + target_os = "android", + target_os = "linux", + target_os = "dragonfly", + target_os = "freebsd", + target_os = "ios", + target_os = "macos", + target_os = "openbsd" + ))] pub fn peer_cred(&self) -> io::Result { ucred::peer_cred(self) } diff --git a/library/std/src/sys/unix/ext/ucred/tests.rs b/library/std/src/sys/unix/ext/ucred/tests.rs index efe99467210..451b534b266 100644 --- a/library/std/src/sys/unix/ext/ucred/tests.rs +++ b/library/std/src/sys/unix/ext/ucred/tests.rs @@ -2,6 +2,15 @@ use crate::os::unix::net::UnixStream; use libc::{getegid, geteuid}; #[test] +#[cfg(any( + target_os = "android", + target_os = "linux", + target_os = "dragonfly", + target_os = "freebsd", + target_os = "ios", + target_os = "macos", + target_os = "openbsd" +))] fn test_socket_pair() { // Create two connected sockets and get their peer credentials. They should be equal. let (sock_a, sock_b) = UnixStream::pair().unwrap();