about summary refs log tree commit diff
path: root/src/docs/unit_cmp.txt
diff options
context:
space:
mode:
authorPhilipp Krones <hello@philkrones.com>2022-09-09 13:36:26 +0200
committerPhilipp Krones <hello@philkrones.com>2022-09-09 13:36:26 +0200
commit98bf99e2f8cf8b357d63a67ce67d5fc5ceef8b3c (patch)
tree9737ff22b257f29282e7538d9ecb264451a3c1c0 /src/docs/unit_cmp.txt
parent854f751b263dfac06dc3f635f8a9f92b8bc51da6 (diff)
Merge commit 'b52fb5234cd7c11ecfae51897a6f7fa52e8777fc' into clippyup
Diffstat (limited to 'src/docs/unit_cmp.txt')
-rw-r--r--src/docs/unit_cmp.txt33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/docs/unit_cmp.txt b/src/docs/unit_cmp.txt
new file mode 100644
index 00000000000..6f3d62010dc
--- /dev/null
+++ b/src/docs/unit_cmp.txt
@@ -0,0 +1,33 @@
+### What it does
+Checks for comparisons to unit. This includes all binary
+comparisons (like `==` and `<`) and asserts.
+
+### Why is this bad?
+Unit is always equal to itself, and thus is just a
+clumsily written constant. Mostly this happens when someone accidentally
+adds semicolons at the end of the operands.
+
+### Example
+```
+if {
+    foo();
+} == {
+    bar();
+} {
+    baz();
+}
+```
+is equal to
+```
+{
+    foo();
+    bar();
+    baz();
+}
+```
+
+For asserts:
+```
+assert_eq!({ foo(); }, { bar(); });
+```
+will always succeed
\ No newline at end of file