From 00a1ef200bf2e4dc8e1258a7fb42fcc71cc1be1b Mon Sep 17 00:00:00 2001 From: Luv-Ray Date: Sat, 1 Jun 2024 08:39:18 +0800 Subject: [PATCH] tests with fixed errors --- tests/ui/indexing/index-bounds.rs | 5 ++++- tests/ui/indexing/index-bounds.stderr | 12 +++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/tests/ui/indexing/index-bounds.rs b/tests/ui/indexing/index-bounds.rs index b784ea28edd9..444cdeb4568b 100644 --- a/tests/ui/indexing/index-bounds.rs +++ b/tests/ui/indexing/index-bounds.rs @@ -5,6 +5,9 @@ fn main() { //~^ ERROR this operation will panic at runtime [unconditional_panic] // issue #121126, test index value between 0xFFFF_FF00 and u32::MAX - let _n = [64][4_294_967_295]; + let _n = [64][u32::MAX as usize - 1]; + //~^ ERROR this operation will panic at runtime [unconditional_panic] + + let _n = [64][u32::MAX as usize + 1]; //~^ ERROR this operation will panic at runtime [unconditional_panic] } diff --git a/tests/ui/indexing/index-bounds.stderr b/tests/ui/indexing/index-bounds.stderr index fe217a723d0f..f06d35264b01 100644 --- a/tests/ui/indexing/index-bounds.stderr +++ b/tests/ui/indexing/index-bounds.stderr @@ -9,8 +9,14 @@ LL | let _n = [64][200]; error: this operation will panic at runtime --> $DIR/index-bounds.rs:8:14 | -LL | let _n = [64][4_294_967_295]; - | ^^^^^^^^^^^^^^^^^^^ index out of bounds: the length is 1 but the index is 4294967295 +LL | let _n = [64][u32::MAX as usize - 1]; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ index out of bounds: the length is 1 but the index is 4294967294 -error: aborting due to 2 previous errors +error: this operation will panic at runtime + --> $DIR/index-bounds.rs:11:14 + | +LL | let _n = [64][u32::MAX as usize + 1]; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ index out of bounds: the length is 1 but the index is 4294967296 + +error: aborting due to 3 previous errors