Skip to content

Commit b3a13fd

Browse files
committed
Make sure array length diagnostic doesn't regress
1 parent 56181cf commit b3a13fd

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/test/ui/consts/const-array-oob-arith.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,12 @@ const ARR: [i32; 6] = [42, 43, 44, 45, 46, 47];
44
const IDX: usize = 3;
55
const VAL: i32 = ARR[IDX];
66
const BONG: [i32; (ARR[0] - 41) as usize] = [5];
7-
const BLUB: [i32; (ARR[0] - 40) as usize] = [5]; //~ ERROR: mismatched types
8-
const BOO: [i32; (ARR[0] - 41) as usize] = [5, 99]; //~ ERROR: mismatched types
7+
const BLUB: [i32; (ARR[0] - 40) as usize] = [5];
8+
//~^ ERROR: mismatched types
9+
//~| expected an array with a fixed size of 2 elements, found one with 1 element
10+
const BOO: [i32; (ARR[0] - 41) as usize] = [5, 99];
11+
//~^ ERROR: mismatched types
12+
//~| expected an array with a fixed size of 1 element, found one with 2 elements
913

1014
fn main() {
1115
let _ = VAL;

src/test/ui/consts/const-array-oob-arith.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ LL | const BLUB: [i32; (ARR[0] - 40) as usize] = [5];
88
found type `[i32; 1]`
99

1010
error[E0308]: mismatched types
11-
--> $DIR/const-array-oob-arith.rs:8:44
11+
--> $DIR/const-array-oob-arith.rs:10:44
1212
|
1313
LL | const BOO: [i32; (ARR[0] - 41) as usize] = [5, 99];
1414
| ^^^^^^^ expected an array with a fixed size of 1 element, found one with 2 elements

0 commit comments

Comments
 (0)