reference icon indicating copy to clipboard operation
reference copied to clipboard

docs: add comprehensive documentation for borrowing from repr(packed)…

Open hns1971 opened this issue 3 months ago • 0 comments

Document borrowing rules for repr(packed) fields (E0793).

This documents the behavior implemented in rust-lang/rust#145419:

  • Disallow borrowing when the target’s ABI alignment exceeds the packed alignment (hard error E0793).
  • Allow borrowing when ABI alignment is ≤ the packed alignment.
  • For [T; N]/[T], alignment equals that of T, independent of N.

Includes examples for the allowed [u8; N] case and the disallowed [u16; N] case.

hns1971 avatar Aug 27 '25 03:08 hns1971