Skip to content

Tracking issue for #[repr(align(x))] on enums #57996

Closed
rust-lang/reference
#619
@niklasf

Description

@niklasf

RFC 1358 introduced #[repr(align(x))] on structs (and unions). It mentions:

Custom alignment can only be specified on struct declarations for now. Specifying a different alignment on perhaps enum or type definitions should be a backwards-compatible extension.

It would be a nice convenience to allow this for enums, especially when they are part of a public API.

#[repr(align(x))]
enum Foo {
    // ...
}

would be equivalent to using AlignX<Foo> everywhere:

#[repr(align(x))]
struct AlignX<T>(T);

enum Foo {
    // ...
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    B-unstableBlocker: Implemented in the nightly compiler and unstable.C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCT-langRelevant to the language team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions