-
Couldn't load subscription status.
- Fork 13.9k
trait-based serialization and auto-serialization #3520
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
Conversation
|
I just noticed that generic types aren't properly auto-serializing. Regular types seem fine. I'll try to get that fixed and add some tests tomorrow. |
|
I've fixed the generic type issues, added temporary prettyprint2 and ebml2 libraries, and a test. We'll need a snapshot before I can convert everything over to the trait-based approach. |
This will need a snapshot before we can convert ebml and rustc to use the new-style serialization.
Unfortunately this trips over issue (rust-lang#3585), where auto-ref isn't playing nicely with @t implementations. Most serializers don't care, but prettyprint2 won't properly display "@" until rust-lang#3585 is fixed.
This will help with the auto_serialize2 migration. We have to change ident from a type alias to uint into a unique type. We need to use a struct instead of a "enum ident = token::str_num" because structs support constants, but newtypes do not.
|
Rebased and landed, thanks. |
use filter by hash when first rendering
josh rustc-pull: check that no new root commits get created A second root was a bad sign in Miri (judging from the description in rust-lang/miri#2583) and seems to be a [bad sign in RA](rust-lang/rust-analyzer#17025 (comment)). So let's add this to the sanity checks.
josh rustc-pull: check that no new root commits get created A second root was a bad sign in Miri (judging from the description in rust-lang/miri#2583) and seems to be a [bad sign in RA](rust-lang/rust-analyzer#17025 (comment)). So let's add this to the sanity checks.
This adds trait-based serialization and auto-serialization. It's parallel with the old serialization library to help with the migration. This has the same approach as the old function-based one, just with traits. Because of this, we can simplify down auto-serialization to handling just records, structs, and enums. Everything else can be implemented in the library.
There are some downsides to the trait-based approach though:
serialization2.rsif we want to automatically support more than 5 argument tuples.#[auto_serialize]requires this preamble at the top of the file, which would be nice to auto-generate.pureeverywhere, because serializers might not be pure. I could change theserializesignature tofn serialize<S: Serializer>(&mut self) { ... }but then everything that will be serialized must be stored in alet mut ...slot. Oddly enough the old function-based approach does not have this problem.