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

Make TryFromBytes a super-trait of FromZeros #962

Closed
jswrenn opened this issue Feb 27, 2024 · 1 comment
Closed

Make TryFromBytes a super-trait of FromZeros #962

jswrenn opened this issue Feb 27, 2024 · 1 comment

Comments

@jswrenn
Copy link
Collaborator

jswrenn commented Feb 27, 2024

The TryFromBytes derive for unions requires that Self: NoCell, due to the safety obligations of Ptr::project in its implementation of is_bit_valid. By contrast, the derives for FromZeros and FromBytes on unions do not require Self: NoCell.

We would like to make TryFromBytes a super-trait of FromZeros, but (as we discovered in #952) this mismatch in requirements presents us with a trilemma:

  • don't make TryFromBytes a super-trait of FromZeros
  • find a way to remove the NoCell requirements on the TryFromBytes derive for unions
  • propagate the NoCell requirement on unions to the derives for FromZeros and FromBytes

Short-Term Resolution

We:

  • don't formally make TryFromBytes a super-trait of FromZeros, but we document that this relationship may be required in the future
  • propagate the NoCell requirement on unions to the derives for FromZeros and FromBytes

Making FromZeros: TryFromBytes may create future breakage for customers manually implementing FromZeros, but this workflow is explicitly documented as unsupported.

jswrenn added a commit that referenced this issue Feb 29, 2024
Makes progress on #5

Closes #962

Co-authored-by: Jack Wrenn <[email protected]>
github-merge-queue bot pushed a commit that referenced this issue Feb 29, 2024
Makes progress on #5

Closes #962

Co-authored-by: Jack Wrenn <[email protected]>
@joshlf
Copy link
Member

joshlf commented Mar 1, 2024

Closed by #952

@joshlf joshlf closed this as completed Mar 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants