]> git.lizzy.rs Git - rust.git/blob - src/test/ui/consts/const-eval/const-eval-overflow2.rs
Rollup merge of #101655 - dns2utf8:box_docs, r=dtolnay
[rust.git] / src / test / ui / consts / const-eval / const-eval-overflow2.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 - 1,
13      );
14  //~^^ ERROR evaluation of constant value failed
15
16 const VALS_I16: (i16,) =
17     (
18      i16::MIN - 1,
19      );
20  //~^^ ERROR evaluation of constant value failed
21
22 const VALS_I32: (i32,) =
23     (
24      i32::MIN - 1,
25      );
26  //~^^ ERROR evaluation of constant value failed
27
28 const VALS_I64: (i64,) =
29     (
30      i64::MIN - 1,
31      );
32  //~^^ ERROR evaluation of constant value failed
33
34 const VALS_U8: (u8,) =
35     (
36      u8::MIN - 1,
37      );
38  //~^^ ERROR evaluation of constant value failed
39
40 const VALS_U16: (u16,) = (
41      u16::MIN - 1,
42      );
43  //~^^ ERROR evaluation of constant value failed
44
45 const VALS_U32: (u32,) = (
46      u32::MIN - 1,
47      );
48  //~^^ ERROR evaluation of constant value failed
49
50 const VALS_U64: (u64,) =
51     (
52      u64::MIN - 1,
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 }