Skip to content

Commit

Permalink
compiler: Precisely name units of object size
Browse files Browse the repository at this point in the history
Co-authored-by: Ralf Jung <post@ralfj.de>
  • Loading branch information
workingjubilee and RalfJung authored Sep 21, 2024
1 parent d93d2f1 commit cf78f26
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions compiler/rustc_abi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -337,15 +337,15 @@ impl TargetDataLayout {
Ok(dl)
}

/// Returns **exclusive** upper bound on object size.
/// Returns **exclusive** upper bound on object size in bytes.
///
/// The theoretical maximum object size is defined as the maximum positive `isize` value.
/// This ensures that the `offset` semantics remain well-defined by allowing it to correctly
/// index every address within an object along with one byte past the end, along with allowing
/// `isize` to store the difference between any two pointers into an object.
///
/// LLVM uses a 64-bit integer to represent object size in bits, but we care only for bytes,
/// so we adopt such a more-constrained address space due to its technical limitations.
/// LLVM uses a 64-bit integer to represent object size in *bits*, but we care only for bytes,
/// so we adopt such a more-constrained size bound due to its technical limitations.
#[inline]
pub fn obj_size_bound(&self) -> u64 {
match self.pointer_size.bits() {
Expand Down

0 comments on commit cf78f26

Please sign in to comment.