Conversation
|
@djkoloski you may have thoughts here. I don't yet have safety comments for |
|
Maybe you could argue that since |
I was on the fence about taking that approach, but thinking about it more (and reinforced by you suggesting the same), I guess it's basically unthinkable that they would ever change that aspect of the layout of those types. I was thinking that the wording in that documentation is sufficiently weak (it says "is", not "is guaranteed to be" or something similar - it reads as though it could just be saying "in practice"), but I think that's probably not enough of a concern to block this. I'll go with that approach. |
Add the following impls: - `str: Unaligned` - `NonZeroU8: Unaligned` - `NonZeroI8: Unaligned` - `Option<NonZeroU8>: Unaligned` - `Option<NonZeroI8>: Unaligned` - `MaybeUninit<T>: Unaligned` where `T: Unaligned` Previously, `unsafe_impl!` special-cased `Unaligned` and emitted a static assertion that the type in question actually had alignment 1. Since this used `core::mem::align_of`, which only works for `Sized` types, it was incompatible with adding an impl of `Unaligned` for `str` in this commit. In order to avoid this issue, this commit removes that special-casing, and introduces a new `assert_unaligned!` macro. Existing `Unaligned` implementations are modified to also call `assert_unaligned!`. `assert_unaligned!(str)` is not used since `str: !Unaligned`.
de3755b to
426a606
Compare
|
OK done! Ready for review whenever you get a chance. |
Add the following impls: - `str: Unaligned` - `NonZeroU8: Unaligned` - `NonZeroI8: Unaligned` - `Option<NonZeroU8>: Unaligned` - `Option<NonZeroI8>: Unaligned` - `MaybeUninit<T>: Unaligned` where `T: Unaligned` Previously, `unsafe_impl!` special-cased `Unaligned` and emitted a static assertion that the type in question actually had alignment 1. Since this used `core::mem::align_of`, which only works for `Sized` types, it was incompatible with adding an impl of `Unaligned` for `str` in this commit. In order to avoid this issue, this commit removes that special-casing, and introduces a new `assert_unaligned!` macro. Existing `Unaligned` implementations are modified to also call `assert_unaligned!`. `assert_unaligned!(str)` is not used since `str: !Unaligned`.
Add the following impls:
str: UnalignedNonZeroU8: UnalignedNonZeroI8: UnalignedOption<NonZeroU8>: UnalignedOption<NonZeroI8>: UnalignedMaybeUninit<T>: UnalignedwhereT: UnalignedPreviously,
unsafe_impl!special-casedUnalignedand emitted a static assertion that the type in question actually had alignment 1. Since this usedcore::mem::align_of, which only works forSizedtypes, it was incompatible with adding an impl ofUnalignedforstrin this commit. In order to avoid this issue, this commit removes that special-casing, and introduces a newassert_unaligned!macro. ExistingUnalignedimplementations are modified to also callassert_unaligned!.assert_unaligned!(str)is not used sincestr: !Unaligned.