incorrect_clone_impl_on_copy_type
vitvakatu opened this issue · 2 comments
vitvakatu commented
Describe the bug
Derivative
proc-macro triggers clippy lint https://rust-lang.github.io/rust-clippy/master/index.html#/incorrect_clone_impl_on_copy_type on the latest nightly.
error: incorrect implementation of `clone` on a `Copy` type
--> src/lib.rs:4:10
|
4 | #[derive(Derivative)]
| ^^^^^^^^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#incorrect_clone_impl_on_copy_type
= note: `#[deny(clippy::incorrect_clone_impl_on_copy_type)]` on by default
= note: this error originates in the derive macro `Derivative` (in Nightly builds, run with -Z macro-backtrace for more info)
error: could not compile `test_derivative` (lib) due to previous error
To Reproduce
Cargo.toml:
[package]
name = "test_derivative"
version = "0.1.0"
edition = "2021"
[dependencies]
derivative = "2.2.0"
rust-toolchain.toml
[toolchain]
channel = "nightly-2023-07-03"
components = ["clippy", "rustfmt"]
profile = "default"
src/lib.rs
use derivative::Derivative;
use std::marker::PhantomData;
#[derive(Derivative)]
#[derivative(Copy(bound = ""))]
#[derivative(Clone(bound = ""))]
pub struct Id<T> {
value: u32,
marker: PhantomData<T>,
}
Expected behavior
No clippy lint triggered.
Errors
See above
Version (please complete the following information):
Please include the output of the following commands, and any other version you think is relevant:
❯ rustup --version
rustup 1.25.1 (bb60b1e89 2022-07-12)
info: This is the version for the rustup toolchain manager, not the rustc compiler.
info: The currently active `rustc` version is `rustc 1.72.0-nightly (839e9a6e1 2023-07-02)`
❯ cargo --version
cargo 1.72.0-nightly (5b377cece 2023-06-30)
❯ rustc --version
rustc 1.72.0-nightly (839e9a6e1 2023-07-02)
- Version of
derivative
: 2.2.0
Additional context
None
ia0 commented
There's the same issue with PartialOrd
and clippy::incorrect_partial_ord_impl_on_ord_type
.
popzxc commented
Looking at this issue, probably the fix is to add #[automatically_derived]
on generated trait implementations.