-
Notifications
You must be signed in to change notification settings - Fork 1.7k
[regression in 1.70] [clippy] redundant clone ; cloned value is neither consumed nor mutated #10870
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
Labels
C-bug
Category: Clippy is not doing the correct thing
I-false-positive
Issue: The lint was triggered on code it shouldn't have
Comments
I ran into a similar false positive; this snippet causes the clippy warning on the rust playground: fn main() {
#[derive(Clone, Debug, PartialEq)]
struct Foo { n: usize }
let mut foo = Foo { n: 1 };
let foo2 = foo.clone(); // clippy: redundant clone for this
foo.n = 2;
assert_eq!(foo, foo2);
} The code could be rejigged of course, but the clone here is clearly necessary since the other value is being mutated and we want to keep a copy of the original. |
See also rust-lang/rust#108944 (comment) |
bors
added a commit
that referenced
this issue
Jun 5, 2023
Move `redundant_clone` to `nursery` changelog: [`redundant_clone`]: Move to `nursery` A bunch of FPs in `redundant_clone` have sprung up after upstream MIR changes: rust-lang/rust#108944 - #10870 - #10577 - #10545 - #10517 r? `@flip1995`
@rustbot label I-false-positive C-bug |
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-positive
Issue: The lint was triggered on code it shouldn't have
Code
Current output
Desired output
Rationale and extra context
This is what the compiler says without the clone:
Other cases
No response
Anything else?
No response
The text was updated successfully, but these errors were encountered: