diff options
| author | Jubilee Young <workingjubilee@gmail.com> | 2025-02-18 13:40:58 -0800 |
|---|---|---|
| committer | Jubilee Young <workingjubilee@gmail.com> | 2025-02-20 19:55:29 -0800 |
| commit | efff15afeabedacc2798d214dac404061df1555d (patch) | |
| tree | 673c577e1a9a0fd22e930f3826e6651fe789c0b5 /compiler/rustc_abi/src/lib.rs | |
| parent | a18bd8acfc32dbfbbe150cd52eecf24e67fb69b6 (diff) | |
| download | rust-efff15afeabedacc2798d214dac404061df1555d.tar.gz rust-efff15afeabedacc2798d214dac404061df1555d.zip | |
compiler: Align::max_for_offset -> Align::max_aligned_factor
No functional changes.
Diffstat (limited to 'compiler/rustc_abi/src/lib.rs')
| -rw-r--r-- | compiler/rustc_abi/src/lib.rs | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/compiler/rustc_abi/src/lib.rs b/compiler/rustc_abi/src/lib.rs index 098638b6bcf..761df0ba1ce 100644 --- a/compiler/rustc_abi/src/lib.rs +++ b/compiler/rustc_abi/src/lib.rs @@ -810,20 +810,19 @@ impl Align { self.bits().try_into().unwrap() } - /// Computes the best alignment possible for the given offset - /// (the largest power of two that the offset is a multiple of). + /// Obtain the greatest factor of `size` that is an alignment + /// (the largest power of two the Size is a multiple of). /// - /// N.B., for an offset of `0`, this happens to return `2^64`. + /// Note that all numbers are factors of 0 #[inline] - pub fn max_for_offset(offset: Size) -> Align { - Align { pow2: offset.bytes().trailing_zeros() as u8 } + pub fn max_aligned_factor(size: Size) -> Align { + Align { pow2: size.bytes().trailing_zeros() as u8 } } - /// Lower the alignment, if necessary, such that the given offset - /// is aligned to it (the offset is a multiple of the alignment). + /// Reduces Align to an aligned factor of `size`. #[inline] - pub fn restrict_for_offset(self, offset: Size) -> Align { - self.min(Align::max_for_offset(offset)) + pub fn restrict_for_offset(self, size: Size) -> Align { + self.min(Align::max_aligned_factor(size)) } } |
