-
Notifications
You must be signed in to change notification settings - Fork 13.3k
allow types to specify the kind of serializer they should be used with or carry state #3740
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
Comments
This is a prereq to #3738, since the |
Also a prereq to fixing #1972. |
It is a little tricky to be sure given the alpha-renaming that has occurred since this bug was filed, but I think the design proposed by Niko in the description has been implemented. The version of The current version of So I think we should be able to close this. I guess I'll want to double check whether the feature is actually being tested. And whether we can indeed fix #3738 and #1972 now. :) |
This is not fully implemented because the deriving mode does not allow you to specify the serializer. |
@nikomatsakis I opened #7229 about that (it suggests a possible solution). |
Visiting for triage; nothing to add. |
De-milestoning, just a bug |
Closing, this appears to be the current design of the |
Right now, the serialization interface requires that the type to be serialized be generic with respect to any sort of serializer:
Unfortunately, some types require context to be serialized, such as
ty::t
orspan
. When doing the original design I had intended that this state would be carried in the serializer, but of course if you must write the serialization function generically that didn't work, so we ended up withast_encode.rs
which does some manual serialization for any type that touchesty::t
. At first this wasn't a lot of stuff but of course it's growing and it's annoying.One way to solve this is to modify the
Serializable
trait as follows:This allows a type to implement
Serializable
only for specific serializers:To really make this work, though, it is also necessary for the
auto_serialize
code to permit generation of an impl that is specialized to a particular serializer, since any struct which containsty::t
values will also only work with RustcSerializer.Another option would be to extend the
Serializable
trait with some kind of state and carry that around, but I think that winds up just being more type parameters without really adding any sort of flexibility.@erickt has done preliminary work but it's hitting an ICE somewhere in the static methods implementation. I haven't tracked down the cause.
The text was updated successfully, but these errors were encountered: