-
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
Tracking issue for custom_derive
feature
#29644
Comments
There isn't really much incentive to stabilize this at the moment; this is basically only useful with plugins (and syntex, but the gate doesn't affect that usage). |
Is there an RFC for this? I couldn't find one easily. |
No RFC; see #23137. |
Do we know who uses custom_derive? It seems like a horrible hack. (Thanks for the link @eefriedman) |
wow look at the turnaround time on that PR! Proposed, r+'ed, and landed all in one day! |
Two crates that use custom_derive: serde_macros and diesel_codegen. |
Servo also uses it in a few places, for example https://github.com/servo/heapsize . |
Thanks for the info. I think custom derive is something we should support, but not in the current form. I'll have a think about how it fits in to the procedural macro overhaul and write some kind of RFC. |
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
HOPE WILL NEVER DIE! Can't use XML/JSON deserialization to structures, but I still hope... 😢 |
cc #35900 |
Nominating for deprecation now that we have macros 1.1 custom derive in place. |
@rfcbot fcp close The general consensus is that this is subsumed by macros 1.1, which offers a more general solution. |
Team member nikomatsakis has proposed to close this. The next step is review by the rest of the tagged teams: No concerns currently listed. See this document for info about what commands tagged team members can give me. |
All relevant subteam members have reviewed. No concerns remain. |
🔔 This feature is undergoing its final comment period with disposition to deprecate. 🔔 |
The final comment period is now complete. |
This is waiting on ultimate removal. Note that here @SergioBenitez says Rocket needs this feature. |
|
I'm in favour of a longer than usual deprecation period. As well as being more powerful, people apparently continue to use old custom derive because they can have a single crate which implements both derives and proc macros, and until we have a more function proc macro 2.0 solution, using new custom derive means having two separate implementations. |
Please see my argument against removal in #37128 (comment). I'm okay with deprecation as long as #38533 remains valid (users don't receive a warning) and I can |
I'm confused about the status of this deprecation. The nightly compiler says derive for custom traits will be removed in 1.15, but nightly is now in 1.16. Combined with @SergioBenitez's comments and Rocket's continued dependence on this feature, I'm pretty unsure whether to assume it will continue for the foreseeable future or whether it really is at risk of being removed any time now. Please advise. |
The deprecation warning was written many months ago, given the above comments the warning should probably be bumped a few versions. |
So regarding the deprecation warning, what will the next removal target be? 1.17 + 3 = 1.20 perhaps? |
@joshhansen My feeling is that we should remove this and I would definitely not advise writing new code that relies on it. That said, I don't think there is a tremendous hurry to do so; all things being equal I'd prefer not to break rocket, of course. Still, if this feature ever becomes an obstacle to doing something we would want, I would be inclined to remove it ASAP, so migrating is definitely a good idea. I heard something about @jseyfried working with @SergioBenitez to move over to the prototypes of the newer macro system that may be relevant here. |
I feel absolutely confused. You just announced it here: https://blog.rust-lang.org/2017/02/02/Rust-1.15.html |
@e-oz We just stabilized and announced a different feature (macros 1.1, aka |
I have to say it was awful idea to release new feature with exactly same name as old deprecated feature. |
The name of the new feature was |
Of course, in retrospect it would have been better to name the old feature something more specific than |
I think the complaint was about the release announcement, which said we're stabilizing "custom derive". I agree that this is all a bit confusing, especially for those not following Rust development closely. |
Yes, that's what broke my whole app and gave me work for a couple of next days. |
[beta] Give a better error message for unknown derive messages This PR improves the error message for unknown derive macros. Currently unknown derives give the following error, which is very misleading: ``` `#[derive]` for custom traits is not stable enough for use. It is deprecated and will be removed in v1.15 (see issue #29644) ``` I'm currently working on a PR that will change this (#39442) to the following: ``` cannot find derive macro `Foo` in this scope ``` This PR backports the (as yet unmerged) error message to beta/1.16 (it's a pity that this is probably too late for 1.15). r? @jseyfried
@SergioBenitez Are you still using this feature? |
@cramertj Yes. With the recent improvements to the proc_macro APIs and a few additional ones, however, I should be able to move Rocket to proc_macro soon. |
@SergioBenitez are you still using this feature? |
Yes. The plan is to migrate away from custom_derive as soon as possible however. Current progress puts us as doing so by next release, or about a month. |
Update: All of Rocket's derives are now implemented as proc-macros and will ship as such in the next official release, which should be within a couple of weeks time. |
Unsupport `#[derive(Trait)]` sugar for `#[derive_Trait]` legacy plugin attributes This is a long deprecated unstable feature that doesn't mesh well with regular resolution/expansion. How to fix broken code: - The recommended way is to migrate to stable procedural macros - derives or attributes (https://doc.rust-lang.org/nightly/book/first-edition/procedural-macros.html). - If that's not possible right now for some reason, you can keep code working with a simple mechanical replacement `#[derive(Legacy)]` -> `#[derive_Legacy]`. Closes #29644 r? @ghost
Treats
#[derive(Anything)]
like#[derive_Anything]
. Tracking for stabilization.The text was updated successfully, but these errors were encountered: