rust/src/test/run-fail/vec-overrun.rs
2018-12-25 21:08:33 -07:00

11 lines
226 B
Rust

// error-pattern:index out of bounds: the len is 1 but the index is 2
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);
}