Skip to content

Commit 800d4f2

Browse files
committed
Move Sealed traits to std::sealed::Sealed.
This also marks it as unstable, as it should never be used outside std.
1 parent 339e196 commit 800d4f2

File tree

3 files changed

+16
-22
lines changed

3 files changed

+16
-22
lines changed

library/std/src/lib.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -579,3 +579,11 @@ include!("keyword_docs.rs");
579579
// is unconditional, so the unstable feature needs to be defined somewhere.
580580
#[unstable(feature = "restricted_std", issue = "none")]
581581
mod __restricted_std_workaround {}
582+
583+
mod sealed {
584+
/// This trait being unreachable from outside the crate
585+
/// prevents outside implementations of our extension traits.
586+
/// This allows adding more trait methods in the future.
587+
#[unstable(feature = "sealed", issue = "none")]
588+
pub trait Sealed {}
589+
}

library/std/src/sys/unix/ext/process.rs

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,10 @@ use crate::ffi::OsStr;
66
use crate::io;
77
use crate::os::unix::io::{AsRawFd, FromRawFd, IntoRawFd, RawFd};
88
use crate::process;
9+
use crate::sealed::Sealed;
910
use crate::sys;
1011
use crate::sys_common::{AsInner, AsInnerMut, FromInner, IntoInner};
1112

12-
mod private {
13-
/// This trait being unreachable from outside the crate
14-
/// prevents other implementations of the `ExitStatusExt` trait,
15-
/// which allows potentially adding more trait methods in the future.
16-
#[stable(feature = "none", since = "1.51.0")]
17-
pub trait Sealed {}
18-
}
19-
2013
/// Unix-specific extensions to the [`process::Command`] builder.
2114
#[stable(feature = "rust1", since = "1.0.0")]
2215
pub trait CommandExt {
@@ -175,7 +168,7 @@ impl CommandExt for process::Command {
175168
/// This trait is sealed: it cannot be implemented outside the standard library.
176169
/// This is so that future additional methods are not breaking changes.
177170
#[stable(feature = "rust1", since = "1.0.0")]
178-
pub trait ExitStatusExt: private::Sealed {
171+
pub trait ExitStatusExt: Sealed {
179172
/// Creates a new `ExitStatus` from the raw underlying `i32` return value of
180173
/// a process.
181174
#[stable(feature = "exit_status_from", since = "1.12.0")]
@@ -210,8 +203,8 @@ pub trait ExitStatusExt: private::Sealed {
210203
fn into_raw(self) -> i32;
211204
}
212205

213-
#[stable(feature = "none", since = "1.51.0")]
214-
impl private::Sealed for process::ExitStatus {}
206+
#[unstable(feature = "sealed", issue = "none")]
207+
impl Sealed for process::ExitStatus {}
215208

216209
#[stable(feature = "rust1", since = "1.0.0")]
217210
impl ExitStatusExt for process::ExitStatus {

library/std/src/sys/windows/ext/process.rs

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,10 @@
44

55
use crate::os::windows::io::{AsRawHandle, FromRawHandle, IntoRawHandle, RawHandle};
66
use crate::process;
7+
use crate::sealed::Sealed;
78
use crate::sys;
89
use crate::sys_common::{AsInner, AsInnerMut, FromInner, IntoInner};
910

10-
mod private {
11-
/// This trait being unreachable from outside the crate
12-
/// prevents other implementations of the `ExitStatusExt` trait,
13-
/// which allows potentially adding more trait methods in the future.
14-
#[stable(feature = "none", since = "1.51.0")]
15-
pub trait Sealed {}
16-
}
17-
1811
#[stable(feature = "process_extensions", since = "1.2.0")]
1912
impl FromRawHandle for process::Stdio {
2013
unsafe fn from_raw_handle(handle: RawHandle) -> process::Stdio {
@@ -85,7 +78,7 @@ impl IntoRawHandle for process::ChildStderr {
8578
/// This trait is sealed: it cannot be implemented outside the standard library.
8679
/// This is so that future additional methods are not breaking changes.
8780
#[stable(feature = "exit_status_from", since = "1.12.0")]
88-
pub trait ExitStatusExt: private::Sealed {
81+
pub trait ExitStatusExt: Sealed {
8982
/// Creates a new `ExitStatus` from the raw underlying `u32` return value of
9083
/// a process.
9184
#[stable(feature = "exit_status_from", since = "1.12.0")]
@@ -99,8 +92,8 @@ impl ExitStatusExt for process::ExitStatus {
9992
}
10093
}
10194

102-
#[stable(feature = "none", since = "1.51.0")]
103-
impl private::Sealed for process::ExitStatus {}
95+
#[unstable(feature = "sealed", issue = "none")]
96+
impl Sealed for process::ExitStatus {}
10497

10598
/// Windows-specific extensions to the [`process::Command`] builder.
10699
#[stable(feature = "windows_process_extensions", since = "1.16.0")]

0 commit comments

Comments
 (0)