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.
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.
11 #![allow(unused_imports)]
13 // Note: the relevant lint pass here runs before some of the constant
14 // evaluation below (e.g. that performed by trans and llvm), so if you
15 // change this warn to a deny, then the compiler will exit before
16 // those errors are detected.
21 use std::{i8, i16, i32, i64, isize};
22 use std::{u8, u16, u32, u64, usize};
24 const VALS_I8: (i8, i8, i8, i8) =
26 //~^ ERROR constant evaluation error
27 //~| attempt to negate with overflow
29 //~^ ERROR constant evaluation error
30 //~| attempt to subtract with overflow
32 //~^ ERROR constant evaluation error
33 //~| attempt to add with overflow
35 //~^ ERROR constant evaluation error
36 //~| attempt to multiply with overflow
39 const VALS_I16: (i16, i16, i16, i16) =
41 //~^ ERROR constant evaluation error
42 //~| attempt to negate with overflow
44 //~^ ERROR constant evaluation error
45 //~| attempt to subtract with overflow
47 //~^ ERROR constant evaluation error
48 //~| attempt to add with overflow
50 //~^ ERROR constant evaluation error
51 //~| attempt to multiply with overflow
54 const VALS_I32: (i32, i32, i32, i32) =
56 //~^ ERROR constant evaluation error
57 //~| attempt to negate with overflow
59 //~^ ERROR constant evaluation error
60 //~| attempt to subtract with overflow
62 //~^ ERROR constant evaluation error
63 //~| attempt to add with overflow
65 //~^ ERROR constant evaluation error
66 //~| attempt to multiply with overflow
69 const VALS_I64: (i64, i64, i64, i64) =
71 //~^ ERROR constant evaluation error
72 //~| attempt to negate with overflow
74 //~^ ERROR constant evaluation error
75 //~| attempt to subtract with overflow
77 //~^ ERROR constant evaluation error
78 //~| attempt to add with overflow
80 //~^ ERROR constant evaluation error
81 //~| attempt to multiply with overflow
84 const VALS_U8: (u8, u8, u8, u8) =
85 ( //~ WARN constant evaluation error: attempt to subtract with overflow
86 -(u8::MIN as i8) as u8,
88 //~^ ERROR constant evaluation error
89 //~| attempt to subtract with overflow
91 //~^ ERROR constant evaluation error
92 //~| attempt to add with overflow
94 //~^ ERROR constant evaluation error
95 //~| attempt to multiply with overflow
98 const VALS_U16: (u16, u16, u16, u16) =
99 ( //~ WARN constant evaluation error: attempt to subtract with overflow
100 -(u16::MIN as i16) as u16,
102 //~^ ERROR constant evaluation error
103 //~| attempt to subtract with overflow
105 //~^ ERROR constant evaluation error
106 //~| attempt to add with overflow
108 //~^ ERROR constant evaluation error
109 //~| attempt to multiply with overflow
112 const VALS_U32: (u32, u32, u32, u32) =
113 ( //~ WARN constant evaluation error: attempt to subtract with overflow
114 -(u32::MIN as i32) as u32,
116 //~^ ERROR constant evaluation error
117 //~| attempt to subtract with overflow
119 //~^ ERROR constant evaluation error
120 //~| attempt to add with overflow
122 //~^ ERROR constant evaluation error
123 //~| attempt to multiply with overflow
126 const VALS_U64: (u64, u64, u64, u64) =
127 ( //~ WARN constant evaluation error: attempt to subtract with overflow
128 -(u64::MIN as i64) as u64,
130 //~^ ERROR constant evaluation error
131 //~| attempt to subtract with overflow
133 //~^ ERROR constant evaluation error
134 //~| attempt to add with overflow
136 //~^ ERROR constant evaluation error
137 //~| attempt to multiply with overflow
152 fn foo<T:fmt::Debug>(x: T) {