-
Notifications
You must be signed in to change notification settings - Fork 105
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
Add new trait impls #141
Add new trait impls #141
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: Unaligned
NonZeroU8: Unaligned
NonZeroI8: Unaligned
Option<NonZeroU8>: Unaligned
Option<NonZeroI8>: Unaligned
MaybeUninit<T>: Unaligned
whereT: Unaligned
Previously,
unsafe_impl!
special-casedUnaligned
and emitted a static assertion that the type in question actually had alignment 1. Since this usedcore::mem::align_of
, which only works forSized
types, it was incompatible with adding an impl ofUnaligned
forstr
in this commit. In order to avoid this issue, this commit removes that special-casing, and introduces a newassert_unaligned!
macro. ExistingUnaligned
implementations are modified to also callassert_unaligned!
.assert_unaligned!(str)
is not used sincestr: !Unaligned
.