summaryrefslogtreecommitdiffstats
path: root/src/test/ui/consts/const-eval/const-eval-overflow2c.rs
blob: 33b892601153a3c2e8f9620abdb19c9e5f2cce9c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#![allow(unused_imports)]

// Note: the relevant lint pass here runs before some of the constant
// evaluation below (e.g., that performed by codegen and llvm), so if you
// change this warn to a deny, then the compiler will exit before
// those errors are detected.

use std::fmt;

const VALS_I8: (i8,) =
    (
     i8::MIN * 2,
     );
 //~^^ ERROR evaluation of constant value failed

const VALS_I16: (i16,) =
    (
     i16::MIN * 2,
     );
 //~^^ ERROR evaluation of constant value failed

const VALS_I32: (i32,) =
    (
     i32::MIN * 2,
     );
 //~^^ ERROR evaluation of constant value failed

const VALS_I64: (i64,) =
    (
     i64::MIN * 2,
     );
 //~^^ ERROR evaluation of constant value failed

const VALS_U8: (u8,) =
    (
     u8::MAX * 2,
     );
 //~^^ ERROR evaluation of constant value failed

const VALS_U16: (u16,) = (
     u16::MAX * 2,
     );
 //~^^ ERROR evaluation of constant value failed

const VALS_U32: (u32,) = (
     u32::MAX * 2,
     );
 //~^^ ERROR evaluation of constant value failed

const VALS_U64: (u64,) =
    (
     u64::MAX * 2,
     );
 //~^^ ERROR evaluation of constant value failed

fn main() {
    foo(VALS_I8);
    foo(VALS_I16);
    foo(VALS_I32);
    foo(VALS_I64);

    foo(VALS_U8);
    foo(VALS_U16);
    foo(VALS_U32);
    foo(VALS_U64);
}

fn foo<T>(_: T) {
}