# Making Copy a subtrait of Clone (PR 23860)

**URL:** <https://internals.rust-lang.org/t/making-copy-a-subtrait-of-clone-pr-23860/1777>\
**Category:** Uncategorized\
**Created:** [March 30, 2015, 7:23pm UTC](https://internals.rust-lang.org/t/making-copy-a-subtrait-of-clone-pr-23860/1777 "2015-03-30T19:23:06Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![nikomatsakis](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/nikomatsakis/32/5410_2.png) [@nikomatsakis](https://internals.rust-lang.org/u/nikomatsakis)\
**Post date:** [March 30, 2015, 7:23pm UTC](https://internals.rust-lang.org/t/making-copy-a-subtrait-of-clone-pr-23860/1777/1 "2015-03-30T19:23:06Z")

</div>

I wanted to draw people’s attention to [PR 23860](https://github.com/rust-lang/rust/pull/23860) that makes `Copy` a subtrait of `Clone` (as originally proposed in [issue 23790](https://github.com/rust-lang/rust/issues/23790)). This codifies the original intention that `Copy` is a refinement of `Clone`: that is, `Copy` indicates a type that can be cloned just by using a simple memcpy. In fact, making this change revealed many bugs in the standard library where types implemented only `Copy` and not `Clone`, which would have prevented those types from being used in generic APIs based on `Clone`. Another nice benefit of this is that it permits generic APIs to begin as `T: Copy` but later migrate to `T: Clone` if it is determined that the additional genericity outweights the potential performance hazard (this could be useful as a compromise for [RFC 839](https://github.com/rust-lang/rfcs/pull/839), for example).

The primary downside of this change is that it requires modifying `#[deriving(Copy)]` to `#[deriving(Copy, Clone)]`; however, there are plans to modify deriving so that `#[deriving(Copy)]` implies an impl of `Clone` as well. Because that is a somewhat controversial decision, the idea was to propose that change separately.

Ideally, PR 23860 would go through the RFC process, but it’s a breaking change that really ought to happen before beta, and there’s just not time left. Fortunately, this change is merely codifying the expected relationship between the two traits more formally. But I still wanted to alert everyone to the change and get your opinion. Please feel free to comment here or on the PR. Thanks.

---

<div class="post-metadata">

**Author:** ![stebalien](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/stebalien/32/228_2.png) [@stebalien](https://internals.rust-lang.org/u/stebalien)\
**Post date:** [March 30, 2015, 8:31pm UTC](https://internals.rust-lang.org/t/making-copy-a-subtrait-of-clone-pr-23860/1777/2 "2015-03-30T20:31:23Z")

</div>

👍 assuming it doesn’t cause any noticeable binary bloat. I can’t see any reason to impl Copy but not Clone. Although, you might want to revisit this if we ever get specialization/default impls:

```rust
default<T> impl Clone for T: Copy {
    fn clone(&self) -> T { self }
}

```

---

<div class="post-metadata">

**Author:** ![nikomatsakis](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/nikomatsakis/32/5410_2.png) [@nikomatsakis](https://internals.rust-lang.org/u/nikomatsakis)\
**Post date:** [March 25, 2019, 8:24am UTC](https://internals.rust-lang.org/t/making-copy-a-subtrait-of-clone-pr-23860/1777/3 "2019-03-25T08:24:08Z")

</div>

Closed on March 25, 2019, 8:24am UTC

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
