Skip to content

Fix slice align_to maximality contracts for general layouts - #816

Open
fromtaoyuanhsinchuuuu wants to merge 1 commit into
model-checking:mainfrom
fromtaoyuanhsinchuuuu:codex/align-to-maximality
Open

fromtaoyuanhsinchuuuu wants to merge 1 commit into
model-checking:mainfrom
fromtaoyuanhsinchuuuu:codex/align-to-maximality

Conversation

@fromtaoyuanhsinchuuuu

@fromtaoyuanhsinchuuuu fromtaoyuanhsinchuuuu commented Dec 2, 2026 •

Copy link
Copy Markdown

Express maximality in whole source elements for both align_to and align_to_mut. Use the alignment period to bound the prefix and the smallest group of source elements that can supply whole destination elements to bound the suffix. Require an unsplit result when either type is zero-sized or no source element boundary can meet the destination alignment.

The GCD-based bounds follow the analysis by @c-grellois in #799.

Validation

  • Kani verified all 134 slice::verify::align_to* harnesses. The six new harnesses, also rerun after formatting, exercise non-divisible element sizes and both reachable and unreachable alignment with [u8; 2] and u16.
  • Checked both alignment-coverage conditions for each of the two [u8; 2] harnesses.
  • cargo check --manifest-path library/Cargo.toml -p core and the targeted Rust formatting check passed.

Resolves #799

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 and MIT licenses.

@fromtaoyuanhsinchuuuu
fromtaoyuanhsinchuuuu requested a review from a team as a code owner December 2, 2026 20:08

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

<[T]>::align_to{,_mut}: first #[ensures] (middle maximality) is false for some valid element types, e.g. [u8; 3] -> u16, u32 -> [u16; 3]

1 participant