Skip to content
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

de: Make flattened structs and aliases interact correctly. #2160

Closed
wants to merge 2 commits into from

Conversation

jhoobergs
Copy link

Rebased version of #1519

@dtolnay What would be needed to get this merged?

Fixes #1504

@jhoobergs
Copy link
Author

@dtolnay Any thoughts?

@PhotonQuantum
Copy link

So what's the progress of this PR? The related issue has been locked and there's no review activity on this one.

The issue is that FlatStructAccess has no access to the aliases of the struct
it's deserializing.

Ideally we'd try to serialize the key rather than checking whether we're going
to use it before-hand, then actually take the value out, but that happens to be
tricky with the current seed API.

So we need to somehow get the aliased names back to FlatStructAccess. Introduce
a serialize_struct-like API that takes them in a backwards-compatible way. For
parallelism, and since we also support aliases on enum variants, also extend the
struct_variant API in a similar way. I'm open to better ways to fix it, but I
can't think of any other that isn't a breaking change...

Fixes serde-rs#1504.
Copy link
Member

@dtolnay dtolnay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#1519 (review) is still the approach that I would prefer. I guess this got stuck on @emilio (or anyone else) looking into what the practical downsides of that approach might be. As far as I can tell it doesn't cause any issue with bincode.

@dralley
Copy link

dralley commented Mar 7, 2023

#2387 claims to fix #1504 also

Copy link
Member

@dtolnay dtolnay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed a different way by #2387.

@dtolnay dtolnay closed this Mar 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Field aliases do not work in combination with flatten
5 participants