Closed
Description
Code
#[derive(Clone, Copy)]
#[derive(Clone, Copy)]
enum E {}
Current output
error[E0119]: conflicting implementations of trait `Clone` for type `E`
--> src/lib.rs:2:10
|
1 | #[derive(Clone, Copy)]
| ----- first implementation here
2 | #[derive(Clone, Copy)]
| ^^^^^ 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 `Copy` for type `E`
--> src/lib.rs:2:17
|
1 | #[derive(Clone, Copy)]
| ---- first implementation here
2 | #[derive(Clone, Copy)]
| ^^^^ conflicting implementation for `E`
|
= note: this error originates in the derive macro `Copy` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0507]: cannot move out of `*self` which is behind a shared reference
--> src/lib.rs:2:10
|
2 | #[derive(Clone, Copy)]
| ^^^^^ move occurs because `*self` has type `E`, which does not implement the `Copy` trait
|
note: if `E` implemented `Clone`, you could clone the value
--> src/lib.rs:3:1
|
2 | #[derive(Clone, Copy)]
| ----- you could clone this value
3 | enum E {}
| ^^^^^^ consider implementing `Clone` for this type
= note: this error originates in the derive macro `Clone` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0507]: cannot move out of `*self` which is behind a shared reference
--> src/lib.rs:1:10
|
1 | #[derive(Clone, Copy)]
| ^^^^^ move occurs because `*self` has type `E`, which does not implement the `Copy` trait
|
note: if `E` implemented `Clone`, you could clone the value
--> src/lib.rs:3:1
|
1 | #[derive(Clone, Copy)]
| ----- you could clone this value
2 | #[derive(Clone, Copy)]
3 | enum E {}
| ^^^^^^ consider implementing `Clone` for this type
= note: this error originates in the derive macro `Clone` (in Nightly builds, run with -Z macro-backtrace for more info)
Desired output
error[E0119]: conflicting implementations of trait `Clone` for type `E`
--> src/lib.rs:2:10
|
1 | #[derive(Clone, Copy)]
| ----- first implementation here
2 | #[derive(Clone, Copy)]
| ^^^^^ 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 `Copy` for type `E`
--> src/lib.rs:2:17
|
1 | #[derive(Clone, Copy)]
| ---- first implementation here
2 | #[derive(Clone, Copy)]
| ^^^^ conflicting implementation for `E`
|
= note: this error originates in the derive macro `Copy` (in Nightly builds, run with -Z macro-backtrace for more info)
Rationale and extra context
First encountered this with a macro that automatically derived Clone
and Copy
. The later two errors are pointing to internal implementation details and have wrong spans; they should be removed. They also suggest "consider implementing Clone
for this type", which is nonsense.
Other cases
No response
Rust Version
1.83.0 nightly on playground
Anything else?
No response