Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upavoid having two distinct systems for copying #17884
Comments
thestinger
added
A-typesystem
I-nominated
labels
Oct 9, 2014
This comment has been minimized.
This comment has been minimized.
|
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 |
This comment has been minimized.
This comment has been minimized.
|
that's a good point |
This comment has been minimized.
This comment has been minimized.
|
I don't believe we should block 1.0 on this. |
This comment has been minimized.
This comment has been minimized.
|
Assigning P-high, not 1.0. (Team collectively agreed that we can debate how to resolve this, but it should not block 1.0.) |
pnkfelix
added
P-medium
and removed
I-nominated
labels
Oct 9, 2014
This comment has been minimized.
This comment has been minimized.
|
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. |
This comment has been minimized.
This comment has been minimized.
|
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? |
This comment has been minimized.
This comment has been minimized.
zwarich
commented
Oct 10, 2014
I think that RFC only includes negative impls, meaning that a type can opt out of a default trait. |
This comment has been minimized.
This comment has been minimized.
|
On Fri, Oct 10, 2014 at 08:48:42AM -0700, Ben Striegel wrote:
It's not the only problem the same thing applies to
|
This comment has been minimized.
This comment has been minimized.
|
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 ( |
glaebhoerl
referenced this issue
Nov 6, 2014
Closed
use correct naming for the comparison traits and add trait inheritance #12517
japaric
referenced this issue
Nov 6, 2014
Closed
Support multiple blanket impls with differing bounds for traits #442
This comment has been minimized.
This comment has been minimized.
|
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. |
steveklabnik
closed this
Feb 16, 2015
This was referenced Mar 4, 2015
This comment has been minimized.
This comment has been minimized.
|
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 |
thestinger commentedOct 9, 2014
Since
Copydoesn't result in an automaticCloneimplementation, there are two entirely separate systems for doing copies. There are many types providingCopywithout a correspondingCloneimplementation and nothing enforces thatCloneperforms the same operation.Ideally, the trait system could allow an implementation of
CloneforT: Copywithout 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++.