Emit error for attrs with empty lists instead of just warning they are unused
Open
@jdonszelmann is already working on this.
Since Sep 17, 2025.
A-diagnostics
T-compiler
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
I don't know if the warning rather than the hard error was intentional before. Maybe for cases using macros? idk.
But I think we should tell users what is expected for attrs user used, instead of just warning it is unused.
Code
#[repr()]
pub struct T;
Current output
warning: unused attribute
--> src/lib.rs:1:1
|
1 | #[repr()]
| ^^^^^^^^^ help: remove this attribute
|
= note: `#[warn(unused_attributes)]` (part of `#[warn(unused)]`) on by default
Desired output
like use #[repr] without list:
#[repr]
pub struct T;
output
error[E0539]: malformed `repr` attribute input
--> src/lib.rs:1:1
|
1 | #[repr]
| ^^^^^^^ expected this to be a list
|
= note: for more information, visit <https://doc.rust-lang.org/reference/type-layout.html#representations>
help: try changing it to one of the following valid forms of the attribute
|
1 | #[repr(<integer type>)]
| ++++++++++++++++
1 | #[repr(C)]
| +++
1 | #[repr(Rust)]
| ++++++
1 | #[repr(align(...))]
| ++++++++++++
= and 2 other candidates
Rationale and extra context
Maybe there are some previous discussions? But I didn't find it
Other cases
Also for other attrs expected list like allow
Rust Version
Build using the Nightly version: 1.92.0-nightly
(2025-09-16 a9d0a6f15533a364816c)
Anything else?
No response
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.
Assessment
This issue has not been assessed yet.