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