Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upTracking issue for plugin stabilization (`plugin`, `plugin_registrar` features) #29597
Comments
aturon
added
T-lang
B-unstable
labels
Nov 5, 2015
This comment has been minimized.
This comment has been minimized.
|
Current status: awaiting a complete revamp of the plugin system. cc @nrc |
aturon
changed the title
Tracking issue for `plugin_registrar`
Tracking issue for plugin stabilization (`plugin`, `plugin_registrar` features)
Nov 5, 2015
This comment has been minimized.
This comment has been minimized.
|
Is anyone actively working on this? Curious what the status is since using Serde without the need for code generation with syntex on stable Rust is very high on my Rust wishlist. |
This comment has been minimized.
This comment has been minimized.
|
@nrc is |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Thanks Aaron—I had read a couple of the posts about the macro system but it didn't click that this was intended to replace compiler plugins for the purpose of syntax extensions. It makes sense now, and looks great. I can't wait. :} |
callahad
added a commit
to callahad/ladaemon
that referenced
this issue
Jun 24, 2016
callahad
added a commit
to callahad/ladaemon
that referenced
this issue
Jun 26, 2016
This comment has been minimized.
This comment has been minimized.
|
Any progress now? |
This comment has been minimized.
This comment has been minimized.
|
Yes! The "Macros 1.1" RFC at rust-lang/rfcs#1681 was accepted. It’s implementation is tracked at #35900. |
scottlamb
added a commit
to scottlamb/moonfire-nvr
that referenced
this issue
Dec 8, 2016
Mark-Simulacrum
added
the
C-tracking-issue
label
Jul 22, 2017
Ms2ger
referenced this issue
Oct 13, 2017
Open
Tracking: Unstable Rust feature gates used by Servo #5286
This comment has been minimized.
This comment has been minimized.
|
The one remaining plugin in Servo is a Could this kind of analysis be built on top of RLS? Could that be a way forward for custom lints without relying on unstable rustc internals? |
This comment has been minimized.
This comment has been minimized.
eisterman
commented
Mar 31, 2018
|
Any progress now? |
This comment has been minimized.
This comment has been minimized.
0rvar
commented
Jul 16, 2018
|
Are there any plans for stabilizing plugins in the foreseeable future? |
This comment has been minimized.
This comment has been minimized.
|
The plan is to remove the plugin API entirely. |
This comment has been minimized.
This comment has been minimized.
vityafx
commented
Aug 3, 2018
|
@oli-obk Could you go into details please? |
This comment has been minimized.
This comment has been minimized.
|
Even if we stabilized the plugin interface, it would be useless, because there is no stable API it offers. Instead things like proc macros 2.0, custom derive, ... are stabilized by offering an interface that does not require the language to guarantee a plugin interface to the compiler. All of these non-plugin-requiring APIs can be implemented with various other schemes, even if they are currently implemented via plugins in the background. Note: this issue is not about allowing writing bin crates which can be extended via plugins, it is about plugins that can extend the compiler. |
This comment has been minimized.
This comment has been minimized.
vityafx
commented
Aug 3, 2018
|
Is not rocket a plugin to a compiler? If so, that means we will bury it alive? |
This comment has been minimized.
This comment has been minimized.
|
Rocket is a plugin to the compiler because proc macros 2.0, and most notably their attribute support is not implemented yet. Of course there is no desire to eliminate any uses of the plugin API without a viable alternative. But there is also no desire to stabilize it while there are much better alternatives on the horizon. Especially if stabilizing has a high cost for the compiler, while the alternatives do not have the same cost associated with them. |
juaby
referenced this issue
Oct 12, 2018
Closed
error[E0554]: #![feature] may not be used on the stable release channel #201
This comment has been minimized.
This comment has been minimized.
|
@SimonSapin What's the status on Servo's use of this? |
This comment has been minimized.
This comment has been minimized.
|
Unchanged. https://github.com/servo/servo/blob/c7cd1b83a11/components/script_plugins/lib.rs uses |
This comment has been minimized.
This comment has been minimized.
|
Is there a tracking issue for moving to a |
This comment has been minimized.
This comment has been minimized.
The current effort around GC safety is at https://github.com/asajeffrey/josephine/, but as far as I know it does not involve |
This comment has been minimized.
This comment has been minimized.
montao
commented
Feb 11, 2019
I am just learning it. Should I not? I think I got a working example |
This comment has been minimized.
This comment has been minimized.
I personally would suggest not to use the API, especially not to add new uses of it. What is your use case? Maybe we can find an alternative way for you to reach your goal without using the plugin API |
This comment has been minimized.
This comment has been minimized.
montao
commented
Feb 11, 2019
I have a metaprogramming project with Basile in Paris who is a research engineer, he mostly works in C and generates many plugins using dlopen in C. We are looking for alternatives to C. We looked at Go but Go includes the runtime in the plugin which creates too large files if we generate thousands of plugins. So far I think that Rust is the only alternative to C in doing this. We really tried hard to achieve it with Go which was our first choice but right now it looks like the changes and fixes we would have to make to the Go build system are too many and too complicated. Therefore I was glad when I got this to work with Rust. I could create a project with several plugins and I can also make the code generate custom plugins at runtime, and it seems that these will be dynamically linked using Rust which is suitable for our case. My Rust code with the plugins https://gitlab.com/montao/rust-multiplugins My Go code with the plugins, which includes the runtime and therefore duplicates code https://gitlab.com/montao/forbasile |
This comment has been minimized.
This comment has been minimized.
|
Looking at the Rust examples, you can achieve the same thing with procedural macros. They are documented here and above that in more detail I believe these do cover your use cases. Please let me know if that assessment is wrong. |
This comment has been minimized.
This comment has been minimized.
osor-io
commented
Feb 16, 2019
|
First of all, my apologies if I'm asking for features that are possible to do some other way or if I'm missing some key parts of the plugin/macro systems I've been investigating this side of Rust for not that long but I'm very excited to try to do some things in it I've yet to investigate it further but it does seem like the case that the plugin features offer everything that macros do right? Can you do something like annotate a file once and then wrap every procedure with a profiler related tag or something? I'd like to do something like the following
And get my plugin/macro/whatever will replace plugins to give me this:
In general I'd like to now have to do excessive tagging, just to enable a plugin to do something. Another feature that would help me immensely would be the possibility to have some state in my compiler plugin/macro so when my callback happens I can store something in there that I can read in future calls. For example, let's say I'm generating Rust code based on something and I generate a new struct that I insert into the AST called Would all of these things be possible with the Macro system or with something that replaced plugins? Or are they possible to do without the need for nightly in a not very painful way (or at all?)? Sorry if I'm missing important bits here or if I don't understand some fundamental facts about Macros and plugins. I just got scared at the plugin features going away since I believe they could add so much to the language and I was very excited to use them only to discover that they are only nightly, their use is discouraged and they might just dissapear Cheers! |
This comment has been minimized.
This comment has been minimized.
|
Yes I do believe everything you just described is possible with procedural macros. You are specifically looking for procedural attribute macros. Though you'd use Though I think the way you are describing it, you'd want this in the crate root and process the entire crate at once. This way you have a global view on the entire crate and can do a global analysis (wrt generating structs only once and such).
the plugin system was a stopgap solution until we got proper procedural macros. No features are disappearing, they are just getting implemented in a sane way that can move to stabilization at some point. The plugins, by their very definition are inherently unstable. |
This comment has been minimized.
This comment has been minimized.
osor-io
commented
Feb 16, 2019
|
It looks like I was looking too much at plugins while ignoring the better procedural macros indeed I get that there's ways to keep state between calls to procedural macros? I'd like to have more than one macro that reads from some shared state to be able to do some code generation that requires me to get some context on what some other macros might have done already Oh and thanks for the quick response! Cheers! |
This comment has been minimized.
This comment has been minimized.
|
Well.. procedural macros can do whatever they want. They can even write to files or access the network. Whether that is a good idea is a different question. They are not meant to share state (neither were plugins meant to do that). Shared state during compilation interferes with incremental compilation and may result in nondeterministic builds. If, on the other hand, you create a single crate-wide attribute, that attribute can see the entire crate at once and generate code inside it. So you don't need shared state between instances, but can just do a global analysis. |
This comment has been minimized.
This comment has been minimized.
Moreover, we do not guarantee a specific order of execution if you write something like: #[my_macro_a]
fn foo() { ... }
#[my_macro_b]
fn bar() { ... }so there is no guarantee that if you save some state in |
This comment has been minimized.
This comment has been minimized.
osor-io
commented
Feb 17, 2019
|
Oh, I see |
This comment has been minimized.
This comment has been minimized.
|
@osor-io Just in case you haven't found it out, the macro wizard @dtolnay have brought us this crate: |
aturon commentedNov 5, 2015
Tracks stabilization for the
pluginandplugin_registrarfeature gates.