Skip to content

Commit 7012194

Browse files
committed
ExitStatusExt unix: Retrospectively seal this trait
As discussed in #79982. I think the "new interfaces", ie the new trait and impl, must be insta-stable. This seems OK because we are, in fact, adding a new restriction to the stable API. Signed-off-by: Ian Jackson <[email protected]>
1 parent fa68567 commit 7012194

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

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

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@ use crate::process;
99
use crate::sys;
1010
use crate::sys_common::{AsInner, AsInnerMut, FromInner, IntoInner};
1111

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+
1220
/// Unix-specific extensions to the [`process::Command`] builder.
1321
#[stable(feature = "rust1", since = "1.0.0")]
1422
pub trait CommandExt {
@@ -163,8 +171,11 @@ impl CommandExt for process::Command {
163171
}
164172

165173
/// Unix-specific extensions to [`process::ExitStatus`].
174+
///
175+
/// This trait is saeled (since Rust 1.51): it cannot be implemented outside the standard library.
176+
/// This is so that future additional methods are not breaking changes.
166177
#[stable(feature = "rust1", since = "1.0.0")]
167-
pub trait ExitStatusExt {
178+
pub trait ExitStatusExt: private::Sealed {
168179
/// Creates a new `ExitStatus` from the raw underlying `i32` return value of
169180
/// a process.
170181
#[stable(feature = "exit_status_from", since = "1.12.0")]
@@ -199,6 +210,9 @@ pub trait ExitStatusExt {
199210
fn into_raw(self) -> i32;
200211
}
201212

213+
#[stable(feature = "none", since = "1.51.0")]
214+
impl private::Sealed for process::ExitStatus {}
215+
202216
#[stable(feature = "rust1", since = "1.0.0")]
203217
impl ExitStatusExt for process::ExitStatus {
204218
fn from_raw(raw: i32) -> Self {

0 commit comments

Comments
 (0)