diff --git a/library/core/src/clone.rs b/library/core/src/clone.rs index 4f76abdb7751..eeb26043b39b 100644 --- a/library/core/src/clone.rs +++ b/library/core/src/clone.rs @@ -275,6 +275,10 @@ fn clone_from(&mut self, source: &Self) // its invariant holds whenever `Clone` is implemented, even if the actual // `TrivialClone` bound would not be satisfied because of lifetime bounds. #[rustc_unsafe_specialization_marker] +// If `#[derive(Clone, Clone, Copy)]` is written, there will be multiple +// implementations of `TrivialClone`. To keep it from appearing in error +// messages, make it a `#[marker]` trait. +#[marker] pub const unsafe trait TrivialClone: [const] Clone {} /// Derive macro generating an impl of the trait `Clone`. diff --git a/tests/ui/derives/duplicate-derive-copy-clone-diagnostics.rs b/tests/ui/derives/duplicate-derive-copy-clone-diagnostics.rs index bc88a0e131a8..c4fb620fea4f 100644 --- a/tests/ui/derives/duplicate-derive-copy-clone-diagnostics.rs +++ b/tests/ui/derives/duplicate-derive-copy-clone-diagnostics.rs @@ -6,7 +6,6 @@ #[derive(Copy, Clone)] //~^ ERROR conflicting implementations of trait `Clone` for type `E` //~| ERROR conflicting implementations of trait `Copy` for type `E` -//~| ERROR conflicting implementations of trait `TrivialClone` for type `E` enum E {} fn main() {} diff --git a/tests/ui/derives/duplicate-derive-copy-clone-diagnostics.stderr b/tests/ui/derives/duplicate-derive-copy-clone-diagnostics.stderr index a0274222e78c..b9eb6194f6c4 100644 --- a/tests/ui/derives/duplicate-derive-copy-clone-diagnostics.stderr +++ b/tests/ui/derives/duplicate-derive-copy-clone-diagnostics.stderr @@ -6,16 +6,6 @@ LL | #[derive(Copy, Clone)] LL | #[derive(Copy, Clone)] | ^^^^ conflicting implementation for `E` -error[E0119]: conflicting implementations of trait `TrivialClone` for type `E` - --> $DIR/duplicate-derive-copy-clone-diagnostics.rs:6:16 - | -LL | #[derive(Copy, Clone)] - | ----- first implementation here -LL | #[derive(Copy, Clone)] - | ^^^^^ conflicting implementation for `E` - | - = note: this error originates in the derive macro `Clone` (in Nightly builds, run with -Z macro-backtrace for more info) - error[E0119]: conflicting implementations of trait `Clone` for type `E` --> $DIR/duplicate-derive-copy-clone-diagnostics.rs:6:16 | @@ -24,6 +14,6 @@ LL | #[derive(Copy, Clone)] LL | #[derive(Copy, Clone)] | ^^^^^ conflicting implementation for `E` -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0119`.