Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upThe serde crate's derive feature interacts poorly with 2018-style macro imports #1441
Comments
dtolnay
added
the
docs
label
Dec 8, 2018
This comment has been minimized.
This comment has been minimized.
|
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 comment has been minimized.
This comment has been minimized.
|
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 |
This comment has been minimized.
This comment has been minimized.
|
Instead of deprecating serde_derive I would prefer if multiple imports of the same item did not conflict with each other. In this case |
This comment has been minimized.
This comment has been minimized.
|
To be fair,
is quite surprising without knowing the context, both because a single |
This comment has been minimized.
This comment has been minimized.
vorner
commented
Jan 12, 2019
|
I find the thing surprising in the opposite direction too, somehow. I usually enable the |
sfackler commentedDec 8, 2018
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
derivefeature, it will stop compiling:The crate can be made to compile in both scenarios by importing Serialize and Serializer from
serde::serrather 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?