diff options
| author | bors <bors@rust-lang.org> | 2024-07-25 20:31:29 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-07-25 20:31:29 +0000 |
| commit | 533c377950283932ecb6a5af9fe226b8514d292b (patch) | |
| tree | 77bc347e4b5efa9425ff5f667b5764cf57aa2a78 /tests/codegen/patchable-function-entry/patchable-function-entry-one-flag.rs | |
| parent | 062b66d45c16b56b0c9f2fe0596a1a8b48e57505 (diff) | |
| parent | e9852cc7c9852c4a351ee8a67edfe4f553f0f11c (diff) | |
| download | rust-533c377950283932ecb6a5af9fe226b8514d292b.tar.gz rust-533c377950283932ecb6a5af9fe226b8514d292b.zip | |
Auto merge of #12473 - Kobzol:assigning-clones-deref, r=Alexendoo
Fix handling of `Deref` in `assigning_clones`
The `assigning_clones` lint had a special case for producing a bit nicer code for mutable references:
```rust
fn clone_function_lhs_mut_ref(mut_thing: &mut HasCloneFrom, ref_thing: &HasCloneFrom) {
*mut_thing = Clone::clone(ref_thing);
}
//v
fn clone_function_lhs_mut_ref(mut_thing: &mut HasCloneFrom, ref_thing: &HasCloneFrom) {
Clone::clone_from(mut_thing, ref_thing);
}
```
However, this could [break](https://github.com/rust-lang/rust-clippy/issues/12437) when combined with `Deref`.
This PR removes the special case, so that the generated code should work more generally. Later we can improve the detection of `Deref` and put the special case back in a way that does not break code.
Fixes: https://github.com/rust-lang/rust-clippy/issues/12437
r? `@blyxyas`
changelog: [`assigning_clones`]: change applicability to `Unspecified` and fix a problem with `Deref`.
Diffstat (limited to 'tests/codegen/patchable-function-entry/patchable-function-entry-one-flag.rs')
0 files changed, 0 insertions, 0 deletions
