about summary refs log tree commit diff
path: root/src/rustllvm/RustWrapper.cpp
diff options
context:
space:
mode:
authorAlex Burka <aburka@seas.upenn.edu>2016-02-03 19:40:59 -0500
committerAlex Burka <aburka@seas.upenn.edu>2016-04-26 13:49:29 -0400
commit9249e6a1e2ef57bb6e329e6477beed31647236b1 (patch)
tree7c95b5476a6fa184d8fac7afaf11084762a1e719 /src/rustllvm/RustWrapper.cpp
parent42ea682fc495b6ec362db0aafba69e56c7aa0a9c (diff)
downloadrust-9249e6a1e2ef57bb6e329e6477beed31647236b1.tar.gz
rust-9249e6a1e2ef57bb6e329e6477beed31647236b1.zip
shallow Clone for #[derive(Copy,Clone)]
Changes #[derive(Copy, Clone)] to use a faster impl of Clone when
both derives are present, and there are no generics in the type.

The faster impl is simply returning *self (which works because the
type is also Copy). See the comments in libsyntax_ext/deriving/clone.rs
for more details.

There are a few types which are Copy but not Clone, in violation
of the definition of Copy. These include large arrays and tuples. The
very existence of these types is arguably a bug, but in order for this
optimization not to change the applicability of #[derive(Copy, Clone)],
the faster Clone impl also injects calls to a new function,
core::clone::assert_receiver_is_clone, to verify that all members are
actually Clone.

This is not a breaking change, because pursuant to RFC 1521, any type
that implements Copy should not do any observable work in its Clone
impl.
Diffstat (limited to 'src/rustllvm/RustWrapper.cpp')
0 files changed, 0 insertions, 0 deletions