-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Attributes are reordered before they are passed to a proc-macro #67839
Comments
I agree that the relative order of inert attributes should be kept. I plan to fix this during the upcoming macro invocation collector rewrite (#54727 (comment)), unless someone gets to it earlier (this should be doable without rewriting the invocation collector entirely). cc #63221 |
I think this change can wait, until the new macro system is implemented, becuse this would be a breaking change either way. (for example the code given above would have different output, if a macro relies on the current order of attributes) |
Would this issue also include the proposal of ordering from rust-lang/reference#565 (comment)? If I currently write, #[foo]
#[derive(Bar)] As far as I observed: |
Fixed in #82419. @pksunkara |
@petrochenkov Really appreciate your hard work in fixing both the issues. I have reworked some of my APIs to not run into this, but I am happy that I can now pick the best ergonomics for my proc-macro libraries instead of trying to navigate these issues. |
expand: Preserve order of inert attributes during expansion Fixes rust-lang#67839 Fixes rust-lang#81871 r? `@Aaron1011`
expand: Preserve order of inert attributes during expansion Fixes rust-lang#67839 Fixes rust-lang#81871 r? ``@Aaron1011``
expand: Preserve order of inert attributes during expansion Fixes rust-lang#67839 Fixes rust-lang#81871 r? ```@Aaron1011```
expand: Preserve order of inert attributes during expansion Fixes rust-lang#67839 Fixes rust-lang#81871 r? ````@Aaron1011````
I am working on a proc-macro, where I would like to give the user the option, to decide, which attributes (and doc comments) should be forwarded.
For example
as you can see in the above case, the order of the attributes is very important.
Sadly the rust compiler (or the
proc_macro
crate) does reorder the attributes, before passing them to the function as aTokenStream
.(this is the output of
cargo expand
, the proc-macro gets a similarTokenStream
, where the order is not preserved either)I think this should not happen and the order should be preserved! Are there any good reasons for reordering them?
related to #36211
The text was updated successfully, but these errors were encountered: