Is proc-macro-attribute application order defined?
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 25/100
- Issue type
- Documentation
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- rust
- Domain
- compilers, documentation
Research direction
Start by reading the related discussions in #565 and rust-lang/rust#63336, then inspect the Rust Reference sections covering attributes and procedural macros. The issue is done when the expansion order and attribute-resolution behavior are settled and documented; the payload names no specific file or test.
Written by the indexing model from the issue text.
Description
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. https://github.com/rust-lang/rust/issues/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.
- Dominant language
- Rust
- Stars
- 1.6k
- Forks
- 607
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 12
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.
More from rust-lang/reference
-
A-const-eval A-undefined-behavior
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
A-resolve
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
-
A-coercions
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
All issues in rust-lang/reference
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
kwakseongjae/auto-hwp#319 ·
-
area:cli bug filter-quality good first issue priority:medium
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
Difficulty 1/5 Under an hour Newbie friendliness 72/100
bevyengine/bevy#25861 ·
-
comp-datalake
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
ClickHouse/ClickHouse#121222 ·
-
enhancement remote
Difficulty 2/5 1-3 hours Newbie friendliness 68/100