-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Tracking issue for plugin stabilization (plugin
, plugin_registrar
features)
#29597
Comments
Current status: awaiting a complete revamp of the plugin system. cc @nrc |
plugin_registrar
plugin
, plugin_registrar
features)
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. 😃 |
@nrc is |
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. :} |
This is necessary because stable Rust does not yet support custom #[derive] implementations, which are needed for Serde's Serialize/Deserialize traits. Serde has a macro package and compiler plugin which handle those, but compiler plugins are *also* not availble in stable Rust, so we instead have to generate code at build time using serde_codegen. Bug for `custom_derive` feature: rust-lang/rust#29644 Bug for compiler plugins: rust-lang/rust#29597
This is necessary because stable Rust does not yet support custom #[derive] implementations, which are needed for Serde's Serialize/Deserialize traits. Serde has a macro package and compiler plugin which handle those, but compiler plugins are *also* not availble in stable Rust, so we instead have to generate code at build time using serde_codegen. Bug for `custom_derive` feature: rust-lang/rust#29644 Bug for compiler plugins: rust-lang/rust#29597
Any progress now? |
Yes! The "Macros 1.1" RFC at rust-lang/rfcs#1681 was accepted. It’s implementation is tracked at #35900. |
It would be nice to build on stable Rust. In particular, I'm hitting compiler bugs in Rust nightly, such at this one: rust-lang/rust#38177 I imagine beta/stable compilers would be less problematic. These two features were easy to get rid of: * alloc was used to get a Box<[u8]> to uninitialized memory. Looks like that's possible with Vec. * box_syntax wasn't actually used at all. (Maybe a leftover from something.) The remaining features are: * plugin, for clippy. rust-lang/rust#29597 I could easily gate it with a "nightly" cargo feature. * proc_macro, for serde_derive. rust-lang/rust#35900 serde does support stable rust, although it's annoying. https://serde.rs/codegen-stable.html I might just wait a bit; this feature looks like it's getting close to stabilization.
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? |
Any progress now? |
Are there any plans for stabilizing plugins in the foreseeable future? |
The plan is to remove the plugin API entirely. |
@oli-obk Could you go into details please? |
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. |
Is not rocket a plugin to a compiler? If so, that means we will bury it alive? |
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. |
@SimonSapin What's the status on Servo's use of this? |
Unchanged. https://github.com/servo/servo/blob/c7cd1b83a11/components/script_plugins/lib.rs uses |
What's going to replace the support for custom lints provided by lint plugins? Some sort of alternative seems like a good idea. |
At this point there is no replacement. See #62868 for some discussion of this. |
At this time, what's still using plugin support? |
No change to report for Servo. https://github.com/servo/servo/tree/9693111c9/components/script_plugins is still an old-style plugin. I don’t know of another practical way to write a custom lint that has access to type resolution. Details in #62868. Without this lint, any Rust code in Servo that manipulates values owned by the GC (which is a lot of code) would need to be marked as |
I'm not sure if this counts, but there's this crate https://github.com/draivin/rust-hotswap that although wasn't updated in a while (and I'm not sure if it even builds anymore), it's pretty cool. |
Discussed in T-compiler triage meeting today. I think the T-compiler strategy should be this:
@rustbot label: -I-compiler-nominated |
In my previous message I only replied to #29597 (comment) on a technical level. Activity in the Servo project has been low lately and will be in the forseeable future. If a better API becomes available, it’s not clear when or if we’d be able to migrate the GC rooting lint to it. Given this, I feel it’s probably not fair to expect rustc to indefinitely keep the burden of maintaining plugin support for Servo’s sake. |
Is there any viable alternatives? I really like compiler plugins, even if "they would be useless" (I don't see how) |
So what alternatives are there to replace the plugin interface ? Specifically, AST code injection. I was looking to create a plugin instrumenting code for specialized performance tracking, is this just not going to be supported going forward ? Back in 2018 the following project had a proof of concept: https://github.com/da-x/instru. Edit: I stumbled upon the following mentioning how the LLVM intrumentation coverage can be enabled in |
For the ast-level things, isn't proc_macros enough? Just execute a proc_macro at the root module of the crate, parse everything, do whatever transform you want to the code, and put them back together as a |
If we could do |
Does that entail tagging every function with a macro ? This project is meant to simplify the analysis of large scientific codebases. The plugin approach removes the need to dig into every twisted codebase, instead just compiling with a secret spice mix plugin to get instrumentation. |
I find that creating a way to use custom inner macros would solve the problem. And if the plugin system is meant to simplify the analysis of large scientific codebases, there should be an alternative. Like custom inner attributes that are applied to every item. |
Note that you can already replace rustc with your own by using the The existing plugin API has not been maintained in years. |
They've been deprecated for four years. This commit includes the following changes. - It eliminates the `rustc_plugin_impl` crate. - It changes the language used for lints in `compiler/rustc_driver_impl/src/lib.rs` and `compiler/rustc_lint/src/context.rs`. External lints are now called "loaded" lints, rather than "plugins" to avoid confusion with the old plugins. This only has a tiny effect on the output of `-W help`. - E0457 and E0498 are no longer used. - E0463 is narrowed, now only relating to unfound crates, not plugins. - The `plugin` feature was moved from "active" to "removed". - It removes the entire plugins chapter from the unstable book. - It removes quite a few tests, mostly all of those in `tests/ui-fulldeps/plugin/`. Closes rust-lang#29597.
They've been deprecated for four years. This commit includes the following changes. - It eliminates the `rustc_plugin_impl` crate. - It changes the language used for lints in `compiler/rustc_driver_impl/src/lib.rs` and `compiler/rustc_lint/src/context.rs`. External lints are now called "loaded" lints, rather than "plugins" to avoid confusion with the old plugins. This only has a tiny effect on the output of `-W help`. - E0457 and E0498 are no longer used. - E0463 is narrowed, now only relating to unfound crates, not plugins. - The `plugin` feature was moved from "active" to "removed". - It removes the entire plugins chapter from the unstable book. - It removes quite a few tests, mostly all of those in `tests/ui-fulldeps/plugin/`. Closes rust-lang#29597.
They've been deprecated for four years. This commit includes the following changes. - It eliminates the `rustc_plugin_impl` crate. - It changes the language used for lints in `compiler/rustc_driver_impl/src/lib.rs` and `compiler/rustc_lint/src/context.rs`. External lints are now called "loaded" lints, rather than "plugins" to avoid confusion with the old plugins. This only has a tiny effect on the output of `-W help`. - E0457 and E0498 are no longer used. - E0463 is narrowed, now only relating to unfound crates, not plugins. - The `plugin` feature was moved from "active" to "removed". - It removes the entire plugins chapter from the unstable book. - It removes quite a few tests, mostly all of those in `tests/ui-fulldeps/plugin/`. Closes rust-lang#29597.
Remove support for compiler plugins. They've been deprecated for four years. This commit includes the following changes. - It eliminates the `rustc_plugin_impl` crate. - It changes the language used for lints in `compiler/rustc_driver_impl/src/lib.rs` and `compiler/rustc_lint/src/context.rs`. External lints are now called "loaded" lints, rather than "plugins" to avoid confusion with the old plugins. This only has a tiny effect on the output of `-W help`. - E0457 and E0498 are no longer used. - E0463 is narrowed, now only relating to unfound crates, not plugins. - The `plugin` feature was moved from "active" to "removed". - It removes the entire plugins chapter from the unstable book. - It removes quite a few tests, mostly all of those in `tests/ui-fulldeps/plugin/`. Closes rust-lang#29597. r? `@ghost`
They've been deprecated for four years. This commit includes the following changes. - It eliminates the `rustc_plugin_impl` crate. - It changes the language used for lints in `compiler/rustc_driver_impl/src/lib.rs` and `compiler/rustc_lint/src/context.rs`. External lints are now called "loaded" lints, rather than "plugins" to avoid confusion with the old plugins. This only has a tiny effect on the output of `-W help`. - E0457 and E0498 are no longer used. - E0463 is narrowed, now only relating to unfound crates, not plugins. - The `plugin` feature was moved from "active" to "removed". - It removes the entire plugins chapter from the unstable book. - It removes quite a few tests, mostly all of those in `tests/ui-fulldeps/plugin/`. Closes rust-lang#29597.
Remove support for compiler plugins. They've been deprecated for four years. This commit includes the following changes. - It eliminates the `rustc_plugin_impl` crate. - It changes the language used for lints in `compiler/rustc_driver_impl/src/lib.rs` and `compiler/rustc_lint/src/context.rs`. External lints are now called "loaded" lints, rather than "plugins" to avoid confusion with the old plugins. This only has a tiny effect on the output of `-W help`. - E0457 and E0498 are no longer used. - E0463 is narrowed, now only relating to unfound crates, not plugins. - The `plugin` feature was moved from "active" to "removed". - It removes the entire plugins chapter from the unstable book. - It removes quite a few tests, mostly all of those in `tests/ui-fulldeps/plugin/`. Closes rust-lang#29597. r? `@ghost`
They've been deprecated for four years. This commit includes the following changes. - It eliminates the `rustc_plugin_impl` crate. - It changes the language used for lints in `compiler/rustc_driver_impl/src/lib.rs` and `compiler/rustc_lint/src/context.rs`. External lints are now called "loaded" lints, rather than "plugins" to avoid confusion with the old plugins. This only has a tiny effect on the output of `-W help`. - E0457 and E0498 are no longer used. - E0463 is narrowed, now only relating to unfound crates, not plugins. - The `plugin` feature was moved from "active" to "removed". - It removes the entire plugins chapter from the unstable book. - It removes quite a few tests, mostly all of those in `tests/ui-fulldeps/plugin/`. Closes rust-lang#29597.
They've been deprecated for four years. This commit includes the following changes. - It eliminates the `rustc_plugin_impl` crate. - It changes the language used for lints in `compiler/rustc_driver_impl/src/lib.rs` and `compiler/rustc_lint/src/context.rs`. External lints are now called "loaded" lints, rather than "plugins" to avoid confusion with the old plugins. This only has a tiny effect on the output of `-W help`. - E0457 and E0498 are no longer used. - E0463 is narrowed, now only relating to unfound crates, not plugins. - The `plugin` feature was moved from "active" to "removed". - It removes the entire plugins chapter from the unstable book. - It removes quite a few tests, mostly all of those in `tests/ui-fulldeps/plugin/`. Closes rust-lang#29597.
Tracks stabilization for the
plugin
andplugin_registrar
feature gates.The text was updated successfully, but these errors were encountered: