Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#[repr(align="")] has terrible diagnostics #50314

Closed
nagisa opened this issue Apr 29, 2018 · 0 comments
Closed

#[repr(align="")] has terrible diagnostics #50314

nagisa opened this issue Apr 29, 2018 · 0 comments
Labels
A-diagnostics Area: Messages for errors, warnings, and lints

Comments

@nagisa
Copy link
Member

nagisa commented Apr 29, 2018

The attribute was fairly recently stabilised in form of #[repr(align(x))] however the RFC and some searches still refer to the attribute as #[repr(align="x")], in which case the compiler emits the following error:

error[E0552]: unrecognized representation hint
   --> libcore/../libcore/tests/slice.rs:574:12
    |
574 |     #[repr(align=8)] struct U64(u64, u64);
    |            ^^^^^^^

We should detect this case and inform users of the correct way to specify the alignment.

cc #33626

@nagisa nagisa added the A-diagnostics Area: Messages for errors, warnings, and lints label Apr 29, 2018
bors added a commit that referenced this issue Apr 29, 2018
Improve error message for #[repr(align=x)]

Before:
```
error[E0552]: unrecognized representation hint
 --> src/main.rs:1:8
  |
1 | #[repr(align="8")]
  |        ^^^^^^^^^
```
After:
```
error[E0693]: incorrect `repr(align)` attribute format
 --> src/main.rs:1:8
  |
2 | #[repr(align="8")]
  |        ^^^^^^^^^ help: use parentheses instead: `align(8)`
```

Fixes #50314.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints
Projects
None yet
Development

No branches or pull requests

1 participant