-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Do not dereference uninhabited types refs in Clone implementations #3456
Conversation
A reference to an uninhabited type should never be dereferenced: this is UB. `Copy` should not be implemented on such a type, and an upcoming Clippy lint (`uninhabited_reference`) may flag such dereferences as suspicious. Since those types are not structs, they do not need to get `Copy` and `Clone` implementations. A `missing!` macro limits code duplication.
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @JohnTitor (or someone else) soon. Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (
|
Thanks! @bors r+ |
☀️ Test successful - checks-actions, checks-cirrus-freebsd-12, checks-cirrus-freebsd-13, checks-cirrus-freebsd-14 |
This is not quite correct: if the Now, this |
I agree. However, in the context of libc which necessarily deals with a lot of |
Oh I see! Then I totally agree, having these impls is a big footgun. Well the whole thing is quite footgunny but that too |
A reference to an uninhabited type should never be dereferenced: this is UB.
Copy
should not be implemented on such a type, and an upcoming Clippy lint (uninhabited_reference
) may flag suchdereferences as suspicious.
Since those types are not structs, they do not need to get
Copy
andClone
implementations. Amissing!
macro limits code duplication.