`repr(align(N))` not respected for uninhabited enum
Open
Nobody has claimed this yet.
A-align
A-enum
A-layout
A-repr
C-bug
T-compiler
T-lang
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
I tried this code:
enum Never {}
#[repr(align(4))]
enum Thing { Variant(Never) }
fn main() {
assert_eq!(1, align_of::<Thing>());
}
I expected the alignment of Thing to be 4, as per the repr attribute, so the assertion should fail. Instead, the program runs without errors.
Meta
Reproducible on the playground with version 1.93.0-nightly (2025-11-22 94b49fd998d6723e0a92)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the provided Rust playground reproduction with the reported nightly version and confirm the alignment reported for Thing. Trace how repr(align(N)) is applied to the uninhabited enum, then add regression coverage for this example. Done means the assertion observes alignment 4 and the relevant compiler tests pass.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100