-
-
Notifications
You must be signed in to change notification settings - Fork 786
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
Add a #[serde(crate_name = "…")] attribute #953
Comments
Attribute parsing happens in Before writing code though, I wanted to write a test case. It likely needs to be a separate crate so that a |
I would test this by adding a crate That said, I am not quite ready to commit to a If you put this attribute on any type in your crate, chances are you want it on every type that derives Serialize or Deserialize. Repeating it for a crate with lots of types will be obnoxious. Something like a macro might be better fit here - where serde_derive emits "extern_crate_serde!()" instead of "extern crate serde" so you can override it globally for your crate by overriding that macro. We would need to evaluate whether this is forward compatible with proc macro hygiene, and how scoping would work in the event that you do want to use different serde crates for different types in your crate. As an attribute I would prefer I would also like to consider not just crate names but paths to where to find the serde crate - similar to how |
Closing because I don't intend to address this by adding a new attribute. For the url crate I would prefer to drop serde_derive and provide handwritten impls using their local name for the serde crate. More generally closing in favor of rust-lang/rust#54363 to centralize the discussion around referring to specific crates from the output of a proc macro. |
@dtolnay I think this can be half solved by ditching the |
For future code archaeologists, this seems to implemented and superseded by #1499 ( |
servo/rust-url#327 proposes depending on multiple versions of serde at the same time, in order to add support for new (semver-incompatible) versions without removing support for old ones (which would be a breaking change). This is done by not depending on the
serde
crate directly, but depending onserde1
which itself depends onserde = "1.0"
and re-exportspub use serde::*;
.However this prevents using
derive
because the code generated by derive includes its ownextern crate serde;
. I’d like an attribute to be added to control the name of the crate in the generatedextern crate
code. Something like:The text was updated successfully, but these errors were encountered: