2020-04-16 15:50:32 +09:00
|
|
|
// run-fail
|
2012-09-29 12:34:11 +01:00
|
|
|
// error-pattern:index out of bounds: the len is 1 but the index is 2
|
2020-05-08 00:39:02 +09:00
|
|
|
// ignore-emscripten no processes
|
2014-03-05 15:28:08 -08:00
|
|
|
|
2010-06-23 21:03:09 -07:00
|
|
|
fn main() {
|
2016-05-27 08:09:36 +05:30
|
|
|
let v: Vec<isize> = vec![10];
|
2015-03-25 17:06:52 -07:00
|
|
|
let x: usize = 0;
|
2014-10-14 23:05:01 -07:00
|
|
|
assert_eq!(v[x], 10);
|
2014-10-09 15:17:22 -04:00
|
|
|
// Bounds-check panic.
|
2011-06-15 11:19:50 -07:00
|
|
|
|
2014-10-14 23:05:01 -07:00
|
|
|
assert_eq!(v[x + 2], 20);
|
2011-08-10 09:27:22 -07:00
|
|
|
}
|