Skip to content

Commit 5f49faa

Browse files
committed
Cleanup sys module to match house style
1 parent 6106b05 commit 5f49faa

File tree

6 files changed

+32
-42
lines changed

6 files changed

+32
-42
lines changed

library/std/src/sys/anonymous_pipe/tests.rs renamed to library/std/src/pipe/tests.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use crate::{
44
};
55

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

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,14 @@
1+
#![forbid(unsafe_op_in_unsafe_fn)]
2+
13
cfg_if::cfg_if! {
24
if #[cfg(unix)] {
35
mod unix;
4-
pub(crate) use unix::{AnonPipe, pipe};
5-
6-
#[cfg(all(test, not(miri)))]
7-
mod tests;
6+
pub use unix::{AnonPipe, pipe};
87
} else if #[cfg(windows)] {
98
mod windows;
10-
pub(crate) use windows::{AnonPipe, pipe};
11-
12-
#[cfg(all(test, not(miri)))]
13-
mod tests;
9+
pub use windows::{AnonPipe, pipe};
1410
} else {
1511
mod unsupported;
16-
pub(crate) use unsupported::{AnonPipe, pipe};
12+
pub use unsupported::{AnonPipe, pipe};
1713
}
1814
}

library/std/src/sys/anonymous_pipe/unix.rs

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
1-
use crate::{
2-
io,
3-
os::fd::{AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd, OwnedFd, RawFd},
4-
pipe::{PipeReader, PipeWriter},
5-
process::Stdio,
6-
sys::{fd::FileDesc, pipe::anon_pipe},
7-
sys_common::{FromInner, IntoInner},
8-
};
1+
use crate::io;
2+
use crate::os::fd::{AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd, OwnedFd, RawFd};
3+
use crate::pipe::{PipeReader, PipeWriter};
4+
use crate::process::Stdio;
5+
use crate::sys::{fd::FileDesc, pipe::anon_pipe};
6+
use crate::sys_common::{FromInner, IntoInner};
97

10-
pub(crate) type AnonPipe = FileDesc;
8+
pub type AnonPipe = FileDesc;
119

1210
#[inline]
13-
pub(crate) fn pipe() -> io::Result<(AnonPipe, AnonPipe)> {
11+
pub fn pipe() -> io::Result<(AnonPipe, AnonPipe)> {
1412
anon_pipe().map(|(rx, wx)| (rx.into_inner(), wx.into_inner()))
1513
}
1614

@@ -35,7 +33,7 @@ impl From<PipeReader> for OwnedFd {
3533
#[unstable(feature = "anonymous_pipe", issue = "127154")]
3634
impl FromRawFd for PipeReader {
3735
unsafe fn from_raw_fd(raw_fd: RawFd) -> Self {
38-
Self(FileDesc::from_raw_fd(raw_fd))
36+
unsafe { Self(FileDesc::from_raw_fd(raw_fd)) }
3937
}
4038
}
4139
#[unstable(feature = "anonymous_pipe", issue = "127154")]
@@ -72,7 +70,7 @@ impl From<PipeWriter> for OwnedFd {
7270
#[unstable(feature = "anonymous_pipe", issue = "127154")]
7371
impl FromRawFd for PipeWriter {
7472
unsafe fn from_raw_fd(raw_fd: RawFd) -> Self {
75-
Self(FileDesc::from_raw_fd(raw_fd))
73+
unsafe { Self(FileDesc::from_raw_fd(raw_fd)) }
7674
}
7775
}
7876
#[unstable(feature = "anonymous_pipe", issue = "127154")]

library/std/src/sys/anonymous_pipe/unsupported.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1-
use crate::{
2-
io,
3-
pipe::{PipeReader, PipeWriter},
4-
process::Stdio,
5-
};
1+
use crate::io;
2+
use crate::pipe::{PipeReader, PipeWriter};
3+
use crate::process::Stdio;
64

7-
pub(crate) use crate::sys::pipe::AnonPipe;
5+
pub use crate::sys::pipe::AnonPipe;
86

97
#[inline]
10-
pub(crate) fn pipe() -> io::Result<(AnonPipe, AnonPipe)> {
8+
pub fn pipe() -> io::Result<(AnonPipe, AnonPipe)> {
119
Err(io::Error::UNSUPPORTED_PLATFORM)
1210
}
1311

library/std/src/sys/anonymous_pipe/windows.rs

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
1-
use crate::{
2-
io,
3-
os::windows::io::{
4-
AsHandle, AsRawHandle, BorrowedHandle, FromRawHandle, IntoRawHandle, OwnedHandle, RawHandle,
5-
},
6-
pipe::{PipeReader, PipeWriter},
7-
process::Stdio,
8-
sys::{handle::Handle, pipe::unnamed_anon_pipe},
9-
sys_common::{FromInner, IntoInner},
1+
use crate::io;
2+
use crate::os::windows::io::{
3+
AsHandle, AsRawHandle, BorrowedHandle, FromRawHandle, IntoRawHandle, OwnedHandle, RawHandle,
104
};
5+
use crate::pipe::{PipeReader, PipeWriter};
6+
use crate::process::Stdio;
7+
use crate::sys::{handle::Handle, pipe::unnamed_anon_pipe};
8+
use crate::sys_common::{FromInner, IntoInner};
119

12-
pub(crate) type AnonPipe = Handle;
10+
pub type AnonPipe = Handle;
1311

1412
#[inline]
15-
pub(crate) fn pipe() -> io::Result<(AnonPipe, AnonPipe)> {
13+
pub fn pipe() -> io::Result<(AnonPipe, AnonPipe)> {
1614
unnamed_anon_pipe().map(|(rx, wx)| (rx.into_inner(), wx.into_inner()))
1715
}
1816

@@ -32,7 +30,7 @@ impl AsRawHandle for PipeReader {
3230
#[unstable(feature = "anonymous_pipe", issue = "127154")]
3331
impl FromRawHandle for PipeReader {
3432
unsafe fn from_raw_handle(raw_handle: RawHandle) -> Self {
35-
Self(Handle::from_raw_handle(raw_handle))
33+
unsafe { Self(Handle::from_raw_handle(raw_handle)) }
3634
}
3735
}
3836
#[unstable(feature = "anonymous_pipe", issue = "127154")]
@@ -71,7 +69,7 @@ impl AsRawHandle for PipeWriter {
7169
#[unstable(feature = "anonymous_pipe", issue = "127154")]
7270
impl FromRawHandle for PipeWriter {
7371
unsafe fn from_raw_handle(raw_handle: RawHandle) -> Self {
74-
Self(Handle::from_raw_handle(raw_handle))
72+
unsafe { Self(Handle::from_raw_handle(raw_handle)) }
7573
}
7674
}
7775
#[unstable(feature = "anonymous_pipe", issue = "127154")]

library/std/src/sys/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ mod pal;
77

88
mod personality;
99

10-
#[unstable(feature = "anonymous_pipe", issue = "127154")]
1110
pub mod anonymous_pipe;
1211
pub mod backtrace;
1312
pub mod cmath;

0 commit comments

Comments
 (0)