summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/src/docs/range_minus_one.txt
diff options
context:
space:
mode:
Diffstat (limited to 'src/tools/clippy/src/docs/range_minus_one.txt')
-rw-r--r--src/tools/clippy/src/docs/range_minus_one.txt27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/tools/clippy/src/docs/range_minus_one.txt b/src/tools/clippy/src/docs/range_minus_one.txt
new file mode 100644
index 000000000..fcb96dcc3
--- /dev/null
+++ b/src/tools/clippy/src/docs/range_minus_one.txt
@@ -0,0 +1,27 @@
+### What it does
+Checks for inclusive ranges where 1 is subtracted from
+the upper bound, e.g., `x..=(y-1)`.
+
+### Why is this bad?
+The code is more readable with an exclusive range
+like `x..y`.
+
+### Known problems
+This will cause a warning that cannot be fixed if
+the consumer of the range only accepts a specific range type, instead of
+the generic `RangeBounds` trait
+([#3307](https://github.com/rust-lang/rust-clippy/issues/3307)).
+
+### Example
+```
+for i in x..=(y-1) {
+ // ..
+}
+```
+
+Use instead:
+```
+for i in x..y {
+ // ..
+}
+``` \ No newline at end of file