@@ -218,9 +218,8 @@ fn bucket_mask_to_capacity(bucket_mask: usize) -> usize {
218218fn calculate_layout < T > ( buckets : usize ) -> Option < ( Layout , usize ) > {
219219 debug_assert ! ( buckets. is_power_of_two( ) ) ;
220220
221- let common_align = usize:: max ( mem:: align_of :: < T > ( ) , Group :: WIDTH ) ;
222221 // Array of buckets
223- let padded_data = Layout :: array :: < T > ( buckets) . ok ( ) ?. align_to ( common_align ) . ok ( ) ? . pad_to_align ( ) ;
222+ let data = Layout :: array :: < T > ( buckets) . ok ( ) ?;
224223
225224 // Array of control bytes. This must be aligned to the group size.
226225 //
@@ -235,7 +234,7 @@ fn calculate_layout<T>(buckets: usize) -> Option<(Layout, usize)> {
235234 // There must be no padding between two tables.
236235 debug_assert_eq ! ( padded_data. padding_needed_for( Group :: WIDTH ) , 0 ) ;
237236
238- padded_data . extend ( ctrl) . ok ( )
237+ data . extend ( ctrl) . ok ( )
239238}
240239
241240/// Returns a Layout which describes the allocation required for a hash table,
@@ -266,6 +265,9 @@ fn calculate_layout<T>(buckets: usize) -> Option<(Layout, usize)> {
266265/// is a ZST, then we instead track the index of the element in the table so
267266/// that `erase` works properly.
268267pub struct Bucket < T > {
268+ // Actually it is pointer to next element than element itself
269+ // this is needed to maintain pointer arithmetic invariants
270+ // keeping direct pointer to element introduces difficulty.
269271 // Using `NonNull` for variance and niche layout
270272 ptr : NonNull < T > ,
271273}
0 commit comments