reference icon indicating copy to clipboard operation
reference copied to clipboard

Attribute macros must be placed before `derive` attributes.

Open ehuss opened this issue 6 years ago • 3 comments

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

ehuss avatar Apr 21 '19 17:04 ehuss

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

petrochenkov avatar Apr 21 '19 17:04 petrochenkov

Any updates on this restriction?

saskenuba avatar Sep 24 '20 00:09 saskenuba

The restriction is going to be removed in https://github.com/rust-lang/rust/pull/79078.

petrochenkov avatar Nov 15 '20 19:11 petrochenkov

Can be closed now?

vlad20012 avatar Jan 27 '23 14:01 vlad20012

Yes, I believe this can be closed, thanks!

ehuss avatar Jan 27 '23 15:01 ehuss