about summary refs log tree commit diff
path: root/library/std/src/os/solid/io.rs
diff options
context:
space:
mode:
Diffstat (limited to 'library/std/src/os/solid/io.rs')
-rw-r--r--library/std/src/os/solid/io.rs22
1 files changed, 8 insertions, 14 deletions
diff --git a/library/std/src/os/solid/io.rs b/library/std/src/os/solid/io.rs
index b8601b533fe..c23d842b238 100644
--- a/library/std/src/os/solid/io.rs
+++ b/library/std/src/os/solid/io.rs
@@ -48,7 +48,7 @@
 
 use crate::marker::PhantomData;
 use crate::mem::ManuallyDrop;
-use crate::sys_common::{self, AsInner, FromInner, IntoInner};
+use crate::sys_common::{AsInner, FromInner, IntoInner};
 use crate::{fmt, net, sys};
 
 /// Raw file descriptors.
@@ -101,12 +101,9 @@ impl BorrowedFd<'_> {
     /// the returned `BorrowedFd`, and it must not have the value
     /// `SOLID_NET_INVALID_FD`.
     #[inline]
+    #[track_caller]
     pub const unsafe fn borrow_raw(fd: RawFd) -> Self {
-        assert!(fd != -1 as RawFd);
-        // 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)
-        let fd = unsafe { ValidRawFd::new_unchecked(fd) };
-        Self { fd, _phantom: PhantomData }
+        Self { fd: ValidRawFd::new(fd).expect("fd != -1"), _phantom: PhantomData }
     }
 }
 
@@ -122,7 +119,7 @@ impl BorrowedFd<'_> {
     /// Creates a new `OwnedFd` instance that shares the same underlying file
     /// description as the existing `BorrowedFd` instance.
     pub fn try_clone_to_owned(&self) -> crate::io::Result<OwnedFd> {
-        let fd = sys::net::cvt(unsafe { sys::net::netc::dup(self.as_raw_fd()) })?;
+        let fd = sys::net::cvt(unsafe { crate::sys::abi::sockets::dup(self.as_raw_fd()) })?;
         Ok(unsafe { OwnedFd::from_raw_fd(fd) })
     }
 }
@@ -156,19 +153,16 @@ impl FromRawFd for OwnedFd {
     /// 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]
+    #[track_caller]
     unsafe fn from_raw_fd(fd: RawFd) -> Self {
-        assert_ne!(fd, -1 as RawFd);
-        // 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)
-        let fd = unsafe { ValidRawFd::new_unchecked(fd) };
-        Self { fd }
+        Self { fd: ValidRawFd::new(fd).expect("fd != -1") }
     }
 }
 
 impl Drop for OwnedFd {
     #[inline]
     fn drop(&mut self) {
-        unsafe { sys::net::netc::close(self.fd.as_inner()) };
+        unsafe { crate::sys::abi::sockets::close(self.fd.as_inner()) };
     }
 }
 
@@ -387,7 +381,7 @@ macro_rules! impl_from_raw_fd {
             #[inline]
             unsafe fn from_raw_fd(fd: RawFd) -> net::$t {
                 let socket = unsafe { sys::net::Socket::from_raw_fd(fd) };
-                net::$t::from_inner(sys_common::net::$t::from_inner(socket))
+                net::$t::from_inner(sys::net::$t::from_inner(socket))
             }
         }
     )*};