about summary refs log tree commit diff
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume1.gomez@gmail.com>2024-03-07 18:32:51 +0100
committerGitHub <noreply@github.com>2024-03-07 18:32:51 +0100
commit92d7e02bb29d4341203dbae28aaa46acec930b28 (patch)
tree478d9874b16d2617e1268c41c3a17fc98cb0bc0e
parentcc6a570e0e3bde2680660c8b8f50c3c25c46b4f3 (diff)
parent5ce3db22487d2d88f035a939abe1131aedbd9d94 (diff)
downloadrust-92d7e02bb29d4341203dbae28aaa46acec930b28.tar.gz
rust-92d7e02bb29d4341203dbae28aaa46acec930b28.zip
Rollup merge of #122147 - kadiwa4:private_impl_mods, r=workingjubilee
Make `std::os::unix::ucred` module private

Tracking issue: #42839

Currently, this unstable module exists: [`std::os::unix::ucred`](https://doc.rust-lang.org/stable/std/os/unix/ucred/index.html).
All it does is provide `UCred` (which is also available from `std::os::unix::net`), `impl_*` (which is probably a mishap and should be private) and `peer_cred` (which is undocumented but has a documented counterpart at `std::os::unix::net::UnixStream::peer_cred`).

This PR makes the entire `ucred` module private and moves it into `net`, because that's where it is used.

I hope it's fine to simply remove it without a deprecation phase. Otherwise, I can add back a deprecated reexport module `std::os::unix::ucred`.

`@rustbot` label: -T-libs +T-libs-api
-rw-r--r--library/std/src/os/unix/mod.rs16
-rw-r--r--library/std/src/os/unix/net/mod.rs29
-rw-r--r--library/std/src/os/unix/net/stream.rs33
-rw-r--r--library/std/src/os/unix/net/ucred.rs (renamed from library/std/src/os/unix/ucred.rs)14
-rw-r--r--library/std/src/os/unix/net/ucred/tests.rs (renamed from library/std/src/os/unix/ucred/tests.rs)0
5 files changed, 44 insertions, 48 deletions
diff --git a/library/std/src/os/unix/mod.rs b/library/std/src/os/unix/mod.rs
index 5ba8719e6ff..b0633fd7bfc 100644
--- a/library/std/src/os/unix/mod.rs
+++ b/library/std/src/os/unix/mod.rs
@@ -95,22 +95,6 @@ pub mod process;
 pub mod raw;
 pub mod thread;
 
-#[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 = "tvos",
-    target_os = "watchos",
-    target_os = "macos",
-    target_os = "netbsd",
-    target_os = "openbsd",
-    target_os = "nto",
-))]
-pub mod ucred;
-
 /// A prelude for conveniently writing platform-specific code.
 ///
 /// Includes all extension traits, and some important type definitions.
diff --git a/library/std/src/os/unix/net/mod.rs b/library/std/src/os/unix/net/mod.rs
index 6da3e350bf1..28c1188677b 100644
--- a/library/std/src/os/unix/net/mod.rs
+++ b/library/std/src/os/unix/net/mod.rs
@@ -12,6 +12,20 @@ mod listener;
 mod stream;
 #[cfg(all(test, not(target_os = "emscripten")))]
 mod tests;
+#[cfg(any(
+    target_os = "android",
+    target_os = "linux",
+    target_os = "dragonfly",
+    target_os = "freebsd",
+    target_os = "ios",
+    target_os = "tvos",
+    target_os = "watchos",
+    target_os = "macos",
+    target_os = "netbsd",
+    target_os = "openbsd",
+    target_os = "nto",
+))]
+mod ucred;
 
 #[stable(feature = "unix_socket", since = "1.10.0")]
 pub use self::addr::*;
@@ -24,3 +38,18 @@ pub use self::datagram::*;
 pub use self::listener::*;
 #[stable(feature = "unix_socket", since = "1.10.0")]
 pub use self::stream::*;
+#[cfg(any(
+    target_os = "android",
+    target_os = "linux",
+    target_os = "dragonfly",
+    target_os = "freebsd",
+    target_os = "ios",
+    target_os = "tvos",
+    target_os = "watchos",
+    target_os = "macos",
+    target_os = "netbsd",
+    target_os = "openbsd",
+    target_os = "nto",
+))]
+#[unstable(feature = "peer_credentials_unix_socket", issue = "42839", reason = "unstable")]
+pub use self::ucred::*;
diff --git a/library/std/src/os/unix/net/stream.rs b/library/std/src/os/unix/net/stream.rs
index b1cd504e219..069cb299e28 100644
--- a/library/std/src/os/unix/net/stream.rs
+++ b/library/std/src/os/unix/net/stream.rs
@@ -1,10 +1,3 @@
-#[cfg(any(doc, target_os = "android", target_os = "linux"))]
-use super::{recv_vectored_with_ancillary_from, send_vectored_with_ancillary_to, SocketAncillary};
-use super::{sockaddr_un, SocketAddr};
-use crate::fmt;
-use crate::io::{self, IoSlice, IoSliceMut};
-use crate::net::Shutdown;
-use crate::os::unix::io::{AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd, OwnedFd, RawFd};
 #[cfg(any(
     target_os = "android",
     target_os = "linux",
@@ -17,28 +10,20 @@ use crate::os::unix::io::{AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd, Owned
     target_os = "netbsd",
     target_os = "openbsd"
 ))]
-use crate::os::unix::ucred;
+use super::{peer_cred, UCred};
+#[cfg(any(doc, target_os = "android", target_os = "linux"))]
+use super::{recv_vectored_with_ancillary_from, send_vectored_with_ancillary_to, SocketAncillary};
+use super::{sockaddr_un, SocketAddr};
+use crate::fmt;
+use crate::io::{self, IoSlice, IoSliceMut};
+use crate::net::Shutdown;
+use crate::os::unix::io::{AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd, OwnedFd, RawFd};
 use crate::path::Path;
 use crate::sys::cvt;
 use crate::sys::net::Socket;
 use crate::sys_common::{AsInner, FromInner};
 use crate::time::Duration;
 
-#[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 = "tvos",
-    target_os = "macos",
-    target_os = "watchos",
-    target_os = "netbsd",
-    target_os = "openbsd"
-))]
-pub use ucred::UCred;
-
 /// A Unix stream socket.
 ///
 /// # Examples
@@ -247,7 +232,7 @@ impl UnixStream {
         target_os = "openbsd"
     ))]
     pub fn peer_cred(&self) -> io::Result<UCred> {
-        ucred::peer_cred(self)
+        peer_cred(self)
     }
 
     /// Sets the read timeout for the socket.
diff --git a/library/std/src/os/unix/ucred.rs b/library/std/src/os/unix/net/ucred.rs
index 6efa74182cc..de09c93840a 100644
--- a/library/std/src/os/unix/ucred.rs
+++ b/library/std/src/os/unix/net/ucred.rs
@@ -1,5 +1,3 @@
-//! Unix peer credentials.
-
 // NOTE: Code in this file is heavily based on work done in PR 13 from the tokio-uds repository on
 //       GitHub.
 //
@@ -26,7 +24,7 @@ pub struct UCred {
 }
 
 #[cfg(any(target_os = "android", target_os = "linux"))]
-pub use self::impl_linux::peer_cred;
+pub(super) use self::impl_linux::peer_cred;
 
 #[cfg(any(
     target_os = "dragonfly",
@@ -34,13 +32,13 @@ pub use self::impl_linux::peer_cred;
     target_os = "openbsd",
     target_os = "netbsd"
 ))]
-pub use self::impl_bsd::peer_cred;
+pub(super) use self::impl_bsd::peer_cred;
 
 #[cfg(any(target_os = "macos", target_os = "ios", target_os = "tvos", target_os = "watchos"))]
-pub use self::impl_mac::peer_cred;
+pub(super) use self::impl_mac::peer_cred;
 
 #[cfg(any(target_os = "linux", target_os = "android"))]
-pub mod impl_linux {
+mod impl_linux {
     use super::UCred;
     use crate::os::unix::io::AsRawFd;
     use crate::os::unix::net::UnixStream;
@@ -82,7 +80,7 @@ pub mod impl_linux {
     target_os = "netbsd",
     target_os = "nto",
 ))]
-pub mod impl_bsd {
+mod impl_bsd {
     use super::UCred;
     use crate::io;
     use crate::os::unix::io::AsRawFd;
@@ -99,7 +97,7 @@ pub mod impl_bsd {
 }
 
 #[cfg(any(target_os = "macos", target_os = "ios", target_os = "tvos", target_os = "watchos"))]
-pub mod impl_mac {
+mod impl_mac {
     use super::UCred;
     use crate::os::unix::io::AsRawFd;
     use crate::os::unix::net::UnixStream;
diff --git a/library/std/src/os/unix/ucred/tests.rs b/library/std/src/os/unix/net/ucred/tests.rs
index dd99ecdd819..dd99ecdd819 100644
--- a/library/std/src/os/unix/ucred/tests.rs
+++ b/library/std/src/os/unix/net/ucred/tests.rs