-
Notifications
You must be signed in to change notification settings - Fork 107
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
Rename only_derive_is_allowed_to_implement_this_trait
#287
Comments
Why not make it an unsafe trait? |
They're all unsafe; the function exists to discourage users from implementing the traits manually and steering them towards the derive. |
Ah, I see. In that case wouldn't the |
My experience has been that many programmers aren't very familiar with |
Rust 1.66+ have this error message which should help to reduce the possibility that someone just sticks
It ultimately should be the responsibility of the one who writes The use case that I have that needs manually implementation is I want to add |
Ah, so you can use this technique to get the derives to work. Bitflags also already supports some external crates, so you could probably put up a PR to add zerocopy support. It's already been discussed in a few places. |
Thanks for the pointer! I wasn't aware that this is possible now with bitflags 2. |
np! Definitely let me know if you end up submitting something upstream because I know of other folks who'd love to make use of it. Also I left this comment, which I suspect will be met with "yeah we know, but unfortunately that doesn't work for these reasons", but maybe we'll get lucky and that'll go somewhere. |
I tried the linked technique and zerocopy works now, but I don't have the |
Since our custom derives are not intelligent enough to accept all types for which an unsafe trait impl would be sound, users may in some cases need to implement a trait manually. We should rename
only_derive_is_allowed_to_implement_this_trait
to something that conveys less of "you aren't supposed to do this" and more "this is dangerous and you'd better know what you're doing and be sure that you need to do this and can't just use the derives".Since some users may already have manual impls, this is unfortunately a breaking change.
The text was updated successfully, but these errors were encountered: