From b197ed8283cb02ed1d1e81525f234362bc852149 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`. --- core/src/num/nonzero.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/core/src/num/nonzero.rs b/core/src/num/nonzero.rs index 1ebd1c58f..8b247daf8 100644 --- a/core/src/num/nonzero.rs +++ b/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 a92a80d7269b8c7865308588d2db4fa8f1456ecd 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 --- core/src/num/nonzero.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/num/nonzero.rs b/core/src/num/nonzero.rs index 8b247daf8..1e5cfdd56 100644 --- a/core/src/num/nonzero.rs +++ b/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 55b4bff4772db59a1f44fd105f5f308e1663db21 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 --- core/src/num/nonzero.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core/src/num/nonzero.rs b/core/src/num/nonzero.rs index 1e5cfdd56..df438f88c 100644 --- a/core/src/num/nonzero.rs +++ b/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 8b92dd0aa50c65fe98d687532ceb6a61f51d2b80 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 `>`) --- core/src/num/nonzero.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/num/nonzero.rs b/core/src/num/nonzero.rs index df438f88c..c45eb66b0 100644 --- a/core/src/num/nonzero.rs +++ b/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 832f84923a6d9f437e3d48e4522a9b1370e309ce 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 `)]` --- core/src/num/nonzero.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/num/nonzero.rs b/core/src/num/nonzero.rs index c45eb66b0..e011a0945 100644 --- a/core/src/num/nonzero.rs +++ b/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)]