]> git.lizzy.rs Git - rust.git/blob - src/test/ui/consts/const-eval/const-eval-overflow2b.rs
da883671a60a3c6cbaebe860ab5da8100d7c8ac7
[rust.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 use std::{i8, i16, i32, i64, isize};
12 use std::{u8, u16, u32, u64, usize};
13
14 const VALS_I8: (i8,) =
15     (
16      i8::MAX + 1,
17      );
18  //~^^ ERROR any use of this value will cause an error
19
20 const VALS_I16: (i16,) =
21     (
22      i16::MAX + 1,
23      );
24  //~^^ ERROR any use of this value will cause an error
25
26 const VALS_I32: (i32,) =
27     (
28      i32::MAX + 1,
29      );
30  //~^^ ERROR any use of this value will cause an error
31
32 const VALS_I64: (i64,) =
33     (
34      i64::MAX + 1,
35      );
36  //~^^ ERROR any use of this value will cause an error
37
38 const VALS_U8: (u8,) =
39     (
40      u8::MAX + 1,
41      );
42  //~^^ ERROR any use of this value will cause an error
43
44 const VALS_U16: (u16,) = (
45      u16::MAX + 1,
46      );
47  //~^^ ERROR any use of this value will cause an error
48
49 const VALS_U32: (u32,) = (
50      u32::MAX + 1,
51      );
52  //~^^ ERROR any use of this value will cause an error
53
54 const VALS_U64: (u64,) =
55     (
56      u64::MAX + 1,
57      );
58  //~^^ ERROR any use of this value will cause an error
59
60 fn main() {
61     foo(VALS_I8);
62     foo(VALS_I16);
63     foo(VALS_I32);
64     foo(VALS_I64);
65
66     foo(VALS_U8);
67     foo(VALS_U16);
68     foo(VALS_U32);
69     foo(VALS_U64);
70 }
71
72 fn foo<T>(_: T) {
73 }