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

[derive] Support TryFromBytes for structs #370

Conversation

joshlf
Copy link
Member

@joshlf joshlf commented Sep 11, 2023

TODO:

  • Should DataExt::fields have a different shape? Extracting field names for enums doesn't really make sense
  • Add SAFETY comments in emitted is_bit_valid impl
  • Do we need to update the TryFromBytes doc comment at all?
  • Lots and lots of tests

Makes progress on #5

@joshlf joshlf force-pushed the try-from-bytes-raw-argument-to-is-bit-valid--derive branch from 0129c61 to 5e660a4 Compare September 11, 2023 19:39
@joshlf joshlf force-pushed the try-from-bytes-raw-argument-to-is-bit-valid--derive-cleanup branch from e82b746 to 8db2922 Compare September 11, 2023 19:39
@joshlf joshlf force-pushed the try-from-bytes-raw-argument-to-is-bit-valid--derive branch from 5e660a4 to 6f2adbd Compare September 11, 2023 22:28
@joshlf joshlf force-pushed the try-from-bytes-raw-argument-to-is-bit-valid--derive-cleanup branch from 8db2922 to 774ddaa Compare September 11, 2023 22:28
@joshlf joshlf force-pushed the try-from-bytes-raw-argument-to-is-bit-valid--derive branch from 6f2adbd to d638597 Compare September 11, 2023 22:52
@joshlf joshlf force-pushed the try-from-bytes-raw-argument-to-is-bit-valid--derive-cleanup branch from 774ddaa to fd9b4c1 Compare September 11, 2023 22:52
@joshlf joshlf force-pushed the try-from-bytes-raw-argument-to-is-bit-valid--derive branch from d638597 to bb5a5ae Compare September 11, 2023 23:05
@joshlf joshlf force-pushed the try-from-bytes-raw-argument-to-is-bit-valid--derive-cleanup branch from fd9b4c1 to 1a330ee Compare September 11, 2023 23:05
@joshlf joshlf force-pushed the try-from-bytes-raw-argument-to-is-bit-valid--derive branch from bb5a5ae to 98942f6 Compare September 11, 2023 23:31
@joshlf joshlf force-pushed the try-from-bytes-raw-argument-to-is-bit-valid--derive-cleanup branch from 1a330ee to 67a18c0 Compare September 11, 2023 23:31
@joshlf joshlf force-pushed the try-from-bytes-raw-argument-to-is-bit-valid--derive branch from 98942f6 to 5b61210 Compare September 12, 2023 00:34
@joshlf joshlf force-pushed the try-from-bytes-raw-argument-to-is-bit-valid--derive-cleanup branch from 67a18c0 to 05e5775 Compare September 12, 2023 00:34
Base automatically changed from try-from-bytes-raw-argument-to-is-bit-valid--derive-cleanup to try-from-bytes-raw-argument-to-is-bit-valid-3-try-transmute-macros September 12, 2023 00:34
@joshlf joshlf force-pushed the try-from-bytes-raw-argument-to-is-bit-valid--derive branch from 5b61210 to 8e079ad Compare September 12, 2023 00:48
@joshlf joshlf changed the title [derive] Support TryFromBytes for structs/unions [derive] Support TryFromBytes for structs Sep 12, 2023
@joshlf joshlf force-pushed the try-from-bytes-raw-argument-to-is-bit-valid--derive branch 2 times, most recently from 1083475 to d838a87 Compare September 12, 2023 01:19
@joshlf joshlf force-pushed the try-from-bytes-raw-argument-to-is-bit-valid-3-try-transmute-macros branch from 1a0b1bb to b8781ee Compare September 12, 2023 01:19
@joshlf joshlf force-pushed the try-from-bytes-raw-argument-to-is-bit-valid--derive branch from d838a87 to 85d0bcb Compare September 12, 2023 01:39
@joshlf joshlf force-pushed the try-from-bytes-raw-argument-to-is-bit-valid-3-try-transmute-macros branch from b8781ee to dc8e0fc Compare September 12, 2023 01:40
@joshlf joshlf force-pushed the try-from-bytes-raw-argument-to-is-bit-valid--derive branch from 85d0bcb to c068ed5 Compare September 12, 2023 02:22
@joshlf joshlf force-pushed the try-from-bytes-raw-argument-to-is-bit-valid-3-try-transmute-macros branch from dc8e0fc to d868b3d Compare September 12, 2023 02:22
@joshlf joshlf force-pushed the try-from-bytes-raw-argument-to-is-bit-valid--derive branch from c068ed5 to f52abdf Compare September 12, 2023 02:48
@joshlf joshlf force-pushed the try-from-bytes-raw-argument-to-is-bit-valid-3-try-transmute-macros branch from d868b3d to c7c950f Compare September 12, 2023 02:49
@joshlf joshlf force-pushed the try-from-bytes-raw-argument-to-is-bit-valid--derive branch 2 times, most recently from c816899 to 9bfd4fa Compare September 12, 2023 03:43
@joshlf joshlf force-pushed the try-from-bytes-raw-argument-to-is-bit-valid-3-try-transmute-macros branch from c7c950f to 41fce8b Compare September 12, 2023 03:44
@joshlf joshlf force-pushed the try-from-bytes-raw-argument-to-is-bit-valid--derive branch from 9bfd4fa to 38e9af7 Compare September 12, 2023 06:16
@joshlf joshlf force-pushed the try-from-bytes-raw-argument-to-is-bit-valid-3-try-transmute-macros branch from 41fce8b to 02895f3 Compare September 12, 2023 06:16
@joshlf joshlf force-pushed the try-from-bytes-raw-argument-to-is-bit-valid--derive branch from 38e9af7 to ac566bc Compare September 12, 2023 15:41
@joshlf joshlf force-pushed the try-from-bytes-raw-argument-to-is-bit-valid-3-try-transmute-macros branch from 83e66cc to 91c9b2b Compare September 19, 2023 02:05
@joshlf joshlf force-pushed the try-from-bytes-raw-argument-to-is-bit-valid--derive branch from a093d6f to f262f98 Compare September 19, 2023 16:31
@joshlf joshlf force-pushed the try-from-bytes-raw-argument-to-is-bit-valid-3-try-transmute-macros branch from 91c9b2b to 7c32984 Compare September 19, 2023 16:32
@joshlf joshlf force-pushed the try-from-bytes-raw-argument-to-is-bit-valid--derive branch from f262f98 to 6de1129 Compare September 19, 2023 16:43
@joshlf joshlf force-pushed the try-from-bytes-raw-argument-to-is-bit-valid-3-try-transmute-macros branch from 7c32984 to dde3280 Compare September 19, 2023 16:43
@joshlf joshlf force-pushed the try-from-bytes-raw-argument-to-is-bit-valid--derive branch from 6de1129 to d19a443 Compare September 19, 2023 18:46
@joshlf joshlf force-pushed the try-from-bytes-raw-argument-to-is-bit-valid-3-try-transmute-macros branch from dde3280 to 91057f7 Compare September 19, 2023 18:46
@joshlf joshlf force-pushed the try-from-bytes-raw-argument-to-is-bit-valid--derive branch from d19a443 to 3dd3531 Compare September 19, 2023 18:57
@joshlf joshlf force-pushed the try-from-bytes-raw-argument-to-is-bit-valid-3-try-transmute-macros branch from 91057f7 to 3008eb5 Compare September 19, 2023 18:58
@joshlf joshlf force-pushed the try-from-bytes-raw-argument-to-is-bit-valid--derive branch from 3dd3531 to 77ef559 Compare September 19, 2023 22:33
@joshlf joshlf force-pushed the try-from-bytes-raw-argument-to-is-bit-valid-3-try-transmute-macros branch from 3008eb5 to 1e309ca Compare September 19, 2023 22:33
TODO:
- Should DataExt::fields have a different shape? Extracting field names
  for enums doesn't really make sense
- Lots and lots of tests
- If we manage to land derive(KnownLayout) first, replace manual impls
  of KnownLayout with the derive
- Is there any way to make sure the code we emit doesn't emit warnings?
  I tested with an earlier version of the code that had lots of code
  smells like pointer coercions that emitted warnings, and even after
  emitting `#[deny(...)]` attributes, I couldn't get code which made use
  of the derive to complain at all - the compiler just happily accepted
  it.
- Update for `is_bit_valid` taking `Ptr` rather than `NonNull`

Makes progress on #5
@joshlf joshlf force-pushed the try-from-bytes-raw-argument-to-is-bit-valid--derive branch from 77ef559 to 9e01587 Compare October 12, 2023 21:41
@joshlf joshlf force-pushed the try-from-bytes-raw-argument-to-is-bit-valid-3-try-transmute-macros branch from 1e309ca to 82d9322 Compare October 12, 2023 21:42
jswrenn added a commit that referenced this pull request Dec 1, 2023
Supersedes #370.

Makes progress on #5.

Co-authored-by: Joshua Liebow-Feeser <hello@joshlf.com>
jswrenn added a commit that referenced this pull request Dec 1, 2023
Supersedes #370.

Makes progress on #5.

Co-authored-by: Joshua Liebow-Feeser <hello@joshlf.com>
jswrenn added a commit that referenced this pull request Dec 1, 2023
Supersedes #370.

Makes progress on #5.

Co-authored-by: Joshua Liebow-Feeser <hello@joshlf.com>
jswrenn added a commit that referenced this pull request Dec 6, 2023
Supersedes #370.

Makes progress on #5.

Co-authored-by: Joshua Liebow-Feeser <hello@joshlf.com>
jswrenn added a commit that referenced this pull request Dec 6, 2023
Supersedes #370.

Makes progress on #5.

Co-authored-by: Joshua Liebow-Feeser <hello@joshlf.com>
jswrenn added a commit that referenced this pull request Dec 7, 2023
Supersedes #370.

Makes progress on #5.

Co-authored-by: Joshua Liebow-Feeser <hello@joshlf.com>
jswrenn added a commit that referenced this pull request Dec 7, 2023
Supersedes #370.

Makes progress on #5.

Co-authored-by: Joshua Liebow-Feeser <hello@joshlf.com>
jswrenn added a commit that referenced this pull request Dec 7, 2023
Supersedes #370.

Makes progress on #5.

Co-authored-by: Joshua Liebow-Feeser <hello@joshlf.com>
jswrenn added a commit that referenced this pull request Dec 7, 2023
Supersedes #370.

Makes progress on #5.

Co-authored-by: Joshua Liebow-Feeser <hello@joshlf.com>
jswrenn added a commit that referenced this pull request Dec 7, 2023
Supersedes #370.

Makes progress on #5.

Co-authored-by: Joshua Liebow-Feeser <hello@joshlf.com>
jswrenn added a commit that referenced this pull request Dec 7, 2023
Supersedes #370.

Makes progress on #5.

Co-authored-by: Joshua Liebow-Feeser <hello@joshlf.com>
jswrenn added a commit that referenced this pull request Dec 8, 2023
Supersedes #370.

Makes progress on #5.

Co-authored-by: Joshua Liebow-Feeser <hello@joshlf.com>
jswrenn added a commit that referenced this pull request Dec 8, 2023
Supersedes #370.

Makes progress on #5.

Co-authored-by: Joshua Liebow-Feeser <hello@joshlf.com>
github-merge-queue bot pushed a commit that referenced this pull request Dec 8, 2023
Supersedes #370.

Makes progress on #5.

Co-authored-by: Joshua Liebow-Feeser <hello@joshlf.com>
@joshlf joshlf closed this Feb 12, 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

Successfully merging this pull request may close these issues.

None yet

1 participant