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
Do not generate unique __Field
for each struct
#2564
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR — this will be useful for benchmarking. Could you please look into compile time impact and runtime impact on https://github.com/serde-rs/json-benchmark, and compile time on https://github.com/gluon-lang/lsp-types?
I am not going to merge this though. I am not on board with exposing public Field
/FieldStrong
right away, and I am not on board with derive for simple structs needing to use __private
in a way that users cannot copy into their handwritten impls. This is discussed in the review you linked, with a recommendation for a path forward.
1a28feb
to
c74b8de
Compare
(review this commit with "ignore whitespace changes" option on)
7d7e5f4
to
d7322e6
Compare
Here is some results: comparison.zip. Measured commits v1.0.183 (05a5b7e) and df12e82, which removes all possible variants of In both cases [patch.crates-io]
serde = { path = "../serde/serde" } The following commands was used (taken from this comment):
@nnethercote perhaps you are willing to test impact of this PR on your cases? |
As suggested in #2250 (review), this PR replaces
__Field
generation with common structs insideserde
crate.There are three different forms of a
__Field
struct, each one has its own struct:Field
+FieldSeed
-- for structs without flatten fields and without#[serde(deny_unknown_fields)]
FieldStrong
+FieldStrongSeed
-- for structs without flatten fields and with#[serde(deny_unknown_fields)]
FieldFlatten
+FieldFlattenSeed
-- for structs with flatten fields