-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Suggest calling clone on moved values #42446
Comments
(Caution may be warranted, as a comment in borrowck suggests that an earlier implementation of this was more trouble than it was worth.) |
Hmm, that's true. I see why we don't want this necessarily (Rust has clones everywhere!) but I am also concerned about the other side where users don't know about Clone and nothing tells them that it's a possibility. |
I am against this suggestion, because it is far from universal in my experience that |
Yeah, I'm going to close this. It seems that suggesting calling clone isn't the best idea here... |
Ah, actually, yeah, covering this in extended documentation is a good idea... |
Mentoring instructionsExpand the documentation for E0382 when it talks about @nikomatsakis, @Mark-Simulacrum, would it make sense to check for
|
I don't think adding the help would be a good idea. I share @nikomatsakis' concerns over the potential negative impacts, along the lines of "why no auto clone, then?" which would probably be non-ideal for us. I think the extended error description is the perfect place to put this, since newcomers to Rust hopefully are using that as much as possible (do we have any data on this?). |
Fair enough. We can close this ticket then when we expand the error docs.
I don't know if we do, as I haven't seen any code in the compiler to send metrics (but I haven't looked for that either). Now that I think about it, it might be a neat feature to highlight very prominently the |
Mention Clone and refs in --explain E0382 I followed the discussion in rust-lang#42446 and came up with these additions. - Mention references before going into traits. They're probably more likely solutions. - Mention `Clone` before `Copy`. Cloning has wider applicability and `#derive[Copy, Clone]` makes more sense after learning about `Clone`. The language is not great, any suggestions there would be appreciated ✨
Is this fixed by #45082 or do we want more? |
We should add a
help
message indicating that calling clone where the value was moved is a good idea, but we should only do this when the value is cloneable.The text was updated successfully, but these errors were encountered: