-
-
Notifications
You must be signed in to change notification settings - Fork 777
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
Fix incorrect representation of tuple variants with skipped fields #2549
Draft
Mingun
wants to merge
16
commits into
serde-rs:master
Choose a base branch
from
Mingun:fix-enum-skip
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…tion (review this with whitespace changes ignored)
…ction and rename it
…n_place` Those functions too small and used only once (review this with whitespace changes ignored)
Changes in generated code (see the file attached to PR): Tuple1as0: Tuple1as0Default: Tuple1as0With: fixed visit_newtype_struct: use default value instead of deserializing it This fixes compilation error for Deserialize side of Tuple1as0(Skipped) tuple
Enums out of scope for now, because they have too many problems failures (1): tuple_struct::tuple2as1 compilation error (commented): tuple_struct::tuple1as0
…r to Tuple0() struct A side-effect: Tuple2as1(Skipped, x) now also can be deserialized using visit_newtype_struct Changes in generated code (see the file attached to PR): Tuple1as0: Tuple1as0Default: Tuple1as0With: removed visit_newtype_struct, *_newtype_struct -> *_tuple_struct(0) Tuple2as1: Tuple2as1Default: Tuple2as1With: added visit_newtype_struct This commit fixes compilation error and actually fixes the issue as it was reported in serde-rs#2105
failures (15): enum_::adjacently_tagged::tuple_struct::tuple0 enum_::adjacently_tagged::tuple_struct::tuple1 enum_::adjacently_tagged::tuple_struct::tuple2as0 enum_::adjacently_tagged::tuple_struct::tuple2as1 enum_::adjacently_tagged::unit enum_::externally_tagged::tuple_struct::tuple0 enum_::externally_tagged::tuple_struct::tuple1 enum_::externally_tagged::tuple_struct::tuple1as0 enum_::externally_tagged::tuple_struct::tuple2as0 enum_::externally_tagged::tuple_struct::tuple2as1 enum_::internally_tagged::tuple_struct::tuple1 enum_::untagged::tuple_struct::tuple0 enum_::untagged::tuple_struct::tuple1as0 enum_::untagged::tuple_struct::tuple2as0 enum_::untagged::tuple_struct::tuple2as1 compilation error (commented): enum_::adjacently_tagged::tuple_struct::tuple1as0 enum_::internally_tagged::tuple_struct::tuple0 enum_::internally_tagged::tuple_struct::tuple2as0 enum_::internally_tagged::tuple_struct::tuple2as1
…ed enums Add methods to calculate effective style of variant
Does not change anything in the generated code, but the new code will correctly process tuple variants when serialization style would compute correctly
Changes in serialization (see the file attached to PR): ExternallyTagged, Untagged, Mixed: Tuple0: tuple(0) -> unit Tuple2as0: tuple(0) -> unit Tuple2as1: tuple(1) -> newtype Tuple2as0Default: tuple(0) -> unit Tuple2as1Default: tuple(1) -> newtype Tuple2as0With: tuple(0) -> unit Tuple2as1With: tuple(1) -> newtype AdjacentlyTagged: Tuple0: { tag, content: tuple(0) } -> { tag } Tuple2as0: { tag, content: tuple(0) } -> { tag } Tuple2as1: { tag, content: tuple(1) } -> { tag, content: newtype } Tuple2as0Default: { tag, content: tuple(0) } -> { tag } Tuple2as1Default: { tag, content: tuple(1) } -> { tag, content: newtype } Tuple2as0With: { tag, content: tuple(0) } -> { tag } Tuple2as1With: { tag, content: tuple(1) } -> { tag, content: newtype }
Does not change anything in the generated code, but the new code will correctly process tuples, when serialization style would compute correctly
Changes in deserialization of all enums, except externally tagged (see the file attached to PR): no changes in logic, only some additional type hints that would required by the next commit
Changes in generated code (see the file attached to PR): AdjacentlyTagged, Untagged, Mixed: Tuple0: tuple(0) -> unit Tuple2as0: tuple(0) -> unit Tuple2as1: tuple(1) -> newtype Tuple2as0Default: tuple(0) -> unit Tuple2as1Default: tuple(1) -> newtype Tuple2as0With: tuple(0) -> unit Tuple2as1With: tuple(1) -> newtype
…djacently tagged and untagged enums serde-rs#2465 maked such deserialization possible
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is continuation of #2520 expanded for enums. Create a draft PR just to see how it could look. It implements suggestions from #2520.
It is still unfinished, I want to check more situations