External Publication
Visit Post

Make `#[derive(Copy)]` enough for both `Clone` and `Copy`

Rust Internals [Unofficial] June 7, 2026
Source

chrefr:

I disagree: I might have valid reasons to have custom code in eq() but Eq is still the same. In fact I did that in the past and also saw it in other places.

You can do this for Eq since it is just a marker trait. Doing this for PartialOrd or Clone would be against the contract of those traits, and a logic error. Even in the Eq case, your intent is better expressed as impl Eq for T {} instead of derive.

chrefr:

saving typing 7 letters does not justify a serious language and compiler complexity

It is not just saving 7 letters, it can also improve the codegen for Clone:

impl Clone for T { fn clone(&self) -> Self { *self } }

Which either saves the optimizer time, or improve the final program performance. And if it gets done over an edition, it has additional benefit of preventing the mentioned logic error, and it would no longer need complex compiler features.

Discussion in the ATmosphere

Loading comments...