Add nice compiler error when Copy is missing on error enums and enum ints.
Why
The existing compiler error is not very intuitive. The existing error will still be outputted but a more direct error describing the problem and the fix will be output first.
Before
error[E0507]: cannot move out of `*val` which is behind a shared reference
--> tests/errors/src/lib.rs:15:1
|
15 | #[contracterror]
| ^^^^^^^^^^^^^^^^ move occurs because `*val` has type `Error`, which does not implement the `Copy` trait
|
= note: this error originates in the attribute macro `contracterror` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider cloning the value if the performance cost is acceptable
|
15 | #[contracterror].clone()
| ++++++++
After
error[E0277]: the trait bound `Error: core::marker::Copy` is not satisfied
--> tests/errors/src/lib.rs:15:1
|
15 | #[contracterror]
| ^^^^^^^^^^^^^^^^ the trait `core::marker::Copy` is not implemented for `Error`
|
help: consider annotating `Error` with `#[derive(Copy)]`
|
17 + #[derive(Copy)]
18 | pub enum Error {
|
error[E0507]: cannot move out of `*val` which is behind a shared reference
--> tests/errors/src/lib.rs:15:1
|
15 | #[contracterror]
| ^^^^^^^^^^^^^^^^ move occurs because `*val` has type `Error`, which does not implement the `Copy` trait
|
= note: this error originates in the attribute macro `contracterror` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider cloning the value if the performance cost is acceptable
|
15 | #[contracterror].clone()
| ++++++++
What
Add nice compiler error when Copy is missing on error enums and enum ints.
Why
The existing compiler error is not very intuitive. The existing error will still be outputted but a more direct error describing the problem and the fix will be output first.
Before
After
Close #630