Skip to content

#[repr(align(8))] is not accepted for arrays #83595

Closed
@manuthambi

Description

@manuthambi

Code

struct Data {
    #[repr(align(8))]
    x: [usize; 20]
}

#[repr(align)] was accepted for arrays in rust v1.50, but is rejected in v1.51.

error[E0517]: attribute should be applied to a struct, enum, or union
 --> src/main.rs:3:12
  |
3 |     #[repr(align(8))]
  |            ^^^^^^^^
4 |     x: [usize; 20]
  |     -------------- not a struct, enum, or union

I am not entirely sure whether the attribute actually did the alignment in 1.50, or the compiler just ignored it. Regardless, is this expected behavior, and if it is how do I align an array?

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-attributesArea: Attributes (`#[…]`, `#![…]`)A-diagnosticsArea: Messages for errors, warnings, and lintsT-langRelevant to the language team, which will review and decide on the PR/issue.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions