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

various small fixes to the derive macros #168

Merged
merged 4 commits into from
Jan 26, 2023

Conversation

Freax13
Copy link
Contributor

@Freax13 Freax13 commented Jan 25, 2023

This pr contributes a few small fixes for the derive macros:

  • parse and emit repr(usize) and repr(isize) on enums
  • fix how the value in the packed attribute is emitted
  • fix deriving CheckedBitPattern on packed structs by avoiding creating references to the fields
  • fix the implementation of derived traits by emitting generics

This can be used with enums.
Previously we emitted the packed attribute with a type suffix for the
value `packed(4u32)`. This is not allowed. Instead we should emit
`packed(4)`.
This is required for packed structs where creating a reference to
fields is not allowed. We can make a copy of the bits because the bits
are `AnyBitPattern` which implies `Copy`.
@Lokathor Lokathor merged commit 2d1f876 into Lokathor:main Jan 26, 2023
@Lokathor Lokathor added semver-patch semver patch change semver-derive We need to update the main crate's use of the derive crate labels Jan 26, 2023
eric-seppanen added a commit to eric-seppanen/bytemuck that referenced this pull request Feb 8, 2025
Derived traits on structs with generic parameters is broken in bytemuck_derive 1.4.0 (Lokathor#168), which can cause builds to fail in confusing ways.

Fixes Lokathor#300.
Lokathor pushed a commit that referenced this pull request Feb 8, 2025
Derived traits on structs with generic parameters is broken in bytemuck_derive 1.4.0 (#168), which can cause builds to fail in confusing ways.

Fixes #300.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver-derive We need to update the main crate's use of the derive crate semver-patch semver patch change
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants