-
Notifications
You must be signed in to change notification settings - Fork 114
[derive] Support deriving NoCell
#667
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
Conversation
b27e74d
to
644f990
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO: Add tests for the types described in #656 (comment):
Can you expand on a few edge cases here? I'm not totally clear on what "contains" means. Is this
NoCell
?struct R<'a> { field: &'a UnsafeCell<u8>, }...and this?
struct ZLA { field: [UnsafeCell<u8>; 0]; }...and this?
struct CPC { field: PhantomData<UnsafeCell<u8>>; }...and this?
trait Trait { type Assoc; } impl<T> Trait for UnsafeCell<T> { type Assoc = T; } struct CAT<T> where T: NoCell { field: <UnsafeCell<T> as Trait>::Assoc, }...and this?
enum Enum { Uninhabited(!, UnsafeCell<u8>), Inhabited(u8), }
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For testing (and potentially the derive expansion), you might find this macro nifty:
macro_rules! assert_unfreeze {
($ty:ty) => {
const _: () = {
static _assert_unfreeze: Option<$ty> = None;
};
}
}
assert_unfreeze!(u8); // accepted!
assert_unfreeze!(core::cell::UnsafeCell<u8>); // rejected! compilation error!
ea82fcf
to
a5cc3f1
Compare
Makes progress on #251
a5cc3f1
to
3234ced
Compare
Didn't end up needing this, but it's very nifty! |
Makes progress on #251