summaryrefslogtreecommitdiffstats
path: root/src/test/ui/array-slice-vec/vec-overrun.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/ui/array-slice-vec/vec-overrun.rs')
-rw-r--r--src/test/ui/array-slice-vec/vec-overrun.rs12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/test/ui/array-slice-vec/vec-overrun.rs b/src/test/ui/array-slice-vec/vec-overrun.rs
new file mode 100644
index 000000000..bdc7d507d
--- /dev/null
+++ b/src/test/ui/array-slice-vec/vec-overrun.rs
@@ -0,0 +1,12 @@
+// run-fail
+// error-pattern:index out of bounds: the len is 1 but the index is 2
+// ignore-emscripten no processes
+
+fn main() {
+ let v: Vec<isize> = vec![10];
+ let x: usize = 0;
+ assert_eq!(v[x], 10);
+ // Bounds-check panic.
+
+ assert_eq!(v[x + 2], 20);
+}