mirror of
https://github.com/rust-lang/rust.git
synced 2026-04-27 18:57:42 +03:00
make TrivialClone a #[marker]-trait to keep it from appearing in error messages
This commit is contained in:
@@ -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`.
|
||||
|
||||
@@ -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() {}
|
||||
|
||||
@@ -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`.
|
||||
|
||||
Reference in New Issue
Block a user