Rollup merge of #121850 - reitermarkus:generic-nonzero-unsafe-trait, r=Nilstrieb
Make `ZeroablePrimitive` trait unsafe. Tracking issue: https://github.com/rust-lang/rust/issues/120257 r? `@dtolnay`
This commit is contained in:
commit
68dd5e65a9
@ -24,13 +24,17 @@ pub trait Sealed {}
|
|||||||
/// A marker trait for primitive types which can be zero.
|
/// 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.
|
/// 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(
|
#[unstable(
|
||||||
feature = "nonzero_internals",
|
feature = "nonzero_internals",
|
||||||
reason = "implementation detail which may disappear or be replaced at any time",
|
reason = "implementation detail which may disappear or be replaced at any time",
|
||||||
issue = "none"
|
issue = "none"
|
||||||
)]
|
)]
|
||||||
#[const_trait]
|
#[const_trait]
|
||||||
pub trait ZeroablePrimitive: Sized + Copy + private::Sealed {}
|
pub unsafe trait ZeroablePrimitive: Sized + Copy + private::Sealed {}
|
||||||
|
|
||||||
macro_rules! impl_zeroable_primitive {
|
macro_rules! impl_zeroable_primitive {
|
||||||
($primitive:ty) => {
|
($primitive:ty) => {
|
||||||
@ -46,7 +50,7 @@ impl const private::Sealed for $primitive {}
|
|||||||
reason = "implementation detail which may disappear or be replaced at any time",
|
reason = "implementation detail which may disappear or be replaced at any time",
|
||||||
issue = "none"
|
issue = "none"
|
||||||
)]
|
)]
|
||||||
impl const ZeroablePrimitive for $primitive {}
|
unsafe impl const ZeroablePrimitive for $primitive {}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user