Skip to content

Better template for #[repr] attributes #142495

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

Merged
merged 1 commit into from
Jun 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion compiler/rustc_attr_parsing/src/attributes/repr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ impl<S: Stage> CombineAttributeParser<S> for ReprParser {
const PATH: &[Symbol] = &[sym::repr];
const CONVERT: ConvertFn<Self::Item> = AttributeKind::Repr;
// FIXME(jdonszelmann): never used
const TEMPLATE: AttributeTemplate = template!(List: "C");
const TEMPLATE: AttributeTemplate =
template!(List: "C | Rust | align(...) | packed(...) | <integer type> | transparent");

fn extend<'c>(
cx: &'c mut AcceptContext<'_, '_, S>,
Expand Down
4 changes: 2 additions & 2 deletions tests/ui/issues/issue-43988.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ LL | #[repr]
| ^^^^^^^
| |
| expected this to be a list
| help: must be of the form: `#[repr(C)]`
| help: must be of the form: `#[repr(C | Rust | align(...) | packed(...) | <integer type> | transparent)]`

error[E0539]: malformed `inline` attribute input
--> $DIR/issue-43988.rs:30:5
Expand All @@ -64,7 +64,7 @@ LL | let _z = #[repr] 1;
| ^^^^^^^
| |
| expected this to be a list
| help: must be of the form: `#[repr(C)]`
| help: must be of the form: `#[repr(C | Rust | align(...) | packed(...) | <integer type> | transparent)]`

error[E0518]: attribute should be applied to function or closure
--> $DIR/issue-43988.rs:5:5
Expand Down
6 changes: 3 additions & 3 deletions tests/ui/repr/repr.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ LL | #[repr]
| ^^^^^^^
| |
| expected this to be a list
| help: must be of the form: `#[repr(C)]`
| help: must be of the form: `#[repr(C | Rust | align(...) | packed(...) | <integer type> | transparent)]`

error[E0539]: malformed `repr` attribute input
--> $DIR/repr.rs:4:1
Expand All @@ -14,7 +14,7 @@ LL | #[repr = "B"]
| ^^^^^^^^^^^^^
| |
| expected this to be a list
| help: must be of the form: `#[repr(C)]`
| help: must be of the form: `#[repr(C | Rust | align(...) | packed(...) | <integer type> | transparent)]`

error[E0539]: malformed `repr` attribute input
--> $DIR/repr.rs:7:1
Expand All @@ -23,7 +23,7 @@ LL | #[repr = "C"]
| ^^^^^^^^^^^^^
| |
| expected this to be a list
| help: must be of the form: `#[repr(C)]`
| help: must be of the form: `#[repr(C | Rust | align(...) | packed(...) | <integer type> | transparent)]`

error: aborting due to 3 previous errors

Expand Down
Loading