-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Make zero copy safe by default, add account(zero_copy(unsafe))
feature.
#2330
Conversation
@ckamm is attempting to deploy a commit to the coral-xyz Team on Vercel. A member of the Team first needs to authorize it. |
Why not do it by default? It would be interesting to remove all the unsafe code |
That would break backwards compatibility. It'd prefer making the safe option the default, but it is a choice I'd leave up to the anchor maintainers. |
Having talked to armani and robert chen about this a while ago, it's probably best to make this the default and anyone that wants to can manually implement their own unsafe types can do that.
|
The default account(zero_copy) feature unsafe impls the bytemuck traits The new one derives it instead, which runs desired sanity checks like "struct has no padding".
f5835e0
to
33c9a14
Compare
33c9a14
to
d1fe74e
Compare
@Henry-E I've covered some of your suggestions. The existing zero_copy docs already referenced bytemuck::Pod safety restrictions, so I didn't know what to add there.
Could you take care of the rest? |
Sure, thanks very much for all that. I'll look into finishing the rest soon. |
I kind of forgot about this kind of error, where rust wants you to implement traits on arrays of specific lengths. Is this something you've had to deal with @ckamm or is it just the case that you only ever use I can't quite remember but I thought there was some reason that people didn't use |
@Henry-E Use You can't use |
@ckamm that solved it, thanks very much! Another thing that I find kind of annoying but don't really know what to do about is how even though we use a reference to anchor's privately exported bytemuck crate |
…r zero copy types
Glad it helped! I don't know of a way to use the privately exported instance, unfortunately. |
account(zero_copy(unsafe))
feature.
No worries, I think I'll do one more review of this tomorrow morning and then I think it's good to merge. |
One solution is to use a crate alias but i don't know if we really want to overwrite the local crate's bytemuck. Now I'm wondering if we should just make it entirely using the local crate's bytemuck and not worry about whatever version of bytemuck anchor's using. |
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
The default account(zero_copy) feature unsafe impls the bytemuck traits
The new one derives it instead, which runs desired sanity checks like "struct has no padding".