]> git.proxmox.com Git - rustc.git/blob - src/test/ui/consts/const-eval/const-eval-overflow2c.rs
New upstream version 1.66.0+dfsg1
[rustc.git] / src / test / ui / consts / const-eval / const-eval-overflow2c.rs
1 #![allow(unused_imports)]
2
3 // Note: the relevant lint pass here runs before some of the constant
4 // evaluation below (e.g., that performed by codegen and llvm), so if you
5 // change this warn to a deny, then the compiler will exit before
6 // those errors are detected.
7
8 use std::fmt;
9
10 const VALS_I8: (i8,) =
11 (
12 i8::MIN * 2,
13 );
14 //~^^ ERROR evaluation of constant value failed
15
16 const VALS_I16: (i16,) =
17 (
18 i16::MIN * 2,
19 );
20 //~^^ ERROR evaluation of constant value failed
21
22 const VALS_I32: (i32,) =
23 (
24 i32::MIN * 2,
25 );
26 //~^^ ERROR evaluation of constant value failed
27
28 const VALS_I64: (i64,) =
29 (
30 i64::MIN * 2,
31 );
32 //~^^ ERROR evaluation of constant value failed
33
34 const VALS_U8: (u8,) =
35 (
36 u8::MAX * 2,
37 );
38 //~^^ ERROR evaluation of constant value failed
39
40 const VALS_U16: (u16,) = (
41 u16::MAX * 2,
42 );
43 //~^^ ERROR evaluation of constant value failed
44
45 const VALS_U32: (u32,) = (
46 u32::MAX * 2,
47 );
48 //~^^ ERROR evaluation of constant value failed
49
50 const VALS_U64: (u64,) =
51 (
52 u64::MAX * 2,
53 );
54 //~^^ ERROR evaluation of constant value failed
55
56 fn main() {
57 foo(VALS_I8);
58 foo(VALS_I16);
59 foo(VALS_I32);
60 foo(VALS_I64);
61
62 foo(VALS_U8);
63 foo(VALS_U16);
64 foo(VALS_U32);
65 foo(VALS_U64);
66 }
67
68 fn foo<T>(_: T) {
69 }