@@ -281,6 +281,11 @@ where
281
281
& self . alloc
282
282
}
283
283
284
+ #[ inline]
285
+ const fn assert_alignment ( ) {
286
+ assert ! ( mem:: size_of:: <T >( ) % mem:: align_of:: <T >( ) == 0 ) ;
287
+ }
288
+
284
289
fn current_memory ( & self ) -> Option < ( NonNull < u8 > , Layout ) > {
285
290
if T :: IS_ZST || self . cap == 0 {
286
291
None
@@ -289,7 +294,8 @@ where
289
294
// and could hypothetically handle differences between stride and size, but this memory
290
295
// has already been allocated so we know it can't overflow and currently rust does not
291
296
// support such types. So we can do better by skipping some checks and avoid an unwrap.
292
- let _: ( ) = const { assert ! ( mem:: size_of:: <T >( ) % mem:: align_of:: <T >( ) == 0 ) } ;
297
+ let _: ( ) = Self :: assert_alignment ( ) ;
298
+ //let _: () = const { assert!(mem::size_of::<T>() % mem::align_of::<T>() == 0) };
293
299
unsafe {
294
300
let align = mem:: align_of :: < T > ( ) ;
295
301
let size = mem:: size_of :: < T > ( ) . unchecked_mul ( self . cap ) ;
@@ -483,7 +489,8 @@ where
483
489
484
490
let ( ptr, layout) = if let Some ( mem) = self . current_memory ( ) { mem } else { return Ok ( ( ) ) } ;
485
491
// See current_memory() why this assert is here
486
- let _: ( ) = const { assert ! ( mem:: size_of:: <T >( ) % mem:: align_of:: <T >( ) == 0 ) } ;
492
+ let _: ( ) = Self :: assert_alignment ( ) ;
493
+ //let _: () = const { assert!(mem::size_of::<T>() % mem::align_of::<T>() == 0) };
487
494
let ptr = unsafe {
488
495
// `Layout::array` cannot overflow here because it would have
489
496
// overflowed earlier when capacity was larger.
0 commit comments