-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Apply only allowed attributes to generated functions #3784
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So by default we have to pass through all attributes, because anything else is a breaking change.
What we can do is to only pass cfg
and cfg_attr
by default for the functions generated by wasm-bindgen
, e.g. *_describe_*()
. This is theoretically still a breaking change but I think proc-macros that generate cfg
s are pretty rare (which are the only ones we really need to support here).
I believe these changes along should suffice to solve #3315, adding an attribute to allow passing down more specific user-specified attributes is not necessary until requested.
I'm not entirely sure but I think you have already achieved what I outlined above with this PR.
It would be great if we can add a test.
@Liamolucko considering this is theoretically a breaking change, I would very much like your approval as well here.
Yes, it wasn't clear where to add tests. It's not a compilation error/warning, so the ui-tests didn't seem to apply. Any advice? |
I would have imagined them to be added via compilation errors as UI tests. E.g. use Of course ideally we would have proper proc-macro tests, if you feel like adding them that would be great. But I'm happy to accept UI tests instead of nothing. |
Apologies, after further thinking I believe you are right, this doesn't make sense in a UI test (and Serde doesn't have any method related attributes I believe). I believe non-UI tests can be added in |
694d929
to
1a28c50
Compare
@daxpedda I was able to add a test to the existing test suite in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add another test with custom proc-macros, to make sure they are skipped for the generated functions?
Feel free to add any reasonable dev-dependencies to make it happen, e.g. tracing
.
I think it should be fine, I'd be very surprised if anyone's relying on attributes getting copied to |
This is a response to #3315. @daxpedda suggested that we pass down specific attributes and then allow the user to specify additional allowed attributes that could be attached to the bindgen and descriptor functions.
This is an initial implementation of the first part of this idea, namely, that only the
cfg
andcfg_attr
attributes are allowed to be passed through. There may be others that should be allowed by default, but since these are involved in conditional compilation, I felt they would be most relevant to apply to the generated functions.I'm mostly looking for feedback on the direction here before I dive too much deeper. Thanks!