From b142720322155ddb5aa4cac8b01ab5633b4cc854 Mon Sep 17 00:00:00 2001 From: Joshua Liebow-Feeser Date: Wed, 9 Mar 2022 13:53:16 -0800 Subject: [PATCH 1/5] Document NonZeroXxx layout guarantees Document that `NonZeroXxx` has the same layout and bit validity as `Xxx` with the exception of `0`. --- library/core/src/num/nonzero.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/library/core/src/num/nonzero.rs b/library/core/src/num/nonzero.rs index 1ebd1c58f2b..8b247daf8a7 100644 --- a/library/core/src/num/nonzero.rs +++ b/library/core/src/num/nonzero.rs @@ -34,6 +34,11 @@ macro_rules! nonzero_integers { /// use std::mem::size_of; #[doc = concat!("assert_eq!(size_of::>(), size_of::<", stringify!($Int), ">());")] /// ``` + /// + /// # Layout + /// + #[doc = concat!("`", stringify!($Ty), "` is guaranteed to have the same layout and bit validity as `", stringify!($Int), "`"] + /// with the exception that `0` is not a valid instance. #[$stability] #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)] #[repr(transparent)] From 7f88cd20ff5d3616b7bab5a4b3b0c942e91904a9 Mon Sep 17 00:00:00 2001 From: Joshua Liebow-Feeser Date: Wed, 9 Mar 2022 14:00:08 -0800 Subject: [PATCH 2/5] Add missing closing parenthesis --- library/core/src/num/nonzero.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/core/src/num/nonzero.rs b/library/core/src/num/nonzero.rs index 8b247daf8a7..1e5cfdd56ca 100644 --- a/library/core/src/num/nonzero.rs +++ b/library/core/src/num/nonzero.rs @@ -37,7 +37,7 @@ macro_rules! nonzero_integers { /// /// # Layout /// - #[doc = concat!("`", stringify!($Ty), "` is guaranteed to have the same layout and bit validity as `", stringify!($Int), "`"] + #[doc = concat!("`", stringify!($Ty), "` is guaranteed to have the same layout and bit validity as `", stringify!($Int), "`")] /// with the exception that `0` is not a valid instance. #[$stability] #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)] From 7d4e9b3637320be8d4f2efe350cd71b9312e9d83 Mon Sep 17 00:00:00 2001 From: Joshua Liebow-Feeser Date: Wed, 5 Oct 2022 09:40:50 -0700 Subject: [PATCH 3/5] Update library/core/src/num/nonzero.rs Co-authored-by: Josh Triplett --- library/core/src/num/nonzero.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/library/core/src/num/nonzero.rs b/library/core/src/num/nonzero.rs index 1e5cfdd56ca..df438f88cee 100644 --- a/library/core/src/num/nonzero.rs +++ b/library/core/src/num/nonzero.rs @@ -39,6 +39,8 @@ macro_rules! nonzero_integers { /// #[doc = concat!("`", stringify!($Ty), "` is guaranteed to have the same layout and bit validity as `", stringify!($Int), "`")] /// with the exception that `0` is not a valid instance. + #[doc = concat!("`Option<", stringify!($Ty), "` is guaranteed to be compatible with `", stringify!($Int), "`," + /// including in FFI. #[$stability] #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)] #[repr(transparent)] From 8323d6abfca91c73217adf13d6313dbad7adfd69 Mon Sep 17 00:00:00 2001 From: Joshua Liebow-Feeser Date: Wed, 5 Oct 2022 09:41:57 -0700 Subject: [PATCH 4/5] Fix typo (missing `>`) --- library/core/src/num/nonzero.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/core/src/num/nonzero.rs b/library/core/src/num/nonzero.rs index df438f88cee..c45eb66b0e9 100644 --- a/library/core/src/num/nonzero.rs +++ b/library/core/src/num/nonzero.rs @@ -39,7 +39,7 @@ macro_rules! nonzero_integers { /// #[doc = concat!("`", stringify!($Ty), "` is guaranteed to have the same layout and bit validity as `", stringify!($Int), "`")] /// with the exception that `0` is not a valid instance. - #[doc = concat!("`Option<", stringify!($Ty), "` is guaranteed to be compatible with `", stringify!($Int), "`," + #[doc = concat!("`Option<", stringify!($Ty), ">` is guaranteed to be compatible with `", stringify!($Int), "`," /// including in FFI. #[$stability] #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)] From 9a3346bcdd23d299f9b45236cfda7d4de0ea640a Mon Sep 17 00:00:00 2001 From: Joshua Liebow-Feeser Date: Wed, 5 Oct 2022 10:07:26 -0700 Subject: [PATCH 5/5] Add missing trailing `)]` --- library/core/src/num/nonzero.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/core/src/num/nonzero.rs b/library/core/src/num/nonzero.rs index c45eb66b0e9..e011a0945e2 100644 --- a/library/core/src/num/nonzero.rs +++ b/library/core/src/num/nonzero.rs @@ -39,7 +39,7 @@ macro_rules! nonzero_integers { /// #[doc = concat!("`", stringify!($Ty), "` is guaranteed to have the same layout and bit validity as `", stringify!($Int), "`")] /// with the exception that `0` is not a valid instance. - #[doc = concat!("`Option<", stringify!($Ty), ">` is guaranteed to be compatible with `", stringify!($Int), "`," + #[doc = concat!("`Option<", stringify!($Ty), ">` is guaranteed to be compatible with `", stringify!($Int), "`,")] /// including in FFI. #[$stability] #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]