Make `#[derive(Copy)]` enough for both `Clone` and `Copy`
Rust Internals [Unofficial]
June 7, 2026
chrefr:
The
Clonederive already does that
Interesting, I wasn't aware of that. It seems doesn't work in all cases though, e.g. with a generic parameter I see this:
struct Foo<T> {
a: T,
b: T,
c: T,
}
#[attr = AutomaticallyDerived]
impl <T> ::core::clone::Clone for Foo<T> where T: ::core::clone::Clone {
#[attr = Inline(Hint)]
fn clone(&self)
->
Foo<T> {
Foo {
a: ::core::clone::Clone::clone(&self.a),
b: ::core::clone::Clone::clone(&self.b),
c: ::core::clone::Clone::clone(&self.c) }
}
}
Might be something related to backward compatibility.
chrefr:
Not true, since old editions must still be supported by the compiler.
I meant dropping the original #[rustc_ignore_this_impl_in_case_of_conflict] proposal and doing this only over an edition. That is, #[derive(Copy)] in a new edition is equivalent of both Clone and Copy, and adding another Clone impl (either manually or via derive) is a hard error, and not touching the current editions at all.
Discussion in the ATmosphere