about summary refs log tree commit diff
path: root/src/docs/needless_update.txt
diff options
context:
space:
mode:
Diffstat (limited to 'src/docs/needless_update.txt')
-rw-r--r--src/docs/needless_update.txt30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/docs/needless_update.txt b/src/docs/needless_update.txt
new file mode 100644
index 00000000000..82adabf6482
--- /dev/null
+++ b/src/docs/needless_update.txt
@@ -0,0 +1,30 @@
+### What it does
+Checks for needlessly including a base struct on update
+when all fields are changed anyway.
+
+This lint is not applied to structs marked with
+[non_exhaustive](https://doc.rust-lang.org/reference/attributes/type_system.html).
+
+### Why is this bad?
+This will cost resources (because the base has to be
+somewhere), and make the code less readable.
+
+### Example
+```
+Point {
+    x: 1,
+    y: 1,
+    z: 1,
+    ..zero_point
+};
+```
+
+Use instead:
+```
+// Missing field `z`
+Point {
+    x: 1,
+    y: 1,
+    ..zero_point
+};
+```
\ No newline at end of file