-
Notifications
You must be signed in to change notification settings - Fork 488
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
Fix/clarify inert/active attributes, and attribute sequence. #565
Comments
If the attribute resolves to
Through generic macro expansion machinery usually.
The general intent is to expand everything in straightforward left-to-right fashion (except for #[my_attr]
#[derive(MyDerive)]
#[my_attr2]
ITEM
=>
my_attr!(MyDerive!(my_attr2!(ITEM))) basically. Derives currently have some issues in this area due to their chaotic Macro 1.1 and legacy nature, but they should be realistically fixable without noticeable breakage. |
After rust-lang/rust#79078 |
The inert/active attribute description is not be correct. The following comment needs to be incorporated: #537 (review)
However, I think the inert/active distinction is subtle and should have more clarification. It is possible to "see" an active attribute based on the point in time during compilation (for example, an attribute macro placed before
#[test]
sees thetest
attribute, it has not been removed, yet).Also, to me it seems like like
cfg
andcfg_attr
aren't always active. If the predicate is true, they are clearly visible from attribute macros, so they have not been removed. This comment implies that things are broken.I would like to know how I can validate this inert/active distinction by reading the rustc code. It is not tracked in any data structure I can see, and I do not know through which mechanism an attribute removes itself. Otherwise I feel like I am shooting in the dark trying to document this.
Also I think the order that attributes are processed and when attributes remove themselves should be documented. For example, do attribute macros see
derive
macros (yes, the derive has not been removed, yet). What is the significance of the order that attributes are listed? (Presumably they are processed top-down?) Attribute macros seem to be removed only after they are processed (an attribute macro sees the attributes below it, but not above it). When iscfg
pruning done (pretty early)? In general I think the order attributes are processed and when attributes remove themselves should be documented.The text was updated successfully, but these errors were encountered: