diff --git a/library/core/src/num/nonzero.rs b/library/core/src/num/nonzero.rs
index 715c3a0b8ac..7d60686597a 100644
--- a/library/core/src/num/nonzero.rs
+++ b/library/core/src/num/nonzero.rs
@@ -85,193 +85,450 @@ macro_rules! impl_nonzero_fmt {
}
}
-macro_rules! nonzero_integers {
- ( $( #[$stability: meta] #[$const_new_unchecked_stability: meta] $Ty: ident($Int: ty); )+ ) => {
- $(
- /// An integer that is known not to equal zero.
+macro_rules! nonzero_integer {
+ (
+ #[$stability:meta]
+ #[$const_new_unchecked_stability:meta]
+ Self = $Ty:ident,
+ Primitive = $signedness:ident $Int:ident,
+ $(UnsignedNonZero = $UnsignedNonZero:ident,)?
+ UnsignedPrimitive = $UnsignedPrimitive:ty,
+
+ // Used in doc comments.
+ leading_zeros_test = $leading_zeros_test:expr,
+ ) => {
+ /// An integer that is known not to equal zero.
+ ///
+ /// This enables some memory layout optimization.
+ #[doc = concat!("For example, `Option<", stringify!($Ty), ">` is the same size as `", stringify!($Int), "`:")]
+ ///
+ /// ```rust
+ /// use std::mem::size_of;
+ #[doc = concat!("assert_eq!(size_of::