File tree Expand file tree Collapse file tree 2 files changed +13
-4
lines changed Expand file tree Collapse file tree 2 files changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,9 @@ fn main() {
55 //~^ ERROR this operation will panic at runtime [unconditional_panic]
66
77 // issue #121126, test index value between 0xFFFF_FF00 and u32::MAX
8- let _n = [ 64 ] [ 4_294_967_295 ] ;
8+ let _n = [ 64 ] [ u32:: MAX as usize - 1 ] ;
9+ //~^ ERROR this operation will panic at runtime [unconditional_panic]
10+
11+ let _n = [ 64 ] [ u32:: MAX as usize + 1 ] ;
912 //~^ ERROR this operation will panic at runtime [unconditional_panic]
1013}
Original file line number Diff line number Diff line change @@ -9,8 +9,14 @@ LL | let _n = [64][200];
99error: this operation will panic at runtime
1010 --> $DIR/index-bounds.rs:8:14
1111 |
12- LL | let _n = [64][4_294_967_295 ];
13- | ^^^^^^^^^^^^^^^^^^^ index out of bounds: the length is 1 but the index is 4294967295
12+ LL | let _n = [64][u32::MAX as usize - 1 ];
13+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ index out of bounds: the length is 1 but the index is 4294967294
1414
15- error: aborting due to 2 previous errors
15+ error: this operation will panic at runtime
16+ --> $DIR/index-bounds.rs:11:14
17+ |
18+ LL | let _n = [64][u32::MAX as usize + 1];
19+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ index out of bounds: the length is 1 but the index is 4294967296
20+
21+ error: aborting due to 3 previous errors
1622
You can’t perform that action at this time.
0 commit comments