]> git.lizzy.rs Git - rust.git/blob - src/test/ui/consts/const-eval/const-eval-overflow-4b.rs
2a4585faf1493aa176016679646c76d9cc138a21
[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 use std::{i8, i16, i32, i64, isize};
9 use std::{u8, u16, u32, u64, usize};
10
11 const A_I8_T
12     : [u32; (i8::MAX as i8 + 1u8) as usize]
13     //~^ ERROR mismatched types
14     //~| expected `i8`, found `u8`
15     //~| ERROR cannot add `u8` to `i8`
16     = [0; (i8::MAX as usize) + 1];
17
18
19 const A_CHAR_USIZE
20     : [u32; 5u8 as char as usize]
21     = [0; 5];
22
23
24 const A_BAD_CHAR_USIZE
25     : [u32; 5i8 as char as usize]
26     //~^ ERROR only `u8` can be cast as `char`, not `i8`
27     = [0; 5];
28
29 fn main() {}