@@ -1615,13 +1615,6 @@ impl_zeroable! {
16151615 // SAFETY: `T: Zeroable` and `UnsafeCell` is `repr(transparent)`.
16161616 { <T : ?Sized + Zeroable >} UnsafeCell <T >,
16171617
1618- // SAFETY: All zeros is equivalent to `None` (option layout optimization guarantee:
1619- // <https://doc.rust-lang.org/stable/std/option/index.html#representation>).
1620- Option <NonZeroU8 >, Option <NonZeroU16 >, Option <NonZeroU32 >, Option <NonZeroU64 >,
1621- Option <NonZeroU128 >, Option <NonZeroUsize >,
1622- Option <NonZeroI8 >, Option <NonZeroI16 >, Option <NonZeroI32 >, Option <NonZeroI64 >,
1623- Option <NonZeroI128 >, Option <NonZeroIsize >,
1624-
16251618 // SAFETY: `null` pointer is valid.
16261619 //
16271620 // We cannot use `T: ?Sized`, since the VTABLE pointer part of fat pointers is not allowed to be
@@ -1681,6 +1674,20 @@ macro_rules! impl_fn_zeroable_option {
16811674
16821675impl_fn_zeroable_option ! ( [ "Rust" , "C" ] { A , B , C , D , E , F , G , H , I , J , K , L , M , N , O , P , Q , R , S , T , U } ) ;
16831676
1677+ macro_rules! impl_non_zero_int_zeroable_option {
1678+ ( $( $int: ty) ,* $( , ) ?) => {
1679+ // SAFETY: Safety comment written in the macro invocation.
1680+ $( unsafe impl ZeroableOption for $int { } ) *
1681+ } ;
1682+ }
1683+
1684+ impl_non_zero_int_zeroable_option ! {
1685+ // SAFETY: All zeros is equivalent to `None` (option layout optimization guarantee:
1686+ // <https://doc.rust-lang.org/stable/std/option/index.html#representation>).
1687+ NonZeroU8 , NonZeroU16 , NonZeroU32 , NonZeroU64 , NonZeroU128 , NonZeroUsize ,
1688+ NonZeroI8 , NonZeroI16 , NonZeroI32 , NonZeroI64 , NonZeroI128 , NonZeroIsize ,
1689+ }
1690+
16841691/// This trait allows creating an instance of `Self` which contains exactly one
16851692/// [structurally pinned value](https://doc.rust-lang.org/std/pin/index.html#projections-and-structural-pinning).
16861693///
0 commit comments