]> git.lizzy.rs Git - rust.git/blob - src/test/ui/consts/const-eval/const-eval-overflow2.rs
Rollup merge of #53226 - QuietMisdreavus:editions-for-all, r=estebank
[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,) =
25      //~^ ERROR this constant cannot be used
26     (
27      i8::MIN - 1,
28      );
29
30 const VALS_I16: (i16,) =
31      //~^ ERROR this constant cannot be used
32     (
33      i16::MIN - 1,
34      );
35
36 const VALS_I32: (i32,) =
37      //~^ ERROR this constant cannot be used
38     (
39      i32::MIN - 1,
40      );
41
42 const VALS_I64: (i64,) =
43      //~^ ERROR this constant cannot be used
44     (
45      i64::MIN - 1,
46      );
47
48 const VALS_U8: (u8,) =
49      //~^ ERROR this constant cannot be used
50     (
51      u8::MIN - 1,
52      );
53
54 const VALS_U16: (u16,) = (
55      //~^ ERROR this constant cannot be used
56      u16::MIN - 1,
57      );
58
59 const VALS_U32: (u32,) = (
60      //~^ ERROR this constant cannot be used
61      u32::MIN - 1,
62      );
63
64 const VALS_U64: (u64,) =
65      //~^ ERROR this constant cannot be used
66     (
67      u64::MIN - 1,
68      );
69
70 fn main() {
71     foo(VALS_I8);
72     foo(VALS_I16);
73     foo(VALS_I32);
74     foo(VALS_I64);
75
76     foo(VALS_U8);
77     foo(VALS_U16);
78     foo(VALS_U32);
79     foo(VALS_U64);
80 }
81
82 fn foo<T>(_: T) {
83 }