-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Implicit Copy Lint #9061
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
Comments
Could this lint, if ever implemented, be used to make the following program not compile when
|
If I am reading the code correctly, and if
Is to mean applying the lint only to that single expression, then yes. The
there would be no such problem. |
Yes, that is exactly what I want! When I want copy then I'll use .clone(), otherwise I want it to compile fail instead of bypassing the borrow checker ie. in my code above, I want the This lint would be great! I'd actually use it crate-wide! Thank you for your reply and for suggesting it! |
What it does
An allow-by-default lint to highlight implicit uses of the Copy trait, which has relevance in some kinds of unsafe code. Using it in deny mode would force the programmer to write
.clone()
everywhere they want to copy a value.Lint Name
implicit_copy
Category
correctness
Advantage
Among other things, I suggested it in UnsafeCell should implement the Copy trait #25053 , as a potential solution. There are other cases in unsafe code.
Drawbacks
It will almost always be on allow; the use cases are very rare.
Example
Given a hypothetical
Copy
impl forUnsafeCell
:An example of how this would help:
The text was updated successfully, but these errors were encountered: