Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

incorrect_clone_impl_on_copy_type #112

Open
vitvakatu opened this issue Jul 3, 2023 · 2 comments · May be fixed by #114
Open

incorrect_clone_impl_on_copy_type #112

vitvakatu opened this issue Jul 3, 2023 · 2 comments · May be fixed by #114
Labels
bug The crate does not work as expected

Comments

@vitvakatu
Copy link

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

@vitvakatu vitvakatu added the bug The crate does not work as expected label Jul 3, 2023
@vitvakatu vitvakatu changed the title Title (eg. attribute X does not work as expected on Mondays) incorrect_clone_impl_on_copy_type Jul 3, 2023
@ia0
Copy link

ia0 commented Aug 11, 2023

There's the same issue with PartialOrd and clippy::incorrect_partial_ord_impl_on_ord_type.

@popzxc
Copy link

popzxc commented Aug 22, 2023

Looking at this issue, probably the fix is to add #[automatically_derived] on generated trait implementations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug The crate does not work as expected
Projects
None yet
3 participants