Warning users when lacking a Clone impl due to imperfect derive
Rust Internals [Unofficial]
May 29, 2026
For reference, the current output is
error[E0277]: the trait bound `Foo<DefaultNotClone>: Clone` is not satisfied
--> src/main.rs:10:9
|
10 | bar(Foo::<DefaultNotClone>::default());
| --- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Clone` is not implemented for `Foo<DefaultNotClone>`
| |
| required by a bound introduced by this call
|
note: required for `Foo<DefaultNotClone>` to implement `Clone`
--> src/main.rs:2:8
|
1 | #[derive(Default, Clone)]
| ----- in this derive macro expansion
2 | struct Foo<T>(std::marker::PhantomData<T>);
| ^^^ - type parameter would need to implement `Clone`
= help: consider manually implementing `Clone` to avoid undesired bounds
note: required by a bound in `bar`
--> src/main.rs:7:11
|
7 | fn bar<T: Clone>(_: T) {}
| ^^^^^ required by this bound in `bar`
help: consider borrowing here
|
10 | bar(&Foo::<DefaultNotClone>::default());
| +
Discussion in the ATmosphere