Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix compilation errors with feature = io_safety. #1084

Merged
merged 1 commit into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/fs/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ cfg_unix! {

impl From<File> for OwnedFd {
fn from(val: File) -> OwnedFd {
self.into_std_file().into()
val.into_std_file().into()
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion src/io/stderr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,9 @@ cfg_unix! {

impl AsFd for Stderr {
fn as_fd(&self) -> BorrowedFd<'_> {
std::io::stderr().as_fd()
unsafe {
BorrowedFd::borrow_raw(std::io::stderr().as_raw_fd())
}
}
}
}
Expand Down
6 changes: 4 additions & 2 deletions src/io/stdin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,9 +210,11 @@ cfg_unix! {
cfg_io_safety! {
use crate::os::unix::io::{AsFd, BorrowedFd};

impl AsFd for Stderr {
impl AsFd for Stdin {
fn as_fd(&self) -> BorrowedFd<'_> {
std::io::stdin().as_fd()
unsafe {
BorrowedFd::borrow_raw(std::io::stdin().as_raw_fd())
}
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion src/io/stdout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,9 @@ cfg_unix! {

impl AsFd for Stdout {
fn as_fd(&self) -> BorrowedFd<'_> {
std::io::stdout().as_fd()
unsafe {
BorrowedFd::borrow_raw(std::io::stdout().as_raw_fd())
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/net/tcp/stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ cfg_unix! {

impl From<TcpStream> for OwnedFd {
fn from(stream: TcpStream) -> OwnedFd {
stream.watcher.into_inner().unwrap().into()
stream.watcher.get_ref().try_clone().unwrap().into()
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/net/udp/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,7 @@ cfg_unix! {

impl From<OwnedFd> for UdpSocket {
fn from(fd: OwnedFd) -> UdpSocket {
std::net::TcpStream::from(fd).into()
std::net::UdpSocket::from(fd).into()
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/os/unix/net/datagram.rs
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ cfg_io_safety! {

impl From<OwnedFd> for UnixDatagram {
fn from(fd: OwnedFd) -> UnixDatagram {
std::net::TcpStream::from(fd).into()
StdUnixDatagram::from(fd).into()
}
}

Expand All @@ -361,4 +361,4 @@ cfg_io_safety! {
stream.watcher.into_inner().unwrap().into()
}
}
}
}
4 changes: 2 additions & 2 deletions src/os/unix/net/listener.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ cfg_io_safety! {

impl From<OwnedFd> for UnixListener {
fn from(fd: OwnedFd) -> UnixListener {
std::net::TcpStream::from(fd).into()
std::os::unix::net::UnixListener::from(fd).into()
}
}

Expand All @@ -254,4 +254,4 @@ cfg_io_safety! {
stream.watcher.into_inner().unwrap().into()
}
}
}
}
6 changes: 3 additions & 3 deletions src/os/unix/net/stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -276,13 +276,13 @@ cfg_io_safety! {

impl From<OwnedFd> for UnixStream {
fn from(fd: OwnedFd) -> UnixStream {
std::net::TcpStream::from(fd).into()
std::os::unix::net::UnixStream::from(fd).into()
}
}

impl From<UnixStream> for OwnedFd {
fn from(stream: UnixStream) -> OwnedFd {
stream.watcher.into_inner().unwrap().into()
stream.watcher.get_ref().try_clone().unwrap().into()
}
}
}
}
2 changes: 1 addition & 1 deletion src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
}

/// Add additional context to errors
pub(crate) trait Context {

Check failure on line 58 in src/utils.rs

View workflow job for this annotation

GitHub Actions / Build with no-std

trait `Context` is never used
fn context(self, message: impl Fn() -> String) -> Self;
}

Expand Down Expand Up @@ -246,7 +246,7 @@
macro_rules! cfg_io_safety {
($($item:item)*) => {
$(
#[cfg(feature = "io-safety")]
#[cfg(feature = "io_safety")]
$item
)*
}
Expand Down
Loading