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

Put ArchiveCopy behind a feature #119

Closed
5 tasks done
djkoloski opened this issue May 2, 2021 · 3 comments
Closed
5 tasks done

Put ArchiveCopy behind a feature #119

djkoloski opened this issue May 2, 2021 · 3 comments
Labels
language deficiency Blocked on missing language or compiler features
Milestone

Comments

@djkoloski
Copy link
Collaborator

djkoloski commented May 2, 2021

A major problem with ArchiveCopy types right now is that they may copy uninitialized bytes in their padding to the output. This behavior should be an opt-in feature for performance. There are still some types that can always be safely copied, so the trait needs to be split up.

  • ArchiveCopy needs to be split into ArchiveCopy (auto trait, explicit impl until auto trait is stabilized, this can be copied but may have padding and produce uninitialized memory) and ArchiveCopySafe (explicit impl, this is ArchiveCopy and has no padding).
  • All types implement Archive the exact same way whether they're ArchiveCopy or not. This includes performing field-by-field resolving even for types that are ArchiveCopy.
  • Types that are ArchiveCopy may implement the traits and no more.
  • Optimizations may always take advantage of ArchiveCopySafe types. They may also take advantage of ArchiveCopy types, but only when a feature (copy_unsafe?) is enabled.
  • Derives produce ArchiveCopySafe impls when passed #[archive(copy_safe)].
@djkoloski djkoloski added this to the v0.7 milestone May 2, 2021
@djkoloski djkoloski added enhancement New feature or request language deficiency Blocked on missing language or compiler features and removed enhancement New feature or request labels May 4, 2021
@djkoloski
Copy link
Collaborator Author

Core rewrite done in f438fa3

@djkoloski
Copy link
Collaborator Author

copy_unsafe added in a753588

@djkoloski
Copy link
Collaborator Author

#[archive(copy_safe)] added in b17f121

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
language deficiency Blocked on missing language or compiler features
Projects
None yet
Development

No branches or pull requests

1 participant