Skip to content

Commit 858ec72

Browse files
authored
Unrolled build for rust-lang#137793
Rollup merge of rust-lang#137793 - NobodyXu:stablise-annoymous-pipe, r=joshtriplett Stablize anonymous pipe Since rust-lang#135822 is staled, I create this PR to stablise anonymous pipe Closes rust-lang#127154 try-job: test-various
2 parents 9bad8ac + 6863a99 commit 858ec72

File tree

15 files changed

+288
-225
lines changed

15 files changed

+288
-225
lines changed

library/std/src/io/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ pub use self::error::RawOsError;
310310
pub use self::error::SimpleMessage;
311311
#[unstable(feature = "io_const_error", issue = "133448")]
312312
pub use self::error::const_error;
313-
#[unstable(feature = "anonymous_pipe", issue = "127154")]
313+
#[stable(feature = "anonymous_pipe", since = "CURRENT_RUSTC_VERSION")]
314314
pub use self::pipe::{PipeReader, PipeWriter, pipe};
315315
#[stable(feature = "is_terminal", since = "1.70.0")]
316316
pub use self::stdio::IsTerminal;

library/std/src/io/pipe.rs

+34-12
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use crate::io;
22
use crate::sys::anonymous_pipe::{AnonPipe, pipe as pipe_inner};
3+
use crate::sys_common::{FromInner, IntoInner};
34

45
/// Create an anonymous pipe.
56
///
@@ -40,7 +41,6 @@ use crate::sys::anonymous_pipe::{AnonPipe, pipe as pipe_inner};
4041
/// # Examples
4142
///
4243
/// ```no_run
43-
/// #![feature(anonymous_pipe)]
4444
/// # #[cfg(miri)] fn main() {}
4545
/// # #[cfg(not(miri))]
4646
/// # fn main() -> std::io::Result<()> {
@@ -67,29 +67,52 @@ use crate::sys::anonymous_pipe::{AnonPipe, pipe as pipe_inner};
6767
/// ```
6868
/// [changes]: io#platform-specific-behavior
6969
/// [man page]: https://man7.org/linux/man-pages/man7/pipe.7.html
70-
#[unstable(feature = "anonymous_pipe", issue = "127154")]
70+
#[stable(feature = "anonymous_pipe", since = "CURRENT_RUSTC_VERSION")]
7171
#[inline]
7272
pub fn pipe() -> io::Result<(PipeReader, PipeWriter)> {
7373
pipe_inner().map(|(reader, writer)| (PipeReader(reader), PipeWriter(writer)))
7474
}
7575

7676
/// Read end of an anonymous pipe.
77-
#[unstable(feature = "anonymous_pipe", issue = "127154")]
77+
#[stable(feature = "anonymous_pipe", since = "CURRENT_RUSTC_VERSION")]
7878
#[derive(Debug)]
7979
pub struct PipeReader(pub(crate) AnonPipe);
8080

8181
/// Write end of an anonymous pipe.
82-
#[unstable(feature = "anonymous_pipe", issue = "127154")]
82+
#[stable(feature = "anonymous_pipe", since = "CURRENT_RUSTC_VERSION")]
8383
#[derive(Debug)]
8484
pub struct PipeWriter(pub(crate) AnonPipe);
8585

86+
impl FromInner<AnonPipe> for PipeReader {
87+
fn from_inner(inner: AnonPipe) -> Self {
88+
Self(inner)
89+
}
90+
}
91+
92+
impl IntoInner<AnonPipe> for PipeReader {
93+
fn into_inner(self) -> AnonPipe {
94+
self.0
95+
}
96+
}
97+
98+
impl FromInner<AnonPipe> for PipeWriter {
99+
fn from_inner(inner: AnonPipe) -> Self {
100+
Self(inner)
101+
}
102+
}
103+
104+
impl IntoInner<AnonPipe> for PipeWriter {
105+
fn into_inner(self) -> AnonPipe {
106+
self.0
107+
}
108+
}
109+
86110
impl PipeReader {
87111
/// Create a new [`PipeReader`] instance that shares the same underlying file description.
88112
///
89113
/// # Examples
90114
///
91115
/// ```no_run
92-
/// #![feature(anonymous_pipe)]
93116
/// # #[cfg(miri)] fn main() {}
94117
/// # #[cfg(not(miri))]
95118
/// # fn main() -> std::io::Result<()> {
@@ -137,7 +160,7 @@ impl PipeReader {
137160
/// # Ok(())
138161
/// # }
139162
/// ```
140-
#[unstable(feature = "anonymous_pipe", issue = "127154")]
163+
#[stable(feature = "anonymous_pipe", since = "CURRENT_RUSTC_VERSION")]
141164
pub fn try_clone(&self) -> io::Result<Self> {
142165
self.0.try_clone().map(Self)
143166
}
@@ -149,7 +172,6 @@ impl PipeWriter {
149172
/// # Examples
150173
///
151174
/// ```no_run
152-
/// #![feature(anonymous_pipe)]
153175
/// # #[cfg(miri)] fn main() {}
154176
/// # #[cfg(not(miri))]
155177
/// # fn main() -> std::io::Result<()> {
@@ -177,13 +199,13 @@ impl PipeWriter {
177199
/// # Ok(())
178200
/// # }
179201
/// ```
180-
#[unstable(feature = "anonymous_pipe", issue = "127154")]
202+
#[stable(feature = "anonymous_pipe", since = "CURRENT_RUSTC_VERSION")]
181203
pub fn try_clone(&self) -> io::Result<Self> {
182204
self.0.try_clone().map(Self)
183205
}
184206
}
185207

186-
#[unstable(feature = "anonymous_pipe", issue = "127154")]
208+
#[stable(feature = "anonymous_pipe", since = "CURRENT_RUSTC_VERSION")]
187209
impl io::Read for &PipeReader {
188210
fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
189211
self.0.read(buf)
@@ -203,7 +225,7 @@ impl io::Read for &PipeReader {
203225
}
204226
}
205227

206-
#[unstable(feature = "anonymous_pipe", issue = "127154")]
228+
#[stable(feature = "anonymous_pipe", since = "CURRENT_RUSTC_VERSION")]
207229
impl io::Read for PipeReader {
208230
fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
209231
self.0.read(buf)
@@ -223,7 +245,7 @@ impl io::Read for PipeReader {
223245
}
224246
}
225247

226-
#[unstable(feature = "anonymous_pipe", issue = "127154")]
248+
#[stable(feature = "anonymous_pipe", since = "CURRENT_RUSTC_VERSION")]
227249
impl io::Write for &PipeWriter {
228250
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
229251
self.0.write(buf)
@@ -241,7 +263,7 @@ impl io::Write for &PipeWriter {
241263
}
242264
}
243265

244-
#[unstable(feature = "anonymous_pipe", issue = "127154")]
266+
#[stable(feature = "anonymous_pipe", since = "CURRENT_RUSTC_VERSION")]
245267
impl io::Write for PipeWriter {
246268
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
247269
self.0.write(buf)

library/std/src/os/fd/owned.rs

+44-1
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@ use crate::mem::ManuallyDrop;
1515
target_os = "trusty"
1616
)))]
1717
use crate::sys::cvt;
18+
use crate::sys_common::FromInner;
1819
#[cfg(not(target_os = "trusty"))]
19-
use crate::sys_common::{AsInner, FromInner, IntoInner};
20+
use crate::sys_common::{AsInner, IntoInner};
2021
use crate::{fmt, io};
2122

2223
type ValidRawFd = core::num::niche_types::NotAllOnes<RawFd>;
@@ -504,3 +505,45 @@ impl<'a> AsFd for io::StderrLock<'a> {
504505
unsafe { BorrowedFd::borrow_raw(2) }
505506
}
506507
}
508+
509+
#[stable(feature = "anonymous_pipe", since = "CURRENT_RUSTC_VERSION")]
510+
impl AsFd for io::PipeReader {
511+
fn as_fd(&self) -> BorrowedFd<'_> {
512+
self.0.as_fd()
513+
}
514+
}
515+
516+
#[stable(feature = "anonymous_pipe", since = "CURRENT_RUSTC_VERSION")]
517+
impl From<io::PipeReader> for OwnedFd {
518+
fn from(pipe: io::PipeReader) -> Self {
519+
pipe.0.into_inner()
520+
}
521+
}
522+
523+
#[stable(feature = "anonymous_pipe", since = "CURRENT_RUSTC_VERSION")]
524+
impl AsFd for io::PipeWriter {
525+
fn as_fd(&self) -> BorrowedFd<'_> {
526+
self.0.as_fd()
527+
}
528+
}
529+
530+
#[stable(feature = "anonymous_pipe", since = "CURRENT_RUSTC_VERSION")]
531+
impl From<io::PipeWriter> for OwnedFd {
532+
fn from(pipe: io::PipeWriter) -> Self {
533+
pipe.0.into_inner()
534+
}
535+
}
536+
537+
#[stable(feature = "anonymous_pipe", since = "CURRENT_RUSTC_VERSION")]
538+
impl From<OwnedFd> for io::PipeReader {
539+
fn from(owned_fd: OwnedFd) -> Self {
540+
Self(FromInner::from_inner(owned_fd))
541+
}
542+
}
543+
544+
#[stable(feature = "anonymous_pipe", since = "CURRENT_RUSTC_VERSION")]
545+
impl From<OwnedFd> for io::PipeWriter {
546+
fn from(owned_fd: OwnedFd) -> Self {
547+
Self(FromInner::from_inner(owned_fd))
548+
}
549+
}

library/std/src/os/fd/raw.rs

+43
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ use crate::os::unix::io::AsFd;
1818
use crate::os::unix::io::OwnedFd;
1919
#[cfg(target_os = "wasi")]
2020
use crate::os::wasi::io::OwnedFd;
21+
use crate::sys_common::FromInner;
2122
#[cfg(not(target_os = "trusty"))]
2223
use crate::sys_common::{AsInner, IntoInner};
2324

@@ -284,3 +285,45 @@ impl<T: AsRawFd> AsRawFd for Box<T> {
284285
(**self).as_raw_fd()
285286
}
286287
}
288+
289+
#[stable(feature = "anonymous_pipe", since = "CURRENT_RUSTC_VERSION")]
290+
impl AsRawFd for io::PipeReader {
291+
fn as_raw_fd(&self) -> RawFd {
292+
self.0.as_raw_fd()
293+
}
294+
}
295+
296+
#[stable(feature = "anonymous_pipe", since = "CURRENT_RUSTC_VERSION")]
297+
impl FromRawFd for io::PipeReader {
298+
unsafe fn from_raw_fd(raw_fd: RawFd) -> Self {
299+
Self::from_inner(unsafe { FromRawFd::from_raw_fd(raw_fd) })
300+
}
301+
}
302+
303+
#[stable(feature = "anonymous_pipe", since = "CURRENT_RUSTC_VERSION")]
304+
impl IntoRawFd for io::PipeReader {
305+
fn into_raw_fd(self) -> RawFd {
306+
self.0.into_raw_fd()
307+
}
308+
}
309+
310+
#[stable(feature = "anonymous_pipe", since = "CURRENT_RUSTC_VERSION")]
311+
impl AsRawFd for io::PipeWriter {
312+
fn as_raw_fd(&self) -> RawFd {
313+
self.0.as_raw_fd()
314+
}
315+
}
316+
317+
#[stable(feature = "anonymous_pipe", since = "CURRENT_RUSTC_VERSION")]
318+
impl FromRawFd for io::PipeWriter {
319+
unsafe fn from_raw_fd(raw_fd: RawFd) -> Self {
320+
Self::from_inner(unsafe { FromRawFd::from_raw_fd(raw_fd) })
321+
}
322+
}
323+
324+
#[stable(feature = "anonymous_pipe", since = "CURRENT_RUSTC_VERSION")]
325+
impl IntoRawFd for io::PipeWriter {
326+
fn into_raw_fd(self) -> RawFd {
327+
self.0.into_raw_fd()
328+
}
329+
}

library/std/src/os/windows/io/handle.rs

+42
Original file line numberDiff line numberDiff line change
@@ -660,3 +660,45 @@ impl<T> From<crate::thread::JoinHandle<T>> for OwnedHandle {
660660
join_handle.into_inner().into_handle().into_inner()
661661
}
662662
}
663+
664+
#[stable(feature = "anonymous_pipe", since = "CURRENT_RUSTC_VERSION")]
665+
impl AsHandle for io::PipeReader {
666+
fn as_handle(&self) -> BorrowedHandle<'_> {
667+
self.0.as_handle()
668+
}
669+
}
670+
671+
#[stable(feature = "anonymous_pipe", since = "CURRENT_RUSTC_VERSION")]
672+
impl From<io::PipeReader> for OwnedHandle {
673+
fn from(pipe: io::PipeReader) -> Self {
674+
pipe.into_inner().into_inner()
675+
}
676+
}
677+
678+
#[stable(feature = "anonymous_pipe", since = "CURRENT_RUSTC_VERSION")]
679+
impl AsHandle for io::PipeWriter {
680+
fn as_handle(&self) -> BorrowedHandle<'_> {
681+
self.0.as_handle()
682+
}
683+
}
684+
685+
#[stable(feature = "anonymous_pipe", since = "CURRENT_RUSTC_VERSION")]
686+
impl From<io::PipeWriter> for OwnedHandle {
687+
fn from(pipe: io::PipeWriter) -> Self {
688+
pipe.into_inner().into_inner()
689+
}
690+
}
691+
692+
#[stable(feature = "anonymous_pipe", since = "CURRENT_RUSTC_VERSION")]
693+
impl From<OwnedHandle> for io::PipeReader {
694+
fn from(owned_handle: OwnedHandle) -> Self {
695+
Self::from_inner(FromInner::from_inner(owned_handle))
696+
}
697+
}
698+
699+
#[stable(feature = "anonymous_pipe", since = "CURRENT_RUSTC_VERSION")]
700+
impl From<OwnedHandle> for io::PipeWriter {
701+
fn from(owned_handle: OwnedHandle) -> Self {
702+
Self::from_inner(FromInner::from_inner(owned_handle))
703+
}
704+
}

library/std/src/os/windows/io/raw.rs

+42
Original file line numberDiff line numberDiff line change
@@ -310,3 +310,45 @@ impl IntoRawSocket for net::UdpSocket {
310310
self.into_inner().into_socket().into_inner().into_raw_socket()
311311
}
312312
}
313+
314+
#[stable(feature = "anonymous_pipe", since = "CURRENT_RUSTC_VERSION")]
315+
impl AsRawHandle for io::PipeReader {
316+
fn as_raw_handle(&self) -> RawHandle {
317+
self.0.as_raw_handle()
318+
}
319+
}
320+
321+
#[stable(feature = "anonymous_pipe", since = "CURRENT_RUSTC_VERSION")]
322+
impl FromRawHandle for io::PipeReader {
323+
unsafe fn from_raw_handle(raw_handle: RawHandle) -> Self {
324+
unsafe { Self::from_inner(FromRawHandle::from_raw_handle(raw_handle)) }
325+
}
326+
}
327+
328+
#[stable(feature = "anonymous_pipe", since = "CURRENT_RUSTC_VERSION")]
329+
impl IntoRawHandle for io::PipeReader {
330+
fn into_raw_handle(self) -> RawHandle {
331+
self.0.into_raw_handle()
332+
}
333+
}
334+
335+
#[stable(feature = "anonymous_pipe", since = "CURRENT_RUSTC_VERSION")]
336+
impl AsRawHandle for io::PipeWriter {
337+
fn as_raw_handle(&self) -> RawHandle {
338+
self.0.as_raw_handle()
339+
}
340+
}
341+
342+
#[stable(feature = "anonymous_pipe", since = "CURRENT_RUSTC_VERSION")]
343+
impl FromRawHandle for io::PipeWriter {
344+
unsafe fn from_raw_handle(raw_handle: RawHandle) -> Self {
345+
unsafe { Self::from_inner(FromRawHandle::from_raw_handle(raw_handle)) }
346+
}
347+
}
348+
349+
#[stable(feature = "anonymous_pipe", since = "CURRENT_RUSTC_VERSION")]
350+
impl IntoRawHandle for io::PipeWriter {
351+
fn into_raw_handle(self) -> RawHandle {
352+
self.0.into_raw_handle()
353+
}
354+
}

library/std/src/process.rs

+14
Original file line numberDiff line numberDiff line change
@@ -1659,6 +1659,20 @@ impl From<io::Stderr> for Stdio {
16591659
}
16601660
}
16611661

1662+
#[stable(feature = "anonymous_pipe", since = "CURRENT_RUSTC_VERSION")]
1663+
impl From<io::PipeWriter> for Stdio {
1664+
fn from(pipe: io::PipeWriter) -> Self {
1665+
Stdio::from_inner(pipe.into_inner().into())
1666+
}
1667+
}
1668+
1669+
#[stable(feature = "anonymous_pipe", since = "CURRENT_RUSTC_VERSION")]
1670+
impl From<io::PipeReader> for Stdio {
1671+
fn from(pipe: io::PipeReader) -> Self {
1672+
Stdio::from_inner(pipe.into_inner().into())
1673+
}
1674+
}
1675+
16621676
/// Describes the result of a process after it has terminated.
16631677
///
16641678
/// This `struct` is used to represent the exit status or other termination of a child process.

0 commit comments

Comments
 (0)