summaryrefslogtreecommitdiffstats
path: root/compiler/rustc_error_codes/src/error_codes/E0586.md
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/rustc_error_codes/src/error_codes/E0586.md')
-rw-r--r--compiler/rustc_error_codes/src/error_codes/E0586.md29
1 files changed, 29 insertions, 0 deletions
diff --git a/compiler/rustc_error_codes/src/error_codes/E0586.md b/compiler/rustc_error_codes/src/error_codes/E0586.md
new file mode 100644
index 000000000..bc6572eca
--- /dev/null
+++ b/compiler/rustc_error_codes/src/error_codes/E0586.md
@@ -0,0 +1,29 @@
+An inclusive range was used with no end.
+
+Erroneous code example:
+
+```compile_fail,E0586
+fn main() {
+ let tmp = vec![0, 1, 2, 3, 4, 4, 3, 3, 2, 1];
+ let x = &tmp[1..=]; // error: inclusive range was used with no end
+}
+```
+
+An inclusive range needs an end in order to *include* it. If you just need a
+start and no end, use a non-inclusive range (with `..`):
+
+```
+fn main() {
+ let tmp = vec![0, 1, 2, 3, 4, 4, 3, 3, 2, 1];
+ let x = &tmp[1..]; // ok!
+}
+```
+
+Or put an end to your inclusive range:
+
+```
+fn main() {
+ let tmp = vec![0, 1, 2, 3, 4, 4, 3, 3, 2, 1];
+ let x = &tmp[1..=3]; // ok!
+}
+```