This upgrades the derives from `syn` 1.0 to `syn` 2.0. While the MSRV
for `syn` 2.0 is not Rust 1.56 which is higher than the MSRV of
`bytemuck`, the derives don't fall under the MSRV policy.
Uses the compiler to check that all non-wrapped fields are actually 1-ZSTs,
and uses Zeroable to check that all non-wrapped fields are "conjurable".
Additionally, relaxes the bound of `PhantomData<T: Zeroable>: Zeroable` to all `T: ?Sized`.
* parse `repr(usize)` and `repr(isize)`
This can be used with enums.
* emit packed repr without type suffix
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)`.
* read bits instead of creating reference
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`.
* emit generics on implied traits
* allow deriving traits on unions in some cases
* basic union tests for nopadding and anybitpattern
* implement derives for unions for more traits
* remove Pod and AnyBitPattern derives for unions due to possible unsoundness
* add MaybePod and NoPadding traits
* MaybePod and NoPadding derive macros
* fix doctest
* fmt
* fix bad doc link
* move new casting functions into separate modules
* fmt
* fix doctest and derive test
* remove relaxed module, add anybitpattern
* rename MaybePod to CheckedCastFromPod
* rename checked casting functions
* rework CheckedCastFromPod into CheckedBitPattern
* add anybitpattern derive, fix up other derives
* fix doctest
* fix derive trait of bits type
* export AnyBitPattern derive
* export anybitpattern from traits
* actually export derive macro for AnyBitPattern
* make bits struct pub because of type leaking rules
* allow clippy lint in derive
* add copy bound to CheckedBitPattern
* - replace Pod bounds with NoPadding+AnyBitPattern
- add try and panic versions of checked cast functions
- slightly update docs
* fix derive tests
* - adapt the allocation module cast functions as well
- as part of that, make AnyBitPattern a subtrait of Zeroable
- AnyBitPattern derive also derives Zeroable
* @JakobDegen and @zakarumych nits
* superset -> subset on CheckedBitPattern and NoPadding docs
* derive Debug on generated `Bits` structs, which can be useful for debugging failures
* don't derive debug on spirv target arch
* make it work on 1.34
* merge conflicts
* fix erroneous behavior in doctest
* add basic derive macro for Pod and Zeroable for structs
* add derive macro for TransparentWrapper
* use core::mem::size_of instead of std::mem::size_of in generated code
* cleanup error handling a bit
* remove unneeded iter logic
* remove unneeded clone and order impl
* fix generics
* fix doc typo
Co-authored-by: Lucien Greathouse <me@lpghatguy.com>
* remove unneeded lifetime anotation
* use unreachable for already rejected patch
Co-authored-by: Lucien Greathouse <me@lpghatguy.com>