File tree Expand file tree Collapse file tree 1 file changed +2
-8
lines changed Expand file tree Collapse file tree 1 file changed +2
-8
lines changed Original file line number Diff line number Diff line change @@ -170,6 +170,7 @@ unsafe impl CheckedBitPattern for bool {
170170 }
171171}
172172
173+ // Rust 1.70.0 documents that NonZero[int] has the same layout as [int].
173174macro_rules! impl_checked_for_nonzero {
174175 ( $( $nonzero: ty: $primitive: ty) ,* $( , ) ?) => {
175176 $(
@@ -178,14 +179,7 @@ macro_rules! impl_checked_for_nonzero {
178179
179180 #[ inline]
180181 fn is_valid_bit_pattern( bits: & Self :: Bits ) -> bool {
181- // Note(zachs18): The size and alignment check are almost certainly
182- // not necessary, but Rust currently doesn't explicitly document that
183- // NonZero[int] has the same layout as [int], so we check it to be safe.
184- // In a const to reduce debug-profile overhead.
185- const LAYOUT_SAME : bool =
186- core:: mem:: size_of:: <$nonzero>( ) == core:: mem:: size_of:: <$primitive>( )
187- && core:: mem:: align_of:: <$nonzero>( ) == core:: mem:: align_of:: <$primitive>( ) ;
188- LAYOUT_SAME && * bits != 0
182+ * bits != 0
189183 }
190184 }
191185 ) *
You can’t perform that action at this time.
0 commit comments