diff --git a/tokio-util/src/compat.rs b/tokio-util/src/compat.rs index 9e3f26bdc3e..a112d2243f0 100644 --- a/tokio-util/src/compat.rs +++ b/tokio-util/src/compat.rs @@ -366,8 +366,8 @@ impl tokio::io::AsyncSeek for Compat { } #[cfg(unix)] -impl std::os::unix::io::AsRawFd for Compat { - fn as_raw_fd(&self) -> std::os::unix::io::RawFd { +impl std::os::fd::AsRawFd for Compat { + fn as_raw_fd(&self) -> std::os::fd::RawFd { self.inner.as_raw_fd() } } diff --git a/tokio/src/fs/file.rs b/tokio/src/fs/file.rs index 0ac16b9475d..5465f2de319 100644 --- a/tokio/src/fs/file.rs +++ b/tokio/src/fs/file.rs @@ -899,24 +899,22 @@ impl fmt::Debug for File { } #[cfg(unix)] -impl std::os::unix::io::AsRawFd for File { - fn as_raw_fd(&self) -> std::os::unix::io::RawFd { +impl std::os::fd::AsRawFd for File { + fn as_raw_fd(&self) -> std::os::fd::RawFd { self.std.as_raw_fd() } } #[cfg(unix)] -impl std::os::unix::io::AsFd for File { - fn as_fd(&self) -> std::os::unix::io::BorrowedFd<'_> { - unsafe { - std::os::unix::io::BorrowedFd::borrow_raw(std::os::unix::io::AsRawFd::as_raw_fd(self)) - } +impl std::os::fd::AsFd for File { + fn as_fd(&self) -> std::os::fd::BorrowedFd<'_> { + unsafe { std::os::fd::BorrowedFd::borrow_raw(std::os::fd::AsRawFd::as_raw_fd(self)) } } } #[cfg(unix)] -impl std::os::unix::io::FromRawFd for File { - unsafe fn from_raw_fd(fd: std::os::unix::io::RawFd) -> Self { +impl std::os::fd::FromRawFd for File { + unsafe fn from_raw_fd(fd: std::os::fd::RawFd) -> Self { StdFile::from_raw_fd(fd).into() } } diff --git a/tokio/src/fs/mocks.rs b/tokio/src/fs/mocks.rs index 3a8ac2bdd27..7fea4c882ff 100644 --- a/tokio/src/fs/mocks.rs +++ b/tokio/src/fs/mocks.rs @@ -44,13 +44,13 @@ mock! { unsafe fn from_raw_handle(h: std::os::windows::io::RawHandle) -> Self; } #[cfg(unix)] - impl std::os::unix::io::AsRawFd for File { - fn as_raw_fd(&self) -> std::os::unix::io::RawFd; + impl std::os::fd::AsRawFd for File { + fn as_raw_fd(&self) -> std::os::fd::RawFd; } #[cfg(unix)] - impl std::os::unix::io::FromRawFd for File { - unsafe fn from_raw_fd(h: std::os::unix::io::RawFd) -> Self; + impl std::os::fd::FromRawFd for File { + unsafe fn from_raw_fd(h: std::os::fd::RawFd) -> Self; } } diff --git a/tokio/src/io/async_fd.rs b/tokio/src/io/async_fd.rs index 285579e1a5f..05cb59e37bb 100644 --- a/tokio/src/io/async_fd.rs +++ b/tokio/src/io/async_fd.rs @@ -6,7 +6,7 @@ use mio::unix::SourceFd; use std::error::Error; use std::fmt; use std::io; -use std::os::unix::io::{AsRawFd, RawFd}; +use std::os::fd::{AsRawFd, RawFd}; use std::task::{ready, Context, Poll}; /// Associates an IO object backed by a Unix file descriptor with the tokio @@ -930,9 +930,9 @@ impl AsRawFd for AsyncFd { } } -impl std::os::unix::io::AsFd for AsyncFd { - fn as_fd(&self) -> std::os::unix::io::BorrowedFd<'_> { - unsafe { std::os::unix::io::BorrowedFd::borrow_raw(self.as_raw_fd()) } +impl std::os::fd::AsFd for AsyncFd { + fn as_fd(&self) -> std::os::fd::BorrowedFd<'_> { + unsafe { std::os::fd::BorrowedFd::borrow_raw(self.as_raw_fd()) } } } diff --git a/tokio/src/io/bsd/poll_aio.rs b/tokio/src/io/bsd/poll_aio.rs index 086ba6d93bc..4fd4c1672ad 100644 --- a/tokio/src/io/bsd/poll_aio.rs +++ b/tokio/src/io/bsd/poll_aio.rs @@ -9,7 +9,7 @@ use mio::Token; use std::fmt; use std::io; use std::ops::{Deref, DerefMut}; -use std::os::unix::io::AsRawFd; +use std::os::fd::AsRawFd; use std::os::unix::prelude::RawFd; use std::task::{ready, Context, Poll}; diff --git a/tokio/src/io/stderr.rs b/tokio/src/io/stderr.rs index 0988e2d9da0..4e2793dfe6c 100644 --- a/tokio/src/io/stderr.rs +++ b/tokio/src/io/stderr.rs @@ -79,7 +79,7 @@ cfg_io_std! { #[cfg(unix)] mod sys { - use std::os::unix::io::{AsFd, AsRawFd, BorrowedFd, RawFd}; + use std::os::fd::{AsFd, AsRawFd, BorrowedFd, RawFd}; use super::Stderr; diff --git a/tokio/src/io/stdin.rs b/tokio/src/io/stdin.rs index 877c48b30fb..992d913ee20 100644 --- a/tokio/src/io/stdin.rs +++ b/tokio/src/io/stdin.rs @@ -54,7 +54,7 @@ cfg_io_std! { #[cfg(unix)] mod sys { - use std::os::unix::io::{AsFd, AsRawFd, BorrowedFd, RawFd}; + use std::os::fd::{AsFd, AsRawFd, BorrowedFd, RawFd}; use super::Stdin; diff --git a/tokio/src/io/stdout.rs b/tokio/src/io/stdout.rs index f46ca0f05c4..8e727137d70 100644 --- a/tokio/src/io/stdout.rs +++ b/tokio/src/io/stdout.rs @@ -128,7 +128,7 @@ cfg_io_std! { #[cfg(unix)] mod sys { - use std::os::unix::io::{AsFd, AsRawFd, BorrowedFd, RawFd}; + use std::os::fd::{AsFd, AsRawFd, BorrowedFd, RawFd}; use super::Stdout; diff --git a/tokio/src/net/tcp/listener.rs b/tokio/src/net/tcp/listener.rs index c8f8be0633d..c2d0b47192a 100644 --- a/tokio/src/net/tcp/listener.rs +++ b/tokio/src/net/tcp/listener.rs @@ -274,7 +274,7 @@ impl TcpListener { pub fn into_std(self) -> io::Result { #[cfg(unix)] { - use std::os::unix::io::{FromRawFd, IntoRawFd}; + use std::os::fd::{FromRawFd, IntoRawFd}; self.io .into_inner() .map(IntoRawFd::into_raw_fd) diff --git a/tokio/src/net/tcp/socket.rs b/tokio/src/net/tcp/socket.rs index f8d39e12a40..024df5b27b1 100644 --- a/tokio/src/net/tcp/socket.rs +++ b/tokio/src/net/tcp/socket.rs @@ -5,7 +5,7 @@ use std::io; use std::net::SocketAddr; #[cfg(unix)] -use std::os::unix::io::{AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd, RawFd}; +use std::os::fd::{AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd, RawFd}; use std::time::Duration; cfg_windows! { @@ -670,7 +670,7 @@ impl TcpSocket { } #[cfg(unix)] let mio = { - use std::os::unix::io::{FromRawFd, IntoRawFd}; + use std::os::fd::{FromRawFd, IntoRawFd}; let raw_fd = self.inner.into_raw_fd(); unsafe { mio::net::TcpStream::from_raw_fd(raw_fd) } @@ -726,7 +726,7 @@ impl TcpSocket { self.inner.listen(backlog as i32)?; #[cfg(unix)] let mio = { - use std::os::unix::io::{FromRawFd, IntoRawFd}; + use std::os::fd::{FromRawFd, IntoRawFd}; let raw_fd = self.inner.into_raw_fd(); unsafe { mio::net::TcpListener::from_raw_fd(raw_fd) } @@ -780,7 +780,7 @@ impl TcpSocket { pub fn from_std_stream(std_stream: std::net::TcpStream) -> TcpSocket { #[cfg(unix)] { - use std::os::unix::io::{FromRawFd, IntoRawFd}; + use std::os::fd::{FromRawFd, IntoRawFd}; let raw_fd = std_stream.into_raw_fd(); unsafe { TcpSocket::from_raw_fd(raw_fd) } diff --git a/tokio/src/net/tcp/stream.rs b/tokio/src/net/tcp/stream.rs index 550ddbd86c7..11141dde080 100644 --- a/tokio/src/net/tcp/stream.rs +++ b/tokio/src/net/tcp/stream.rs @@ -254,7 +254,7 @@ impl TcpStream { pub fn into_std(self) -> io::Result { #[cfg(unix)] { - use std::os::unix::io::{FromRawFd, IntoRawFd}; + use std::os::fd::{FromRawFd, IntoRawFd}; self.io .into_inner() .map(IntoRawFd::into_raw_fd) diff --git a/tokio/src/net/udp.rs b/tokio/src/net/udp.rs index 44fa9ba3596..b7e71665ef2 100644 --- a/tokio/src/net/udp.rs +++ b/tokio/src/net/udp.rs @@ -256,7 +256,7 @@ impl UdpSocket { pub fn into_std(self) -> io::Result { #[cfg(unix)] { - use std::os::unix::io::{FromRawFd, IntoRawFd}; + use std::os::fd::{FromRawFd, IntoRawFd}; self.io .into_inner() .map(IntoRawFd::into_raw_fd) diff --git a/tokio/src/net/unix/datagram/socket.rs b/tokio/src/net/unix/datagram/socket.rs index 0a065ec3ebc..8c5f36400cc 100644 --- a/tokio/src/net/unix/datagram/socket.rs +++ b/tokio/src/net/unix/datagram/socket.rs @@ -5,7 +5,7 @@ use crate::util::check_socket_for_blocking; use std::fmt; use std::io; use std::net::Shutdown; -use std::os::unix::io::{AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd, RawFd}; +use std::os::fd::{AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd, RawFd}; use std::os::unix::net; use std::path::Path; use std::task::{ready, Context, Poll}; diff --git a/tokio/src/net/unix/listener.rs b/tokio/src/net/unix/listener.rs index 996d3e1dced..f2cfc82d859 100644 --- a/tokio/src/net/unix/listener.rs +++ b/tokio/src/net/unix/listener.rs @@ -6,11 +6,11 @@ use std::fmt; use std::io; #[cfg(target_os = "android")] use std::os::android::net::SocketAddrExt; +use std::os::fd::{AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd, RawFd}; #[cfg(target_os = "linux")] use std::os::linux::net::SocketAddrExt; #[cfg(any(target_os = "linux", target_os = "android"))] use std::os::unix::ffi::OsStrExt; -use std::os::unix::io::{AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd, RawFd}; use std::os::unix::net::{self, SocketAddr as StdSocketAddr}; use std::path::Path; use std::task::{ready, Context, Poll}; diff --git a/tokio/src/net/unix/pipe.rs b/tokio/src/net/unix/pipe.rs index 65bd51ad8a1..e8ac818a3e5 100644 --- a/tokio/src/net/unix/pipe.rs +++ b/tokio/src/net/unix/pipe.rs @@ -6,8 +6,8 @@ use crate::io::{AsyncRead, AsyncWrite, PollEvented, ReadBuf, Ready}; use mio::unix::pipe as mio_pipe; use std::fs::File; use std::io::{self, Read, Write}; +use std::os::fd::{AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd, OwnedFd, RawFd}; use std::os::unix::fs::OpenOptionsExt; -use std::os::unix::io::{AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd, OwnedFd, RawFd}; use std::path::Path; use std::pin::Pin; use std::task::{Context, Poll}; diff --git a/tokio/src/net/unix/socket.rs b/tokio/src/net/unix/socket.rs index cb383b09a59..52f6443145b 100644 --- a/tokio/src/net/unix/socket.rs +++ b/tokio/src/net/unix/socket.rs @@ -1,7 +1,7 @@ use std::io; use std::path::Path; -use std::os::unix::io::{AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd, RawFd}; +use std::os::fd::{AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd, RawFd}; use crate::net::{UnixDatagram, UnixListener, UnixStream}; @@ -178,7 +178,7 @@ impl UnixSocket { self.inner.listen(backlog as i32)?; let mio = { - use std::os::unix::io::{FromRawFd, IntoRawFd}; + use std::os::fd::{FromRawFd, IntoRawFd}; let raw_fd = self.inner.into_raw_fd(); unsafe { mio::net::UnixListener::from_raw_fd(raw_fd) } @@ -213,7 +213,7 @@ impl UnixSocket { } } let mio = { - use std::os::unix::io::{FromRawFd, IntoRawFd}; + use std::os::fd::{FromRawFd, IntoRawFd}; let raw_fd = self.inner.into_raw_fd(); unsafe { mio::net::UnixStream::from_raw_fd(raw_fd) } @@ -235,7 +235,7 @@ impl UnixSocket { )); } let mio = { - use std::os::unix::io::{FromRawFd, IntoRawFd}; + use std::os::fd::{FromRawFd, IntoRawFd}; let raw_fd = self.inner.into_raw_fd(); unsafe { mio::net::UnixDatagram::from_raw_fd(raw_fd) } diff --git a/tokio/src/net/unix/stream.rs b/tokio/src/net/unix/stream.rs index 0381275e3af..2a09929d530 100644 --- a/tokio/src/net/unix/stream.rs +++ b/tokio/src/net/unix/stream.rs @@ -11,11 +11,11 @@ use std::io::{self, Read, Write}; use std::net::Shutdown; #[cfg(target_os = "android")] use std::os::android::net::SocketAddrExt; +use std::os::fd::{AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd, RawFd}; #[cfg(target_os = "linux")] use std::os::linux::net::SocketAddrExt; #[cfg(any(target_os = "linux", target_os = "android"))] use std::os::unix::ffi::OsStrExt; -use std::os::unix::io::{AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd, RawFd}; use std::os::unix::net::{self, SocketAddr as StdSocketAddr}; use std::path::Path; use std::pin::Pin; diff --git a/tokio/src/net/unix/ucred.rs b/tokio/src/net/unix/ucred.rs index bdc417f1304..1fb05c71bbe 100644 --- a/tokio/src/net/unix/ucred.rs +++ b/tokio/src/net/unix/ucred.rs @@ -91,7 +91,7 @@ pub(crate) mod impl_linux { use libc::ucred; pub(crate) fn get_peer_cred(sock: &UnixStream) -> io::Result { - use std::os::unix::io::AsRawFd; + use std::os::fd::AsRawFd; unsafe { let raw_fd = sock.as_raw_fd(); @@ -137,7 +137,7 @@ pub(crate) mod impl_netbsd { use libc::{c_void, getsockopt, socklen_t, unpcbid, LOCAL_PEEREID, SOL_SOCKET}; use std::io; use std::mem::size_of; - use std::os::unix::io::AsRawFd; + use std::os::fd::AsRawFd; pub(crate) fn get_peer_cred(sock: &UnixStream) -> io::Result { unsafe { @@ -179,7 +179,7 @@ pub(crate) mod impl_bsd { use libc::getpeereid; use std::io; use std::mem::MaybeUninit; - use std::os::unix::io::AsRawFd; + use std::os::fd::AsRawFd; pub(crate) fn get_peer_cred(sock: &UnixStream) -> io::Result { unsafe { @@ -217,7 +217,7 @@ pub(crate) mod impl_macos { use std::io; use std::mem::size_of; use std::mem::MaybeUninit; - use std::os::unix::io::AsRawFd; + use std::os::fd::AsRawFd; pub(crate) fn get_peer_cred(sock: &UnixStream) -> io::Result { unsafe { @@ -260,7 +260,7 @@ pub(crate) mod impl_macos { pub(crate) mod impl_solaris { use crate::net::unix::{self, UnixStream}; use std::io; - use std::os::unix::io::AsRawFd; + use std::os::fd::AsRawFd; use std::ptr; pub(crate) fn get_peer_cred(sock: &UnixStream) -> io::Result { @@ -293,7 +293,7 @@ pub(crate) mod impl_solaris { pub(crate) mod impl_aix { use crate::net::unix::UnixStream; use std::io; - use std::os::unix::io::AsRawFd; + use std::os::fd::AsRawFd; pub(crate) fn get_peer_cred(sock: &UnixStream) -> io::Result { unsafe { diff --git a/tokio/src/process/unix/mod.rs b/tokio/src/process/unix/mod.rs index 03cc7fddafa..a8554ff6f86 100644 --- a/tokio/src/process/unix/mod.rs +++ b/tokio/src/process/unix/mod.rs @@ -42,7 +42,7 @@ use std::fmt; use std::fs::File; use std::future::Future; use std::io; -use std::os::unix::io::{AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd, OwnedFd, RawFd}; +use std::os::fd::{AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd, OwnedFd, RawFd}; use std::pin::Pin; use std::process::{Child as StdChild, ExitStatus, Stdio}; use std::task::Context; diff --git a/tokio/src/runtime/signal/mod.rs b/tokio/src/runtime/signal/mod.rs index 8055c0965a6..04a5fad795d 100644 --- a/tokio/src/runtime/signal/mod.rs +++ b/tokio/src/runtime/signal/mod.rs @@ -42,7 +42,7 @@ impl Driver { /// Creates a new signal `Driver` instance that delegates wakeups to `park`. pub(crate) fn new(io: io::Driver, io_handle: &io::Handle) -> std_io::Result { use std::mem::ManuallyDrop; - use std::os::unix::io::{AsRawFd, FromRawFd}; + use std::os::fd::{AsRawFd, FromRawFd}; // NB: We give each driver a "fresh" receiver file descriptor to avoid // the issues described in alexcrichton/tokio-process#42. diff --git a/tokio/tests/async_send_sync.rs b/tokio/tests/async_send_sync.rs index 19cc6aed711..dccd9b6d085 100644 --- a/tokio/tests/async_send_sync.rs +++ b/tokio/tests/async_send_sync.rs @@ -739,8 +739,8 @@ mod unix_asyncfd { struct ImplsFd { _t: T, } - impl std::os::unix::io::AsRawFd for ImplsFd { - fn as_raw_fd(&self) -> std::os::unix::io::RawFd { + impl std::os::fd::AsRawFd for ImplsFd { + fn as_raw_fd(&self) -> std::os::fd::RawFd { unreachable!() } } diff --git a/tokio/tests/fs_file.rs b/tokio/tests/fs_file.rs index e5bc0bd87ff..615d0810eee 100644 --- a/tokio/tests/fs_file.rs +++ b/tokio/tests/fs_file.rs @@ -251,7 +251,7 @@ async fn file_debug_fmt() { #[tokio::test] #[cfg(unix)] async fn unix_fd_is_valid() { - use std::os::unix::io::AsRawFd; + use std::os::fd::AsRawFd; let tempfile = tempfile(); let file = File::create(tempfile.path()).await.unwrap(); @@ -261,7 +261,7 @@ async fn unix_fd_is_valid() { #[tokio::test] #[cfg(unix)] async fn read_file_from_unix_fd() { - use std::os::unix::io::{FromRawFd, IntoRawFd}; + use std::os::fd::{FromRawFd, IntoRawFd}; let mut tempfile = tempfile(); tempfile.write_all(HELLO).unwrap(); diff --git a/tokio/tests/io_async_fd.rs b/tokio/tests/io_async_fd.rs index 51ea79d5155..d6a73f97dac 100644 --- a/tokio/tests/io_async_fd.rs +++ b/tokio/tests/io_async_fd.rs @@ -1,7 +1,7 @@ #![warn(rust_2018_idioms)] #![cfg(all(unix, feature = "full"))] -use std::os::unix::io::{AsRawFd, RawFd}; +use std::os::fd::{AsRawFd, RawFd}; use std::sync::{ atomic::{AtomicBool, Ordering}, Arc, diff --git a/tokio/tests/net_unix_pipe.rs b/tokio/tests/net_unix_pipe.rs index 7169b5b61fe..20cb4b54836 100644 --- a/tokio/tests/net_unix_pipe.rs +++ b/tokio/tests/net_unix_pipe.rs @@ -8,8 +8,8 @@ use tokio_test::{assert_err, assert_ok, assert_pending, assert_ready_ok}; use std::fs::File; use std::io; +use std::os::fd::AsRawFd; use std::os::unix::fs::OpenOptionsExt; -use std::os::unix::io::AsRawFd; use std::path::{Path, PathBuf}; /// Helper struct which will clean up temporary files once dropped.