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

make Copy: Clone #23790

Closed
nikomatsakis opened this issue Mar 27, 2015 · 18 comments · Fixed by #23860
Closed

make Copy: Clone #23790

nikomatsakis opened this issue Mar 27, 2015 · 18 comments · Fixed by #23860
Milestone

Comments

@nikomatsakis
Copy link
Contributor

It really makes sense for Clone to be a supertrait of Copy -- Copy is a refinement of Clone where memcpy suffices, basically. I've got a branch handling most of this, though it requires adding a lot of #[derive(Copy, Clone)] sort of things.

@nikomatsakis
Copy link
Contributor Author

cc @aturon @alexcrichton

@nikomatsakis
Copy link
Contributor Author

triage: P-backcompat-lang (1.0 beta)

@Gankra
Copy link
Contributor

Gankra commented Mar 27, 2015

💖 ✨ ✨ ✨

@nikomatsakis
Copy link
Contributor Author

@gankro I'm in the tedious process of adding clone impls to run-pass tests right now... woohoo...

@Gankra
Copy link
Contributor

Gankra commented Mar 27, 2015

I'm sure this is what has been causing all the spurious buildbot failures.

@alexcrichton
Copy link
Member

though it requires adding a lot of #[derive(Copy, Clone)] sort of things.

Does this mean that we have many Copy things which are not Clone today?

@aturon
Copy link
Member

aturon commented Mar 27, 2015

I'm very happy with this pragmatic way of resolving the Copy/Clone dichotomy.

@barosl
Copy link
Contributor

barosl commented Mar 28, 2015

Does this mean the types with Clone will be implicitly copied, when they were previously moved? Isn't this confusing to move semantics?

@tomjakubowski
Copy link
Contributor

@barosl I don't think so, I think it just means that for a type to impl Copy it must also impl Clone.

@bombless
Copy link
Contributor

Yeah I guess #[derive(Copy, Clone)] will keep as-is, while some #[derive(Copy)] will trigger error.

@Kimundi
Copy link
Member

Kimundi commented Mar 30, 2015

Sounds like a simple solution, I like it!

@nikomatsakis
Copy link
Contributor Author

@alexcrichton

Does this mean that we have many Copy things which are not Clone today?

yes, yes, it does. Not so much in the libraries, I don't think, though there as well.

@nikomatsakis
Copy link
Contributor Author

@gankro

I'm sure this is what has been causing all the spurious buildbot failures.

Um, what? (I have no idea what you mean...)

@nikomatsakis
Copy link
Contributor Author

@alexcrichton see #23860

@ghost
Copy link

ghost commented Mar 30, 2015

Does it make sense to consider how ToOwned fits into the picture here too? I know it's potentially unrelated but the current interaction between Clone and ToOwned when defining new data structures that hold Cow things is a bit awkward due to impl<T> ToOwned for T where T: Clone.

@bombless
Copy link
Contributor

Does it make sense to consider how ToOwned fits into the picture here too?

I think now ToOwned automatically turn &T and &mut T into T (when T: Copy) and that makes sense.

@aturon
Copy link
Member

aturon commented Mar 30, 2015

@freebroccolo

Does it make sense to consider how ToOwned fits into the picture here too? I know it's potentially unrelated but the current interaction between Clone and ToOwned when defining new data structures that hold Cow things is a bit awkward due to impl<T> ToOwned for T where T: Clone.

I've been vaguely uneasy about the relationship between ToOwned and Clone for a while, but I hadn't quite realized that implication of the blanket impl.

Do you have any thoughts on the direction here? I could imagine removing the blanket impl of ToOwned, although I'm not sure exactly what the fallout would be.

@Gankra
Copy link
Contributor

Gankra commented Mar 30, 2015

Niko: just goofin' around! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants