File tree 2 files changed +9
-10
lines changed
2 files changed +9
-10
lines changed Original file line number Diff line number Diff line change @@ -810,20 +810,19 @@ impl Align {
810
810
self . bits ( ) . try_into ( ) . unwrap ( )
811
811
}
812
812
813
- /// Computes the best alignment possible for the given offset
814
- /// (the largest power of two that the offset is a multiple of).
813
+ /// Obtain the greatest factor of `size` that is an alignment
814
+ /// (the largest power of two the Size is a multiple of).
815
815
///
816
- /// N.B., for an offset of `0`, this happens to return `2^64`.
816
+ /// Note that all numbers are factors of 0
817
817
#[ inline]
818
- pub fn max_for_offset ( offset : Size ) -> Align {
819
- Align { pow2 : offset . bytes ( ) . trailing_zeros ( ) as u8 }
818
+ pub fn max_aligned_factor ( size : Size ) -> Align {
819
+ Align { pow2 : size . bytes ( ) . trailing_zeros ( ) as u8 }
820
820
}
821
821
822
- /// Lower the alignment, if necessary, such that the given offset
823
- /// is aligned to it (the offset is a multiple of the alignment).
822
+ /// Reduces Align to an aligned factor of `size`.
824
823
#[ inline]
825
- pub fn restrict_for_offset ( self , offset : Size ) -> Align {
826
- self . min ( Align :: max_for_offset ( offset ) )
824
+ pub fn restrict_for_offset ( self , size : Size ) -> Align {
825
+ self . min ( Align :: max_aligned_factor ( size ) )
827
826
}
828
827
}
829
828
Original file line number Diff line number Diff line change @@ -534,7 +534,7 @@ fn layout_of_uncached<'tcx>(
534
534
(
535
535
BackendRepr :: Memory { sized : true } ,
536
536
AbiAndPrefAlign {
537
- abi : Align :: max_for_offset ( size) ,
537
+ abi : Align :: max_aligned_factor ( size) ,
538
538
pref : dl. vector_align ( size) . pref ,
539
539
} ,
540
540
)
You can’t perform that action at this time.
0 commit comments