]> git.proxmox.com Git - rustc.git/blame - src/tools/clippy/src/docs/self_assignment.txt
New upstream version 1.66.0+dfsg1
[rustc.git] / src / tools / clippy / src / docs / self_assignment.txt
CommitLineData
f2b60f7d
FG
1### What it does
2Checks for explicit self-assignments.
3
4### Why is this bad?
5Self-assignments are redundant and unlikely to be
6intentional.
7
8### Known problems
9If expression contains any deref coercions or
10indexing operations they are assumed not to have any side effects.
11
12### Example
13```
14struct Event {
15 x: i32,
16}
17
18fn copy_position(a: &mut Event, b: &Event) {
19 a.x = a.x;
20}
21```
22
23Should be:
24```
25struct Event {
26 x: i32,
27}
28
29fn copy_position(a: &mut Event, b: &Event) {
30 a.x = b.x;
31}
32```