-
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
avoid having two distinct systems for copying #17884
Comments
This should be fine to do when some of the upgraded coherence stuff lands. The only issue is if there was a type that was Copy that wanted a non-trivial implementation of Clone. I don't expect that to be the case. It would probably also be very poor design if |
that's a good point |
I don't believe we should block 1.0 on this. |
Assigning P-high, not 1.0. (Team collectively agreed that we can debate how to resolve this, but it should not block 1.0.) |
The upgraded coherence stuff would allow a blanket impl like
However, this has a bad interaction with tuple impls, because you would need an impl like:
Without negative bounds, we can't write such an impl. We could imagine adding those though. The other option would be permitting specialization, in which case the tuple impl could be given higher priority than the blanket impl -- however, that has the negative affect that others can override as well. Regarding triage this strikes me as a wart but one we could live with for 1.0. |
Having If the inability to implement In any case...
...aren't negative bounds a part of https://github.com/rust-lang/rfcs/blob/master/active/0003-opt-in-builtin-traits.md? |
I think that RFC only includes negative impls, meaning that a type can opt out of a default trait. |
On Fri, Oct 10, 2014 at 08:48:42AM -0700, Ben Striegel wrote:
It's not the only problem the same thing applies to
|
It might be worth observing that in this case, in a sense, the compiler is being over-conservative: it would actually be OK to allow all of A much harder question is whether this insight can be useful in any way. In a dependently typed language, maybe the compiler could reason about the definitions of the (GHC's type-level functions ( |
Talking with @nikomatsakis on IRC, it would seem that there are enough complications with this that we do not plan on doing it. An RFC might be able to resolve them, but probably not. If anyone feels super strongly about this, please persue one. |
I would like to hear more about these complications, given that this is still a pain point. Even if we don't want a blanket impl, I'm curious if simple making |
Since
Copy
doesn't result in an automaticClone
implementation, there are two entirely separate systems for doing copies. There are many types providingCopy
without a correspondingClone
implementation and nothing enforces thatClone
performs the same operation.Ideally, the trait system could allow an implementation of
Clone
forT: Copy
without introducing problematic conflicts. If that's not possible, then something else should be done to provide a system that's at least as sane as the story in C++.The text was updated successfully, but these errors were encountered: