From e3aba17ef1e070dd55a8d0f73cc53fa6480fddca Mon Sep 17 00:00:00 2001 From: Josh Triplett Date: Tue, 24 Mar 2026 20:23:48 -0700 Subject: [PATCH] Add a `sealed::Sealed` trait to `core`, like that in `std` This allows traits in `core` to be sealed as well. This could be the same trait as `std` via a re-export, but that would require `core::sealed` to be `pub` (even if unstable). Keep them as separate traits for now. --- library/core/src/lib.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/library/core/src/lib.rs b/library/core/src/lib.rs index 35f93d8fb33b..e0750f078445 100644 --- a/library/core/src/lib.rs +++ b/library/core/src/lib.rs @@ -110,6 +110,7 @@ #![feature(offset_of_enum)] #![feature(panic_internals)] #![feature(pattern_type_macro)] +#![feature(sealed)] #![feature(ub_checks)] // tidy-alphabetical-end // @@ -216,6 +217,14 @@ pub mod from { pub use crate::macros::builtin::From; } +mod sealed { + /// This trait being unreachable from outside the crate + /// prevents outside implementations of our extension traits. + /// This allows adding more trait methods in the future. + #[unstable(feature = "sealed", issue = "none")] + pub trait Sealed {} +} + // We don't export this through #[macro_export] for now, to avoid breakage. #[unstable(feature = "autodiff", issue = "124509")] /// Unstable module containing the unstable `autodiff` macro.