summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/src/docs/needless_bool.txt
diff options
context:
space:
mode:
Diffstat (limited to 'src/tools/clippy/src/docs/needless_bool.txt')
-rw-r--r--src/tools/clippy/src/docs/needless_bool.txt26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/tools/clippy/src/docs/needless_bool.txt b/src/tools/clippy/src/docs/needless_bool.txt
new file mode 100644
index 000000000..b5c78871f
--- /dev/null
+++ b/src/tools/clippy/src/docs/needless_bool.txt
@@ -0,0 +1,26 @@
+### What it does
+Checks for expressions of the form `if c { true } else {
+false }` (or vice versa) and suggests using the condition directly.
+
+### Why is this bad?
+Redundant code.
+
+### Known problems
+Maybe false positives: Sometimes, the two branches are
+painstakingly documented (which we, of course, do not detect), so they *may*
+have some value. Even then, the documentation can be rewritten to match the
+shorter code.
+
+### Example
+```
+if x {
+ false
+} else {
+ true
+}
+```
+
+Use instead:
+```
+!x
+``` \ No newline at end of file