Skip to content
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

#[derive(Clone)] should explicitly override clone_from #13281

Closed
huonw opened this issue Apr 3, 2014 · 3 comments
Closed

#[derive(Clone)] should explicitly override clone_from #13281

huonw opened this issue Apr 3, 2014 · 3 comments
Labels
C-enhancement Category: An issue proposing an enhancement or a PR with one. I-slow Issue: Problems and improvements with respect to performance of generated code.

Comments

@huonw
Copy link
Member

huonw commented Apr 3, 2014

This would mean derived clone implementations can reuse the resources of interior types (especially important with types containing things like Vec) when cloning into an already-created instance.

Currently doing this is difficult with how #[deriving] works internally (needs a mutable borrow of the contents of self, and needs to avoid borrowing self for enum variants that mismatch or else the requisite *self = other.clone() implementation won't work).

@steveklabnik
Copy link
Member

Triage: no change that i'm aware of.

@tbu-
Copy link
Contributor

tbu- commented Mar 21, 2017

Seems like we could close this issue (see reasoning in #27939).

@Mark-Simulacrum Mark-Simulacrum added the I-slow Issue: Problems and improvements with respect to performance of generated code. label Jun 13, 2017
@Mark-Simulacrum Mark-Simulacrum added C-enhancement Category: An issue proposing an enhancement or a PR with one. and removed I-papercut labels Jul 20, 2017
@dtolnay dtolnay changed the title #[deriving(Clone)] should explicitly override clone_from #[derive(Clone)] should explicitly override clone_from Dec 3, 2017
@dtolnay
Copy link
Member

dtolnay commented Dec 3, 2017

The reasoning in #27939 still applies as to why this should not be provided by the built-in derive(Clone). A custom derive for clone_from is provided in the derivative crate

@dtolnay dtolnay closed this as completed Dec 3, 2017
Jarcho pushed a commit to Jarcho/rust that referenced this issue Aug 24, 2024
 Trigger [`string_slice`] if expression is reference to `&str`

Close rust-lang#12708
changelog: [`string_slice`]: trigger lint if expression is reference to `&str`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category: An issue proposing an enhancement or a PR with one. I-slow Issue: Problems and improvements with respect to performance of generated code.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants