summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/src/docs/self_assignment.txt
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/tools/clippy/src/docs/self_assignment.txt32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/tools/clippy/src/docs/self_assignment.txt b/src/tools/clippy/src/docs/self_assignment.txt
new file mode 100644
index 000000000..ea60ea077
--- /dev/null
+++ b/src/tools/clippy/src/docs/self_assignment.txt
@@ -0,0 +1,32 @@
+### What it does
+Checks for explicit self-assignments.
+
+### Why is this bad?
+Self-assignments are redundant and unlikely to be
+intentional.
+
+### Known problems
+If expression contains any deref coercions or
+indexing operations they are assumed not to have any side effects.
+
+### Example
+```
+struct Event {
+ x: i32,
+}
+
+fn copy_position(a: &mut Event, b: &Event) {
+ a.x = a.x;
+}
+```
+
+Should be:
+```
+struct Event {
+ x: i32,
+}
+
+fn copy_position(a: &mut Event, b: &Event) {
+ a.x = b.x;
+}
+``` \ No newline at end of file