about summary refs log tree commit diff
diff options
context:
space:
mode:
authorDan Gohman <dev@sunfishcode.online>2021-07-27 17:08:27 -0700
committerDan Gohman <dev@sunfishcode.online>2021-08-19 12:02:39 -0700
commit0cb69dec57f9ad279d7ceefad26cb0d2e16107bc (patch)
tree757494d77a16b17e5424f62611e15dd7de705dcf
parent45b5de3376bdfdd04222add3f42e39f933984993 (diff)
downloadrust-0cb69dec57f9ad279d7ceefad26cb0d2e16107bc.tar.gz
rust-0cb69dec57f9ad279d7ceefad26cb0d2e16107bc.zip
Rename `OwnedFd`'s private field to match it's debug output.
-rw-r--r--library/std/src/os/unix/io/fd.rs34
-rw-r--r--library/std/src/os/wasi/io/fd.rs34
-rw-r--r--library/std/src/os/windows/io/handle.rs68
-rw-r--r--library/std/src/os/windows/io/socket.rs35
4 files changed, 86 insertions, 85 deletions
diff --git a/library/std/src/os/unix/io/fd.rs b/library/std/src/os/unix/io/fd.rs
index 6bb1fa15c17..2be6198092f 100644
--- a/library/std/src/os/unix/io/fd.rs
+++ b/library/std/src/os/unix/io/fd.rs
@@ -32,7 +32,7 @@ use crate::sys_common::{AsInner, FromInner, IntoInner};
 #[rustc_layout_scalar_valid_range_end(0xFF_FF_FF_FE)]
 #[unstable(feature = "io_safety", issue = "87074")]
 pub struct BorrowedFd<'fd> {
-    raw: RawFd,
+    fd: RawFd,
     _phantom: PhantomData<&'fd OwnedFd>,
 }
 
@@ -52,7 +52,7 @@ pub struct BorrowedFd<'fd> {
 #[rustc_layout_scalar_valid_range_end(0xFF_FF_FF_FE)]
 #[unstable(feature = "io_safety", issue = "87074")]
 pub struct OwnedFd {
-    raw: RawFd,
+    fd: RawFd,
 }
 
 impl BorrowedFd<'_> {
@@ -60,13 +60,13 @@ impl BorrowedFd<'_> {
     ///
     /// # Safety
     ///
-    /// The resource pointed to by `raw` must remain open for the duration of
+    /// The resource pointed to by `fd` must remain open for the duration of
     /// the returned `BorrowedFd`, and it must not have the value `-1`.
     #[inline]
     #[unstable(feature = "io_safety", issue = "87074")]
-    pub unsafe fn borrow_raw_fd(raw: RawFd) -> Self {
-        assert_ne!(raw, -1_i32 as RawFd);
-        Self { raw, _phantom: PhantomData }
+    pub unsafe fn borrow_raw_fd(fd: RawFd) -> Self {
+        assert_ne!(fd, -1_i32 as RawFd);
+        Self { fd, _phantom: PhantomData }
     }
 }
 
@@ -74,7 +74,7 @@ impl BorrowedFd<'_> {
 impl AsRawFd for BorrowedFd<'_> {
     #[inline]
     fn as_raw_fd(&self) -> RawFd {
-        self.raw
+        self.fd
     }
 }
 
@@ -82,7 +82,7 @@ impl AsRawFd for BorrowedFd<'_> {
 impl AsRawFd for OwnedFd {
     #[inline]
     fn as_raw_fd(&self) -> RawFd {
-        self.raw
+        self.fd
     }
 }
 
@@ -90,9 +90,9 @@ impl AsRawFd for OwnedFd {
 impl IntoRawFd for OwnedFd {
     #[inline]
     fn into_raw_fd(self) -> RawFd {
-        let raw = self.raw;
+        let fd = self.fd;
         forget(self);
-        raw
+        fd
     }
 }
 
@@ -102,13 +102,13 @@ impl FromRawFd for OwnedFd {
     ///
     /// # Safety
     ///
-    /// The resource pointed to by `raw` must be open and suitable for assuming
+    /// The resource pointed to by `fd` must be open and suitable for assuming
     /// ownership. The resource must not require any cleanup other than `close`.
     #[inline]
-    unsafe fn from_raw_fd(raw: RawFd) -> Self {
-        assert_ne!(raw, -1i32);
+    unsafe fn from_raw_fd(fd: RawFd) -> Self {
+        assert_ne!(fd, -1i32);
         // SAFETY: we just asserted that the value is in the valid range and isn't `-1` (the only value bigger than `0xFF_FF_FF_FE` unsigned)
-        Self { raw }
+        Self { fd }
     }
 }
 
@@ -122,7 +122,7 @@ impl Drop for OwnedFd {
             // the file descriptor was closed or not, and if we retried (for
             // something like EINTR), we might close another valid file descriptor
             // opened after we closed ours.
-            let _ = libc::close(self.raw as raw::c_int);
+            let _ = libc::close(self.fd as raw::c_int);
         }
     }
 }
