rustc has stopped emitting unused `repr`/`link`/`panic_handler` attribute lints on macro invocations
Open
@JonathanBrouwer is already working on this.
Since May 12, 2026.
A-attributes
C-bug
P-high
regression-from-stable-to-stable
T-compiler
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
Code
I tried this code:
macro_rules! produce_struct {
($name: ident) => {
pub struct $name {}
};
}
#[repr(align(64))]
produce_struct!(Foo);
const _: () = assert!(align_of::<Foo>() == 1);
I expected to see this happen: program accepted, with warnings
warning: unused attribute `repr`
--> <source>:7:1
|
7 | #[repr(align(64))]
| ^^^^^^^^^^^^^^^^^^
|
= note: -Ztrack-diagnostics: created at /rustc-dev/1159e78c4747b02ef996e55082b704c09b970588/compiler/rustc_lint/src/early.rs:40:26
note: the built-in attribute `repr` will be ignored, since it's applied to the macro invocation `produce_struct`
--> <source>:8:1
|
8 | produce_struct!(Foo);
| ^^^^^^^^^^^^^^
= note: `#[warn(unused_attributes)]` on by default
Instead, this happened: program accepted, no warnings issued
Version it worked on
It most recently worked on: rust 1.90 and earlier: https://rust.godbolt.org/z/Wzf519Wbv
Version with regression
1.91 and up, including current beta and nightly
The following attributes are also affected, this compiles without warnings (save for incomplete_features).
#![allow(incomplete_features)]
#![feature(dropck_eyepatch)]
#![feature(export_stable)]
#![feature(register_tool)]
#![feature(sanitize)]
macro_rules! produce_struct {
($name: ident) => {
pub struct $name {}
};
}
#[repr(align(64))]
#[sanitize(address = "off")]
#[register_tool(blah)]
#[link(name = "foo")]
#[export_stable]
#[panic_handler]
#[may_dangle]
produce_struct!(Foo);
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.