]> git.lizzy.rs Git - rust.git/commit - src/tools/rust-analyzer
Rollup merge of #95361 - scottmcm:valid-align, r=Mark-Simulacrum
authorDylan DPC <99973273+Dylan-DPC@users.noreply.github.com>
Sat, 9 Apr 2022 16:26:25 +0000 (18:26 +0200)
committerGitHub <noreply@github.com>
Sat, 9 Apr 2022 16:26:25 +0000 (18:26 +0200)
commite4b4bf1535ab3539c4573c8d960214c6e49eb138
tree4d1f4e3804268b1973d078805dc4f6537473cc99
parent1ced0b61a43d67ef209fc2fa8c4da783daa2471e
parentfe0c08a4f24ff7e6fb03b61656436bfa5ff29ac7
Rollup merge of #95361 - scottmcm:valid-align, r=Mark-Simulacrum

Make non-power-of-two alignments a validity error in `Layout`

Inspired by the zulip conversation about how `Layout` should better enforce `size <= isize::MAX as usize`, this uses an N-variant enum on N-bit platforms to require at the validity level that the existing invariant of "must be a power of two" is upheld.

This was MIRI can catch it, and means there's a more-specific type for `Layout` to store than just `NonZeroUsize`.

It's left as `pub(crate)` here; a future PR could consider giving it a tracking issue for non-internal usage.
library/core/src/alloc/layout.rs
library/core/src/mem/mod.rs