about summary refs log tree commit diff
path: root/tests/ui/array-slice-vec/vec-overrun.rs
blob: 10f8350869fb832a3bdecc86fc1decf7a458441a (plain)
1
2
3
4
5
6
7
8
9
10
11
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);
}