Skip to content

Derive Clone when deriving Copy #934

Closed
@dimbleby

Description

@dimbleby

bindgen almost always implements Clone explicitly, like this:

impl Clone for Foo {
    fn clone(&self) -> Self { *self }
}

I (accidentally!) ran clippy over some autogenerated code and it expressed disappointment that Clone was manually implemented for all sorts of structures on which Copy was derived:

warning: you are implementing `Clone` explicitly on a `Copy` type

And indeed, Clone could be derived in every case, at least for my project.

The code that prevents this is here.

My input header is a plain C header (so certainly no templates). If anything, it almost looks as though that test is exactly backwards, though I expect it's more likely that I simply don't understand what issue is being avoided here...

Anyway, it certainly seems like Clone could be derived a lot more often than it currently is.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions