Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is proc-macro-attribute application order defined? #692

Open
CAD97 opened this issue Oct 5, 2019 · 2 comments
Open

Is proc-macro-attribute application order defined? #692

CAD97 opened this issue Oct 5, 2019 · 2 comments
Labels
A-attributes Area: Attributes A-proc-macro Area: proc-macros

Comments

@CAD97
Copy link

CAD97 commented Oct 5, 2019

In code, if I write

#[strip_attrs_on_item]
#[this_attr_always_panics]
struct Foo;

Is it guaranteed that strip_attrs_on_item will receive the token stream # [ this_attr_always_panics ] struct Foo ; and that if it does what it says on the tin and emits struct Foo ;, this_attr_always_panics is not called?

As an addendum, is this_attr_always_panics even resolved, if it's transformed before application?

#565 is probably related. rust-lang/rust#63336 is this issue.

derive macros have a special path to say "I handle this attribute" so derive(serde::Serialize) implies that you can use #[serde(..)] afterwards, and the derive gives it meaning. If expansion order isn't guaranteed outer before inner, then replacing the derive with an attribute would remove this ability.

This is not #578, which is about attributes within the same crate but on different items.

@Centril
Copy link
Contributor

Centril commented Oct 6, 2019

cc @petrochenkov @eddyb

@Luro02
Copy link

Luro02 commented Apr 12, 2020

This comment might be related rust-lang/rust#67839 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-attributes Area: Attributes A-proc-macro Area: proc-macros
Projects
None yet
Development

No branches or pull requests

4 participants