Skip to content

Commit 13f9a4c

Browse files
authored
Rollup merge of #87759 - m-ou-se:linux-process-sealed, r=jyn514
Re-use std::sealed::Sealed in os/linux/process. This uses `std::sealed::Sealed` in `std::os::linux::process` instead of defining new `Sealed` traits there.
2 parents 5a36cdb + f280a12 commit 13f9a4c

File tree

2 files changed

+7
-12
lines changed

2 files changed

+7
-12
lines changed

library/std/src/os/linux/process.rs

+3-12
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use crate::io::Result;
66
use crate::os::unix::io::{AsRawFd, FromRawFd, IntoRawFd, RawFd};
77
use crate::process;
8+
use crate::sealed::Sealed;
89
#[cfg(not(doc))]
910
use crate::sys::fd::FileDesc;
1011
use crate::sys_common::{AsInner, AsInnerMut, FromInner, IntoInner};
@@ -84,15 +85,10 @@ impl IntoRawFd for PidFd {
8485
}
8586
}
8687

87-
mod private_child_ext {
88-
pub trait Sealed {}
89-
impl Sealed for crate::process::Child {}
90-
}
91-
9288
/// Os-specific extensions for [`Child`]
9389
///
9490
/// [`Child`]: process::Child
95-
pub trait ChildExt: private_child_ext::Sealed {
91+
pub trait ChildExt: Sealed {
9692
/// Obtains a reference to the [`PidFd`] created for this [`Child`], if available.
9793
///
9894
/// A pidfd will only be available if its creation was requested with
@@ -120,15 +116,10 @@ pub trait ChildExt: private_child_ext::Sealed {
120116
fn take_pidfd(&mut self) -> Result<PidFd>;
121117
}
122118

123-
mod private_command_ext {
124-
pub trait Sealed {}
125-
impl Sealed for crate::process::Command {}
126-
}
127-
128119
/// Os-specific extensions for [`Command`]
129120
///
130121
/// [`Command`]: process::Command
131-
pub trait CommandExt: private_command_ext::Sealed {
122+
pub trait CommandExt: Sealed {
132123
/// Sets whether a [`PidFd`](struct@PidFd) should be created for the [`Child`]
133124
/// spawned by this [`Command`].
134125
/// By default, no pidfd will be created.

library/std/src/process.rs

+4
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,10 @@ pub struct Child {
205205
pub stderr: Option<ChildStderr>,
206206
}
207207

208+
/// Allows extension traits within `std`.
209+
#[unstable(feature = "sealed", issue = "none")]
210+
impl crate::sealed::Sealed for Child {}
211+
208212
impl AsInner<imp::Process> for Child {
209213
fn as_inner(&self) -> &imp::Process {
210214
&self.handle

0 commit comments

Comments
 (0)