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

redundant-clone: false positive with assert_eq!() #5973

Closed
djc opened this issue Aug 27, 2020 · 1 comment · Fixed by #7011
Closed

redundant-clone: false positive with assert_eq!() #5973

djc opened this issue Aug 27, 2020 · 1 comment · Fixed by #7011
Labels
C-bug Category: Clippy is not doing the correct thing E-hard Call for participation: This a hard problem and requires more experience or effort to work on I-suggestion-causes-error Issue: The suggestions provided by this Lint cause an ICE/error when applied T-MIR Type: This lint will require working with the MIR

Comments

@djc
Copy link
Contributor

djc commented Aug 27, 2020

I tried this code:

fn main() {
    let foo = Some("bar".to_string());
    assert_eq!(foo.clone(), None, "not equal {}", foo.unwrap());
}

I expected to see this happen: no lints

Instead, this happened: got a redundant-clone warning.

This seems similar to #5700 or #5595, but maybe not quite the same?

Meta

  • cargo clippy -V: 0.0.212 (2020-08-26 2d8a3b9)
  • rustc -Vv:
rustc 1.45.2 (d3fb005a3 2020-07-31)
binary: rustc
commit-hash: d3fb005a39e62501b8b0b356166e515ae24e2e54
commit-date: 2020-07-31
host: x86_64-apple-darwin
release: 1.45.2
LLVM version: 10.0

(I wonder if the number of false positives reported here are contributing to redudant clone also being relatively high on the commonly ignored lints list from #5418.)

@djc djc added the C-bug Category: Clippy is not doing the correct thing label Aug 27, 2020
@ebroto ebroto added E-hard Call for participation: This a hard problem and requires more experience or effort to work on I-suggestion-causes-error Issue: The suggestions provided by this Lint cause an ICE/error when applied T-MIR Type: This lint will require working with the MIR labels Aug 27, 2020
@flip1995
Copy link
Member

(I wonder if the number of false positives reported here are contributing to redudant clone also being relatively high on the commonly ignored lints list from #5418.)

That is probably because the redundant_clone lint was riddled with FPs before the rewrite to a MIR lint, which got rid of even more annoying FPs than the ones that occur now.

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 E-hard Call for participation: This a hard problem and requires more experience or effort to work on I-suggestion-causes-error Issue: The suggestions provided by this Lint cause an ICE/error when applied T-MIR Type: This lint will require working with the MIR
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants