]> git.lizzy.rs Git - rust.git/blob - src/test/ui/consts/const-eval/const-eval-overflow2.rs
8e094a7f7dcc77d1c21722d9585374f6c4652f6b
[rust.git] / src / test / ui / consts / const-eval / const-eval-overflow2.rs
1 // Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 #![allow(unused_imports)]
12
13 // Note: the relevant lint pass here runs before some of the constant
14 // evaluation below (e.g. that performed by codegen and llvm), so if you
15 // change this warn to a deny, then the compiler will exit before
16 // those errors are detected.
17
18 #![deny(const_err)]
19
20 use std::fmt;
21 use std::{i8, i16, i32, i64, isize};
22 use std::{u8, u16, u32, u64, usize};
23
24 const VALS_I8: (i8,) = //~ ERROR any use of this value will cause an error
25     (
26      i8::MIN - 1,
27      );
28
29 const VALS_I16: (i16,) = //~ ERROR any use of this value will cause an error
30     (
31      i16::MIN - 1,
32      );
33
34 const VALS_I32: (i32,) = //~ ERROR any use of this value will cause an error
35     (
36      i32::MIN - 1,
37      );
38
39 const VALS_I64: (i64,) = //~ ERROR any use of this value will cause an error
40     (
41      i64::MIN - 1,
42      );
43
44 const VALS_U8: (u8,) = //~ ERROR any use of this value will cause an error
45     (
46      u8::MIN - 1,
47      );
48
49 const VALS_U16: (u16,) = ( //~ ERROR any use of this value will cause an error
50      u16::MIN - 1,
51      );
52
53 const VALS_U32: (u32,) = ( //~ ERROR any use of this value will cause an error
54      u32::MIN - 1,
55      );
56
57 const VALS_U64: (u64,) = //~ ERROR any use of this value will cause an error
58     (
59      u64::MIN - 1,
60      );
61
62 fn main() {
63     foo(VALS_I8);
64     foo(VALS_I16);
65     foo(VALS_I32);
66     foo(VALS_I64);
67
68     foo(VALS_U8);
69     foo(VALS_U16);
70     foo(VALS_U32);
71     foo(VALS_U64);
72 }
73
74 fn foo<T>(_: T) {
75 }