@@ -281,6 +281,11 @@ where
281281 & self . alloc
282282 }
283283
284+ #[ inline]
285+ const fn assert_alignment ( ) {
286+ assert ! ( mem:: size_of:: <T >( ) % mem:: align_of:: <T >( ) == 0 ) ;
287+ }
288+
284289 fn current_memory ( & self ) -> Option < ( NonNull < u8 > , Layout ) > {
285290 if T :: IS_ZST || self . cap == 0 {
286291 None
@@ -289,7 +294,8 @@ where
289294 // and could hypothetically handle differences between stride and size, but this memory
290295 // has already been allocated so we know it can't overflow and currently rust does not
291296 // 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) };
293299 unsafe {
294300 let align = mem:: align_of :: < T > ( ) ;
295301 let size = mem:: size_of :: < T > ( ) . unchecked_mul ( self . cap ) ;
@@ -483,7 +489,8 @@ where
483489
484490 let ( ptr, layout) = if let Some ( mem) = self . current_memory ( ) { mem } else { return Ok ( ( ) ) } ;
485491 // 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) };
487494 let ptr = unsafe {
488495 // `Layout::array` cannot overflow here because it would have
489496 // overflowed earlier when capacity was larger.
0 commit comments