Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Cleanup sys module to match house style
  • Loading branch information
ChrisDenton committed Jul 30, 2024
commit a75d2f9d384135c5f0f6bd6d26ec2ba9aa76745a
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use crate::io::{Read, Write};
use crate::pipe::pipe;

#[test]
#[cfg(all(windows, unix, not(miri)))]
fn pipe_creation_clone_and_rw() {
let (rx, tx) = pipe().unwrap();

Expand Down
14 changes: 5 additions & 9 deletions library/std/src/sys/anonymous_pipe/mod.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
#![forbid(unsafe_op_in_unsafe_fn)]

cfg_if::cfg_if! {
if #[cfg(unix)] {
mod unix;
pub(crate) use unix::{AnonPipe, pipe};

#[cfg(all(test, not(miri)))]
mod tests;
pub use unix::{AnonPipe, pipe};
} else if #[cfg(windows)] {
mod windows;
pub(crate) use windows::{AnonPipe, pipe};

#[cfg(all(test, not(miri)))]
mod tests;
pub use windows::{AnonPipe, pipe};
} else {
mod unsupported;
pub(crate) use unsupported::{AnonPipe, pipe};
pub use unsupported::{AnonPipe, pipe};
}
}
8 changes: 4 additions & 4 deletions library/std/src/sys/anonymous_pipe/unix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ use crate::sys::fd::FileDesc;
use crate::sys::pipe::anon_pipe;
use crate::sys_common::{FromInner, IntoInner};

pub(crate) type AnonPipe = FileDesc;
pub type AnonPipe = FileDesc;

#[inline]
pub(crate) fn pipe() -> io::Result<(AnonPipe, AnonPipe)> {
pub fn pipe() -> io::Result<(AnonPipe, AnonPipe)> {
anon_pipe().map(|(rx, wx)| (rx.into_inner(), wx.into_inner()))
}

Expand All @@ -34,7 +34,7 @@ impl From<PipeReader> for OwnedFd {
#[unstable(feature = "anonymous_pipe", issue = "127154")]
impl FromRawFd for PipeReader {
unsafe fn from_raw_fd(raw_fd: RawFd) -> Self {
Self(FileDesc::from_raw_fd(raw_fd))
unsafe { Self(FileDesc::from_raw_fd(raw_fd)) }
}
}
#[unstable(feature = "anonymous_pipe", issue = "127154")]
Expand Down Expand Up @@ -71,7 +71,7 @@ impl From<PipeWriter> for OwnedFd {
#[unstable(feature = "anonymous_pipe", issue = "127154")]
impl FromRawFd for PipeWriter {
unsafe fn from_raw_fd(raw_fd: RawFd) -> Self {
Self(FileDesc::from_raw_fd(raw_fd))
unsafe { Self(FileDesc::from_raw_fd(raw_fd)) }
}
}
#[unstable(feature = "anonymous_pipe", issue = "127154")]
Expand Down
2 changes: 1 addition & 1 deletion library/std/src/sys/anonymous_pipe/unsupported.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crate::process::Stdio;
pub(crate) use crate::sys::pipe::AnonPipe;

#[inline]
pub(crate) fn pipe() -> io::Result<(AnonPipe, AnonPipe)> {
pub fn pipe() -> io::Result<(AnonPipe, AnonPipe)> {
Err(io::Error::UNSUPPORTED_PLATFORM)
}

Expand Down
8 changes: 4 additions & 4 deletions library/std/src/sys/anonymous_pipe/windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ use crate::sys::handle::Handle;
use crate::sys::pipe::unnamed_anon_pipe;
use crate::sys_common::{FromInner, IntoInner};

pub(crate) type AnonPipe = Handle;
pub type AnonPipe = Handle;

#[inline]
pub(crate) fn pipe() -> io::Result<(AnonPipe, AnonPipe)> {
pub fn pipe() -> io::Result<(AnonPipe, AnonPipe)> {
unnamed_anon_pipe().map(|(rx, wx)| (rx.into_inner(), wx.into_inner()))
}

Expand All @@ -31,7 +31,7 @@ impl AsRawHandle for PipeReader {
#[unstable(feature = "anonymous_pipe", issue = "127154")]
impl FromRawHandle for PipeReader {
unsafe fn from_raw_handle(raw_handle: RawHandle) -> Self {
Self(Handle::from_raw_handle(raw_handle))
unsafe { Self(Handle::from_raw_handle(raw_handle)) }
}
}
#[unstable(feature = "anonymous_pipe", issue = "127154")]
Expand Down Expand Up @@ -70,7 +70,7 @@ impl AsRawHandle for PipeWriter {
#[unstable(feature = "anonymous_pipe", issue = "127154")]
impl FromRawHandle for PipeWriter {
unsafe fn from_raw_handle(raw_handle: RawHandle) -> Self {
Self(Handle::from_raw_handle(raw_handle))
unsafe { Self(Handle::from_raw_handle(raw_handle)) }
}
}
#[unstable(feature = "anonymous_pipe", issue = "127154")]
Expand Down
1 change: 0 additions & 1 deletion library/std/src/sys/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ mod pal;

mod personality;

#[unstable(feature = "anonymous_pipe", issue = "127154")]
pub mod anonymous_pipe;
pub mod backtrace;
pub mod cmath;
Expand Down