From 698f8c2f01ea549d77d7dc3338a12e04c11057b9 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:02:58 +0200 Subject: Adding upstream version 1.64.0+dfsg1. Signed-off-by: Daniel Baumann --- .../rustc_error_codes/src/error_codes/E0586.md | 29 ++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 compiler/rustc_error_codes/src/error_codes/E0586.md (limited to 'compiler/rustc_error_codes/src/error_codes/E0586.md') 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! +} +``` -- cgit v1.2.3