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

.clone().takes_self_ref() isn't caught by clippy::redundant_clone #9455

Open
kangalio opened this issue Sep 10, 2022 · 0 comments
Open

.clone().takes_self_ref() isn't caught by clippy::redundant_clone #9455

kangalio opened this issue Sep 10, 2022 · 0 comments
Labels
C-bug Category: Clippy is not doing the correct thing I-false-negative Issue: The lint should have been triggered on code, but wasn't

Comments

@kangalio
Copy link

Summary

Code of the form .clone().method(), where method takes &self, has a redundant clone. Clippy should catch this

Lint Name

redundant_clone

Reproducer

I tried this code:

#[derive(Clone)]
struct Foo;
impl Foo {
    fn method(&self) {}
}

fn example(foo: &Foo) {
    foo.clone().method();
}

I expected to see this happen: a warning that the .clone() call is redundant

Instead, this happened: no such warning

Version

rustc 1.63.0 (4b91a6ea7 2022-08-08)
binary: rustc
commit-hash: 4b91a6ea7258a947e59c6522cd5898e7c0a6a88f
commit-date: 2022-08-08
host: x86_64-unknown-linux-gnu
release: 1.63.0
LLVM version: 14.0.5
@kangalio kangalio added C-bug Category: Clippy is not doing the correct thing I-false-negative Issue: The lint should have been triggered on code, but wasn't labels Sep 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: Clippy is not doing the correct thing I-false-negative Issue: The lint should have been triggered on code, but wasn't
Projects
None yet
Development

No branches or pull requests

1 participant