@@ -130,14 +130,14 @@ impl Drop for OwnedFd {
 #[unstable(feature = "io_safety", issue = "87074")]
 impl fmt::Debug for BorrowedFd<'_> {
     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
-        f.debug_struct("BorrowedFd").field("fd", &self.raw).finish()
+        f.debug_struct("BorrowedFd").field("fd", &self.fd).finish()
     }
 }
 
 #[unstable(feature = "io_safety", issue = "87074")]
 impl fmt::Debug for OwnedFd {
     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
-        f.debug_struct("OwnedFd").field("fd", &self.raw).finish()
+        f.debug_struct("OwnedFd").field("fd", &self.fd).finish()
     }
 }
 
diff --git a/library/std/src/os/wasi/io/fd.rs b/library/std/src/os/wasi/io/fd.rs
index f9cacc841cd..f77a73abb90 100644
--- a/library/std/src/os/wasi/io/fd.rs
+++ b/library/std/src/os/wasi/io/fd.rs
@@ -32,7 +32,7 @@ use crate::sys_common::{AsInner, FromInner, IntoInner};
 #[rustc_layout_scalar_valid_range_end(0xFF_FF_FF_FE)]
 #[unstable(feature = "io_safety", issue = "87074")]
 pub struct BorrowedFd<'fd> {
-    raw: RawFd,
+    fd: RawFd,
     _phantom: PhantomData<&'fd OwnedFd>,
 }
 
@@ -52,7 +52,7 @@ pub struct BorrowedFd<'fd> {
 #[rustc_layout_scalar_valid_range_end(0xFF_FF_FF_FE)]
 #[unstable(feature = "io_safety", issue = "87074")]
 pub struct OwnedFd {
-    raw: RawFd,
+    fd: RawFd,
 }
 
 impl BorrowedFd<'_> {
@@ -60,13 +60,13 @@ impl BorrowedFd<'_> {
     ///
     /// # Safety
     ///
-    /// The resource pointed to by `raw` must remain open for the duration of
+    /// The resource pointed to by `fd` must remain open for the duration of
     /// the returned `BorrowedFd`, and it must not have the value `-1`.
     #[inline]
     #[unstable(feature = "io_safety", issue = "87074")]
-    pub unsafe fn borrow_raw_fd(raw: RawFd) -> Self {
-        assert_ne!(raw, -1_i32 as RawFd);
-        unsafe { Self { raw, _phantom: PhantomData } }
+    pub unsafe fn borrow_raw_fd(fd: RawFd) -> Self {
+        assert_ne!(fd, -1_i32 as RawFd);
+        unsafe { Self { fd, _phantom: PhantomData } }
     }
 }
 
@@ -74,7 +74,7 @@ impl BorrowedFd<'_> {
 impl AsRawFd for BorrowedFd<'_> {
     #[inline]
     fn as_raw_fd(&self) -> RawFd {
-        self.raw
+        self.fd
     }
 }
 
@@ -82,7 +82,7 @@ impl AsRawFd for BorrowedFd<'_> {
 impl AsRawFd for OwnedFd {
     #[inline]
     fn as_raw_fd(&self) -> RawFd {
-        self.raw
+        self.fd
     }
 }
 
@@ -90,9 +90,9 @@ impl AsRawFd for OwnedFd {
 impl IntoRawFd for OwnedFd {
     #[inline]
     fn into_raw_fd(self) -> RawFd {
-        let raw = self.raw;
+        let fd = self.fd;
         forget(self);
-        raw
+        fd
     }
 }
 
@@ -102,13 +102,13 @@ impl FromRawFd for OwnedFd {
     ///
     /// # Safety
     ///
-    /// The resource pointed to by `raw` must be open and suitable for assuming
+    /// The resource pointed to by `fd` must be open and suitable for assuming
     /// ownership.
     #[inline]
-    unsafe fn from_raw_fd(raw: RawFd) -> Self {
-        assert_ne!(raw, RawFd::MAX);
+    unsafe fn from_raw_fd(fd: RawFd) -> Self {
+        assert_ne!(fd, RawFd::MAX);
         // SAFETY: we just asserted that the value is in the valid range and isn't `-1` (the only value bigger than `0xFF_FF_FF_FE` unsigned)
-        unsafe { Self { raw } }
+        unsafe { Self { fd } }
     }
 }
 
@@ -122,7 +122,7 @@ impl Drop for OwnedFd {
             // the file descriptor was closed or not, and if we retried (for
             // something like EINTR), we might close another valid file descriptor
             // opened after we closed ours.
-            let _ = libc::close(self.raw as raw::c_int);
+            let _ = libc::close(self.fd as raw::c_int);
         }
     }
 }
