]> git.proxmox.com Git - rustc.git/blob - src/test/ui/consts/const-eval/const-eval-overflow2b.rs
New upstream version 1.51.0+dfsg1
[rustc.git] / src / test / ui / consts / const-eval / const-eval-overflow2b.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 #![deny(const_err)]
9
10 use std::fmt;
11
12 const VALS_I8: (i8,) =
13 (
14 i8::MAX + 1,
15 );
16 //~^^ ERROR any use of this value will cause an error
17 //~| WARN this was previously accepted by the compiler but is being phased out
18
19 const VALS_I16: (i16,) =
20 (
21 i16::MAX + 1,
22 );
23 //~^^ ERROR any use of this value will cause an error
24 //~| WARN this was previously accepted by the compiler but is being phased out
25
26 const VALS_I32: (i32,) =
27 (
28 i32::MAX + 1,
29 );
30 //~^^ ERROR any use of this value will cause an error
31 //~| WARN this was previously accepted by the compiler but is being phased out
32
33 const VALS_I64: (i64,) =
34 (
35 i64::MAX + 1,
36 );
37 //~^^ ERROR any use of this value will cause an error
38 //~| WARN this was previously accepted by the compiler but is being phased out
39
40 const VALS_U8: (u8,) =
41 (
42 u8::MAX + 1,
43 );
44 //~^^ ERROR any use of this value will cause an error
45 //~| WARN this was previously accepted by the compiler but is being phased out
46
47 const VALS_U16: (u16,) = (
48 u16::MAX + 1,
49 );
50 //~^^ ERROR any use of this value will cause an error
51 //~| WARN this was previously accepted by the compiler but is being phased out
52
53 const VALS_U32: (u32,) = (
54 u32::MAX + 1,
55 );
56 //~^^ ERROR any use of this value will cause an error
57 //~| WARN this was previously accepted by the compiler but is being phased out
58
59 const VALS_U64: (u64,) =
60 (
61 u64::MAX + 1,
62 );
63 //~^^ ERROR any use of this value will cause an error
64 //~| WARN this was previously accepted by the compiler but is being phased out
65
66 fn main() {
67 foo(VALS_I8);
68 foo(VALS_I16);
69 foo(VALS_I32);
70 foo(VALS_I64);
71
72 foo(VALS_U8);
73 foo(VALS_U16);
74 foo(VALS_U32);
75 foo(VALS_U64);
76 }
77
78 fn foo<T>(_: T) {
79 }