Skip to content

Attribute macros must be placed before derive attributes. #566

@ehuss

Description

@ehuss
Contributor

I can't find this anywhere in the reference.

#[derive(Debug)]
#[my_awesome_macro] // This is an error.
struct S;

Currently unstable, see: rust-lang/rust#81119

Activity

petrochenkov

petrochenkov commented on Apr 21, 2019

@petrochenkov
Contributor

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 rust-lang/rust#54277

saskenuba

saskenuba commented on Sep 24, 2020

@saskenuba

Any updates on this restriction?

petrochenkov

petrochenkov commented on Nov 15, 2020

@petrochenkov
Contributor

The restriction is going to be removed in rust-lang/rust#79078.

added a commit that references this issue on Feb 7, 2021
vlad20012

vlad20012 commented on Jan 27, 2023

@vlad20012
Member

Can be closed now?

ehuss

ehuss commented on Jan 27, 2023

@ehuss
ContributorAuthor

Yes, I believe this can be closed, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @ehuss@vlad20012@petrochenkov@saskenuba

        Issue actions

          Attribute macros must be placed before `derive` attributes. · Issue #566 · rust-lang/reference