]> git.lizzy.rs Git - rust.git/blob - src/test/ui/consts/const-eval/const-eval-overflow-4b.rs
Rollup merge of #104076 - ozkanonur:fix-ci-rustc-sysroot, r=jyn514
[rust.git] / src / test / ui / consts / const-eval / const-eval-overflow-4b.rs
1 // Evaluation of constants in array-elem count goes through different
2 // compiler control-flow paths.
3 //
4 // This test is checking the count in an array type.
5
6 #![allow(unused_imports)]
7
8 const A_I8_T
9     : [u32; (i8::MAX as i8 + 1u8) as usize]
10     //~^ ERROR mismatched types
11     //~| expected `i8`, found `u8`
12     //~| ERROR cannot add `u8` to `i8`
13     = [0; (i8::MAX as usize) + 1];
14
15
16 const A_CHAR_USIZE
17     : [u32; 5u8 as char as usize]
18     = [0; 5];
19
20
21 const A_BAD_CHAR_USIZE
22     : [u32; 5i8 as char as usize]
23     //~^ ERROR only `u8` can be cast as `char`, not `i8`
24     = [0; 5];
25
26 fn main() {}