Uh oh!
There was an error while loading. Please reload this page.
[RFC] Split Copy trait in two traits: Pod and Copy - #23016
Conversation
rust-highfive
commented
Mar 4, 2015
r? @kmcallister (rust_highfive has picked a reviewer for you, use r? to override) |
tbu-
commented
Mar 4, 2015
@japaric Very nice work, thank you! I haven't looked into the details, but do you also derive |
japaric
commented
Mar 4, 2015
No, the plan was to do that in the type system with a blanket impl for implCloneforTwhereT:Pod{fnclone(&self) -> T{// NB safe! this a memcpy of Pod data (no owned/refcounted/`drop`able data here)unsafe{
mem::transmute_copy(self)}}}But! It can't be done right now because it needs negative bounds to handle some coherence problem (overlapping impls). I think it may be possible to do it in syntax extension (have |
bors
commented
Mar 12, 2015
☔ The latest upstream changes (presumably #23162) made this pull request unmergeable. Please resolve the merge conflicts. |
japaric
commented
Mar 20, 2015
Closing, since we are taking the lint route. |
aturon
commented
Mar 20, 2015
@japaric Thanks for pushing this along and raising the discussion! |
fix: resolve assignment lhs in its expression scope
DO NOT MERGE NEEDS AN APPROVED RFC.
Podtrait is used to mark types that can be cloned by simply copying its bytes on the stack.Copytrait is used to mark types that are implictly copyable.Podcan only be derived by structs/enums whose fields are alsoPodCopycan only be derived by types that arePod, i.e.trait Copy: Pod {}#[derive(Copy)]syntax extension now derives both thePodandCopytraits.#[derive(Pod)]syntax extension have been added to derive thePodtraitCell<T>'sT: Copybound has been relaxed toT: Pod, this lets you use it with a wider variety of types like iterators, which are not implicitly copyable.[breaking-change]s
Copytrait, you'll have to manually implementPodas well:impl<T> Copy for MyType<T> {} + impl<T> Pod for MyType<T> {}#![derive(Copy)]expand into two items, it was necessary to change the unstable#[derive]API. This will likely break third-party#[derive]extensions.I plon to finish writing a proper RFC by tomorrow, but here's the current draft.RFC
cc @aturon@nikomatsakis@tbu-
cc #21846