@@ -130,14 +130,14 @@ impl Drop for OwnedFd {
 #[unstable(feature = "io_safety", issue = "87074")]
 impl fmt::Debug for BorrowedFd<'_> {
     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
-        f.debug_struct("BorrowedFd").field("fd", &self.raw).finish()
+        f.debug_struct("BorrowedFd").field("fd", &self.fd).finish()
     }
 }
 
 #[unstable(feature = "io_safety", issue = "87074")]
 impl fmt::Debug for OwnedFd {
     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
-        f.debug_struct("OwnedFd").field("fd", &self.raw).finish()
+        f.debug_struct("OwnedFd").field("fd", &self.fd).finish()
     }
 }
 
diff --git a/library/std/src/os/windows/io/handle.rs b/library/std/src/os/windows/io/handle.rs
index e9128684354..5d250520685 100644
--- a/library/std/src/os/windows/io/handle.rs
+++ b/library/std/src/os/windows/io/handle.rs
@@ -30,7 +30,7 @@ use crate::sys_common::{AsInner, FromInner, IntoInner};
 #[repr(transparent)]
 #[unstable(feature = "io_safety", issue = "87074")]
 pub struct BorrowedHandle<'handle> {
-    raw: NonNull<c_void>,
+    handle: NonNull<c_void>,
     _phantom: PhantomData<&'handle OwnedHandle>,
 }
 
@@ -58,7 +58,7 @@ pub struct BorrowedHandle<'handle> {
 #[repr(transparent)]
 #[unstable(feature = "io_safety", issue = "87074")]
 pub struct OwnedHandle {
-    raw: NonNull<c_void>,
+    handle: NonNull<c_void>,
 }
 
 /// Similar to `Option<OwnedHandle>`, but intended for use in FFI interfaces
@@ -78,7 +78,7 @@ pub struct OwnedHandle {
 #[repr(transparent)]
 #[unstable(feature = "io_safety", issue = "87074")]
 pub struct OptionFileHandle {
-    raw: RawHandle,
+    handle: RawHandle,
 }
 
 // The Windows [`HANDLE`] type may be transferred across and shared between
@@ -98,13 +98,13 @@ impl BorrowedHandle<'_> {
     ///
     /// # Safety
     ///
-    /// The resource pointed to by `raw` must remain open for the duration of
-    /// the returned `BorrowedHandle`, and it must not be null.
+    /// The resource pointed to by `handle` must remain open for the duration
+    /// of the returned `BorrowedHandle`, and it must not be null.
     #[inline]
     #[unstable(feature = "io_safety", issue = "87074")]
-    pub unsafe fn borrow_raw_handle(raw: RawHandle) -> Self {
-        assert!(!raw.is_null());
-        Self { raw: NonNull::new_unchecked(raw), _phantom: PhantomData }
+    pub unsafe fn borrow_raw_handle(handle: RawHandle) -> Self {
+        assert!(!handle.is_null());
+        Self { handle: NonNull::new_unchecked(handle), _phantom: PhantomData }
     }
 }
 
@@ -113,7 +113,7 @@ impl OptionFileHandle {
     #[inline]
     #[unstable(feature = "io_safety", issue = "87074")]
     pub const fn none() -> Self {
-        Self { raw: c::INVALID_HANDLE_VALUE }
+        Self { handle: c::INVALID_HANDLE_VALUE }
     }
 }
 
@@ -122,19 +122,19 @@ impl TryFrom<OptionFileHandle> for OwnedHandle {
 
     #[inline]
     fn try_from(option: OptionFileHandle) -> Result<Self, ()> {
-        let raw = option.raw;
+        let handle = option.handle;
         forget(option);
-        if let Some(non_null) = NonNull::new(raw) {
+        if let Some(non_null) = NonNull::new(handle) {
             if non_null.as_ptr() != c::INVALID_HANDLE_VALUE {
-                Ok(Self { raw: non_null })
+                Ok(Self { handle: non_null })
             } else {
                 Err(())
             }
         } else {
             // In theory, we ought to be able to assume that the pointer here
-            // is never null, change `option.raw` to `NonNull`, and obviate the
-            // the panic path here. Unfortunately, Win32 documentation doesn't
-            // explicitly guarantee this anywhere.
+            // is never null, change `option.handle` to `NonNull`, and obviate
+            // the the panic path here. Unfortunately, Win32 documentation
+            // doesn't explicitly guarantee this anywhere.
             //
             // APIs like [`CreateFileW`] itself have `HANDLE` arguments where a
             // null handle indicates an absent value, which wouldn't work if
@@ -150,32 +150,32 @@ impl TryFrom<OptionFileHandle> for OwnedHandle {
 impl From<OwnedHandle> for OptionFileHandle {
     #[inline]
     fn from(owned: OwnedHandle) -> Self {
-        let raw = owned.raw;
+        let handle = owned.handle;
         forget(owned);
-        Self { raw: raw.as_ptr() }
+        Self { handle: handle.as_ptr() }
     }
 }
 
 impl AsRawHandle for BorrowedHandle<'_> {
     #[inline]
     fn as_raw_handle(&self) -> RawHandle {
-        self.raw.as_ptr()
+        self.handle.as_ptr()
     }
 }
 
 impl AsRawHandle for OwnedHandle {
     #[inline]
     fn as_raw_handle(&self) -> RawHandle {
-        self.raw.as_ptr()
+        self.handle.as_ptr()
     }
 }
 
 impl IntoRawHandle for OwnedHandle {
     #[inline]
     fn into_raw_handle(self) -> RawHandle {
-        let raw = self.raw.as_ptr();
+        let handle = self.handle.as_ptr();
         forget(self);
-        raw
+        handle
     }
 }
 
@@ -184,7 +184,7 @@ impl FromRawHandle for OwnedHandle {
     ///
     /// # Safety
     ///
-    /// The resource pointed to by `raw` must be open and suitable for
+    /// The resource pointed to by `handle` must be open and suitable for
     /// assuming ownership. The resource must not require any cleanup other
     /// than `CloseHandle`.
     ///
@@ -193,9 +193,9 @@ impl FromRawHandle for OwnedHandle {
     ///
     /// [`RegCloseKey`]: https://docs.microsoft.com/en-us/windows/win32/api/winreg/nf-winreg-regclosekey
     #[inline]
-    unsafe fn from_raw_handle(raw: RawHandle) -> Self {
-        assert!(!raw.is_null());
-        Self { raw: NonNull::new_unchecked(raw) }
+    unsafe fn from_raw_handle(handle: RawHandle) -> Self {
+        assert!(!handle.is_null());
+        Self { handle: NonNull::new_unchecked(handle) }
     }
 }
 
@@ -204,16 +204,16 @@ impl FromRawHandle for OptionFileHandle {
     ///
     /// # Safety
     ///
-    /// The resource pointed to by `raw` must be either open and otherwise
+    /// The resource pointed to by `handle` must be either open and otherwise
     /// unowned, or equal to `INVALID_HANDLE_VALUE``. Note that not all Windows
     /// APIs use `INVALID_HANDLE_VALUE` for errors; see [here] for the full
     /// story.
     ///
     /// [here]: https://devblogs.microsoft.com/oldnewthing/20040302-00/?p=40443
     #[inline]
-    unsafe fn from_raw_handle(raw: RawHandle) -> Self {
-        assert!(!raw.is_null());
-        Self { raw }
+    unsafe fn from_raw_handle(handle: RawHandle) -> Self {
+        assert!(!handle.is_null());
+        Self { handle }
     }
 }
 
@@ -221,7 +221,7 @@ impl Drop for OwnedHandle {
     #[inline]
     fn drop(&mut self) {
         unsafe {
-            let _ = c::CloseHandle(self.raw.as_ptr());
+            let _ = c::CloseHandle(self.handle.as_ptr());
         }
     }
 }
@@ -230,26 +230,26 @@ impl Drop for OptionFileHandle {
     #[inline]
     fn drop(&mut self) {
         unsafe {
-            let _ = c::CloseHandle(self.raw);
+            let _ = c::CloseHandle(self.handle);
         }
     }
 }
 
 impl fmt::Debug for BorrowedHandle<'_> {
     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
-        f.debug_struct("BorrowedHandle").field("handle", &self.raw).finish()
+        f.debug_struct("BorrowedHandle").field("handle", &self.handle).finish()
     }
 }
 
 impl fmt::Debug for OwnedHandle {
     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
-        f.debug_struct("OwnedHandle").field("handle", &self.raw).finish()
+        f.debug_struct("OwnedHandle").field("handle", &self.handle).finish()
     }
 }
 
 impl fmt::Debug for OptionFileHandle {
     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
-        f.debug_struct("OptionFileHandle").field("handle", &self.raw).finish()
+        f.debug_struct("OptionFileHandle").field("handle", &self.handle).finish()
     }
 }
 
diff --git a/library/std/src/os/windows/io/socket.rs b/library/std/src/os/windows/io/socket.rs
index 28695042a2b..fd89f4cc60c 100644
--- a/library/std/src/os/windows/io/socket.rs
+++ b/library/std/src/os/windows/io/socket.rs
@@ -28,7 +28,7 @@ use crate::sys::c;
 )]
 #[unstable(feature = "io_safety", issue = "87074")]
 pub struct BorrowedSocket<'socket> {
-    raw: RawSocket,
+    socket: RawSocket,
     _phantom: PhantomData<&'socket OwnedSocket>,
 }
 
@@ -50,7 +50,7 @@ pub struct BorrowedSocket<'socket> {
 )]
 #[unstable(feature = "io_safety", issue = "87074")]
 pub struct OwnedSocket {
-    raw: RawSocket,
+    socket: RawSocket,
 }
 
 impl BorrowedSocket<'_> {
@@ -63,32 +63,32 @@ impl BorrowedSocket<'_> {
     /// `INVALID_SOCKET`.
     #[inline]
     #[unstable(feature = "io_safety", issue = "87074")]
-    pub unsafe fn borrow_raw_socket(raw: RawSocket) -> Self {
-        debug_assert_ne!(raw, c::INVALID_SOCKET as RawSocket);
-        Self { raw, _phantom: PhantomData }
+    pub unsafe fn borrow_raw_socket(socket: RawSocket) -> Self {
+        debug_assert_ne!(socket, c::INVALID_SOCKET as RawSocket);
+        Self { socket, _phantom: PhantomData }
     }
 }
 
 impl AsRawSocket for BorrowedSocket<'_> {
     #[inline]
     fn as_raw_socket(&self) -> RawSocket {
-        self.raw
+        self.socket
     }
 }
 
 impl AsRawSocket for OwnedSocket {
     #[inline]
     fn as_raw_socket(&self) -> RawSocket {
-        self.raw
+        self.socket
     }
 }
 
 impl IntoRawSocket for OwnedSocket {
     #[inline]
     fn into_raw_socket(self) -> RawSocket {
-        let raw = self.raw;
+        let socket = self.socket;
         forget(self);
-        raw
+        socket
     }
 }
 
@@ -97,12 +97,13 @@ impl FromRawSocket for OwnedSocket {
     ///
     /// # Safety
     ///
-    /// The resource pointed to by `raw` must be open and suitable for assuming
-    /// ownership. The resource must not require cleanup other than `closesocket`.
+    /// The resource pointed to by `socket` must be open and suitable for
+    /// assuming ownership. The resource must not require cleanup other than
+    /// `closesocket`.
     #[inline]
-    unsafe fn from_raw_socket(raw: RawSocket) -> Self {
-        debug_assert_ne!(raw, c::INVALID_SOCKET as RawSocket);
-        Self { raw }
+    unsafe fn from_raw_socket(socket: RawSocket) -> Self {
+        debug_assert_ne!(socket, c::INVALID_SOCKET as RawSocket);
+        Self { socket }
     }
 }
 
@@ -110,20 +111,20 @@ impl Drop for OwnedSocket {
     #[inline]
     fn drop(&mut self) {
         unsafe {
-            let _ = c::closesocket(self.raw);
+            let _ = c::closesocket(self.socket);
         }
     }
 }
 
 impl fmt::Debug for BorrowedSocket<'_> {
     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
-        f.debug_struct("BorrowedSocket").field("socket", &self.raw).finish()
+        f.debug_struct("BorrowedSocket").field("socket", &self.socket).finish()
     }
 }
 
 impl fmt::Debug for OwnedSocket {
     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
-        f.debug_struct("OwnedSocket").field("socket", &self.raw).finish()
+        f.debug_struct("OwnedSocket").field("socket", &self.socket).finish()
     }
 }