reference
reference copied to clipboard
Attribute macros must be placed before `derive` attributes.
I can't find this anywhere in the reference.
#[derive(Debug)]
#[my_awesome_macro] // This is an error.
struct S;
Currently unstable, see: https://github.com/rust-lang/rust/issues/81119
This is a future-proofing kind of an error.
The current implementation does not expand all the attributes in left-to-right fashion and if we put #[my_awesome_macro] after a derive it will still be expanded before the derive, so such attributes are simply prohibited to avoid the issue.
When the implementation is fixed the restriction could be lifted.
cc https://github.com/rust-lang/rust/pull/54277
Any updates on this restriction?
The restriction is going to be removed in https://github.com/rust-lang/rust/pull/79078.
Can be closed now?
Yes, I believe this can be closed, thanks!