diff options
| author | Markus Reiter <me@reitermark.us> | 2024-03-01 13:39:24 +0100 |
|---|---|---|
| committer | Markus Reiter <me@reitermark.us> | 2024-03-01 13:49:37 +0100 |
| commit | f6d2607163bb043c772b0dc502b89048e204aaa6 (patch) | |
| tree | 4de298941cf58aae3b4c809a36de1980701e661e | |
| parent | 6cbf0926d54c80ea6d15df333be9281f65bbeb36 (diff) | |
| download | rust-f6d2607163bb043c772b0dc502b89048e204aaa6.tar.gz rust-f6d2607163bb043c772b0dc502b89048e204aaa6.zip | |
Make `ZeroablePrimitive` trait unsafe.
| -rw-r--r-- | library/core/src/num/nonzero.rs | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/library/core/src/num/nonzero.rs b/library/core/src/num/nonzero.rs index 295b88361cf..9e34c0d240d 100644 --- a/library/core/src/num/nonzero.rs +++ b/library/core/src/num/nonzero.rs @@ -24,13 +24,17 @@ mod private { /// A marker trait for primitive types which can be zero. /// /// This is an implementation detail for <code>[NonZero]\<T></code> which may disappear or be replaced at any time. +/// +/// # Safety +/// +/// Types implementing this trait must be primitves that are valid when zeroed. #[unstable( feature = "nonzero_internals", reason = "implementation detail which may disappear or be replaced at any time", issue = "none" )] #[const_trait] -pub trait ZeroablePrimitive: Sized + Copy + private::Sealed {} +pub unsafe trait ZeroablePrimitive: Sized + Copy + private::Sealed {} macro_rules! impl_zeroable_primitive { ($primitive:ty) => { @@ -46,7 +50,7 @@ macro_rules! impl_zeroable_primitive { reason = "implementation detail which may disappear or be replaced at any time", issue = "none" )] - impl const ZeroablePrimitive for $primitive {} + unsafe impl const ZeroablePrimitive for $primitive {} }; } |
