Skip to content

redundant_clone false positive #4633

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

Closed
ehuss opened this issue Oct 4, 2019 · 1 comment
Closed

redundant_clone false positive #4633

ehuss opened this issue Oct 4, 2019 · 1 comment

Comments

@ehuss
Copy link
Contributor

ehuss commented Oct 4, 2019

Clippy version: clippy 0.0.212 (648e5b9 2019-10-01)

I'm getting a false-positive for redundant_clone on this line. Here is a semi-reduced example:

#![allow(unused)]
#![warn(clippy::redundant_clone)]

#[derive(Clone)]
struct Version;

struct PackageId {
    inner: &'static PackageIdInner,
}

struct PackageIdInner {
    name: &'static str,
    version: Version,
}

impl PackageId {
    fn foo(name: &'static str, version: Version) {}

    fn bar(self) {
        PackageId::foo(self.inner.name, self.inner.version.clone());
        //                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^ redundant clone
        // Removing clone causes:
        // ERR: cannot move out of `self.inner.version` which is behind a shared reference
    }
}

Some more examples:

@flip1995
Copy link
Member

flip1995 commented Oct 5, 2019

#4509 fixed this, but didn't land in nightly yet. Should be fixed in next nightly.

@flip1995 flip1995 closed this as completed Oct 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants