-
-
Notifications
You must be signed in to change notification settings - Fork 795
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
The serde crate's derive feature interacts poorly with 2018-style macro imports #1441
Comments
I am on board with your proposed solution -- let's update all documentation and examples to recommend depending on the derive macros re-exported by serde rather than using serde_derive. |
This issue made me think about the impact path-imported macros has on re-exported macros and other items with the exact same name. Previously, they were in completely separate namespaces, so that was fine. Now re-exporting macros will silently re-assign a new item under that name (you could say now the macro namespace silently leaks into the other items namespace). Which means the pattern where:
does not seamlessly work anymore in all newer Rust versions because of the edge case this issue presents. As a result, now that using the Deprecating will have an added benefit of being future-compatible with procedural macros that are defined in the same crate as non-procedural macro items. If deprecating |
Instead of deprecating serde_derive I would prefer if multiple imports of the same item did not conflict with each other. In this case |
To be fair,
is quite surprising without knowing the context, both because a single |
I find the thing surprising in the opposite direction too, somehow. I usually enable the |
I updated all example code to use serde's derive feature rather than depending directly on serde_derive. |
This is in line with best practices recommended by serde[1]. This will also resolve downstream crates depending on shiplift who enable the serde derive feature, due to Cargos unification of features for each crate[2]. [1]: serde-rs/serde#1441 [2]: rust-lang/cargo#4361 (comment)
This is in line with best practices recommended by serde[1]. This will also resolve downstream crates depending on shiplift who enable the serde derive feature, due to Cargos unification of features for each crate[2]. [1]: serde-rs/serde#1441 [2]: rust-lang/cargo#4361 (comment)
`serde_derive`. Works around the issue, when using `rogcat` as a library; see serde-rs/serde#1441
`serde_derive`. Works around the issue, when using `rogcat` as a library; see serde-rs/serde#1441
`serde_derive`. Works around the issue, when using `rogcat` as a library; see serde-rs/serde#1441
`serde_derive`. Works around the issue, when using `rogcat` as a library; see serde-rs/serde#1441
* Move parsers to the library * use serde `derive` feauture to replace explicit dependency on `serde_derive`. Works around the issue, when using `rogcat` as a library; see serde-rs/serde#1441
This change: - Allows for future imports of crates that dep on the serde derive feature (e.g. trybuild). - Migrates all existing dual {serde, serde_derive} deps to use serde only. The crate migration per-se is not necessary, but without changes the build breaks due to an issue with the macros being imported multiple times. Read more @ serde-rs/serde#1441 Change-Id: I02c5dc59aec77b30898684a9799a4541c3ed80a5
Needed to fix compilation issue encountered when qapi was used together with another crate that activated serde's derive feature. Followed the recommendation here: serde-rs/serde#1441
This change: - Allows for future imports of crates that dep on the serde derive feature (e.g. trybuild). - Migrates all existing dual {serde, serde_derive} deps to use serde only. The crate migration per-se is not necessary, but without changes the build breaks due to an issue with the macros being imported multiple times. Read more @ serde-rs/serde#1441 Change-Id: I02c5dc59aec77b30898684a9799a4541c3ed80a5
Say I have a crate that derives Serialize for one type, and has to manually implement it for another. I believe the "standard" way of doing this would be
This works fine in isolation, but if this crate is used alongside some other crate that activates serde's
derive
feature, it will stop compiling:The crate can be made to compile in both scenarios by importing Serialize and Serializer from
serde::ser
rather thanserde
, but it seems like an easy thing to forget, and you're not going to notice until it breaks someone downstream that's trying to use your crate.What do you think the right way of avoiding this is? Should the recommended approach change from depending on serde_derive to using the derive feature directly?
The text was updated successfully, but these errors were encountered: