-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Custom attributes from unstable plugins and procedural macro attributes are not compatible #40001
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
Comments
Note that |
@nox Does the plugin remove the cc @jseyfried |
@abonander Which plugin do you mean? |
This comment was a bit exaggerated, sorry :) The issue looks like some bad interaction between old-style plugins and new-style procedural macros. Given that plugins are on the way out, I’m skeptical that people will be interested in putting in work to fix it. In the short term, that means we’ll need to keep In medium term, the usual advice is to move everything to proc macros instead of plugins. But as far as I understand this doesn’t work for The "best" solution here would be proper GC support in the language, but it seems that there is still a lot of work to do before that happens. Maybe @pnkfelix can say more. |
Which nightly were you using for this? There have been some PRs playing with the expansion order recently, which may have fixed/introduced the issue. This is definitely an issue that should be fixed though. |
Servo is currently on rustc 1.17.0-nightly (025c328 2017-02-15) |
I just tried with (8a1ce40 2017-02-21), it didn't fix the problem. |
Actually the error is different now:
I double checked whether I still do whitelist it, and whether I still have an |
I pushed the rustup commit to the branch if anyone wants to try. |
That was simply the error message being updated. If I have some free time tonight, I'll try looking into this. Does |
It doesn't work anywhere, even on structs that don't use |
I did some debugging, and I only start getting this error when I add the |
Well yes of course. This bug was discovered when |
This is because Perhaps we can implement associated attributes similar to what custom derive does. @jseyfried What do you think? |
@abonander We don't use |
Also note that |
Regardless, that's what I believe is causing the problem here. It's trying to eagerly expand attributes as procedural macros because a kind-of chicken-or-egg problem in that part of expansion. I half expected we'd end up dealing with something like this but I was more eager to at least get the basic implementation going so I could use it with my own prototype. |
I think the right thing to do here is to modify this function to ignore plugin attributes. (It's only called when the proc_macro feature is enabled). Checking that feature_gate.plugin_attributes does not contain the name may be enough. |
The problem is that Perhaps it is necessary to require lints to declare any attributes they use. |
It's declared and whitelisted in |
Ah, so yeah, that needs to be checked when collecting attributes then. |
I think it is important that old-style plugins interact as well as possible with procedural macros to ensure a smooth transition. At a bare minimum, adding @abonander fixed this in #40039 (@nox @keeperofdakeys thanks for helping debug!). |
Thanks @abonander and @keeperofdakeys, and thanks to the Rust team for the neat per-PR nightlies which will allow me to try it in Servo as soon as the PR lands. |
Don't assume plugin-whitelisted attributes are proc macro attributes closes #40001
In servo/servo@master...nox:custom-derive I changed the attribute
#[dom_struct]
from ourplugins
crate (aplugin = true
crate) into aproc_macro_attribute
function. Unfortunately, theplugins
crate also defines a whitelisted attribute#[must_root]
and using both at the same time fails with the following compile error:The text was updated successfully, but these errors were encountered: