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 #![feature(rustc_attrs)]
12 #![allow(unused_imports)]
14 // Note: the relevant lint pass here runs before some of the constant
15 // evaluation below (e.g. that performed by trans and llvm), so if you
16 // change this warn to a deny, then the compiler will exit before
17 // those errors are detected.
20 use std
::{i8, i16, i32, i64, isize}
;
21 use std
::{u8, u16, u32, u64, usize}
;
23 const VALS_I8
: (i8, i8, i8, i8) =
25 //~^ ERROR attempted to negate with overflow
27 //~^ ERROR attempted to subtract with overflow
29 //~^ ERROR attempted to add with overflow
31 //~^ ERROR attempted to multiply with overflow
34 const VALS_I16
: (i16, i16, i16, i16) =
36 //~^ ERROR attempted to negate with overflow
38 //~^ ERROR attempted to subtract with overflow
40 //~^ ERROR attempted to add with overflow
42 //~^ ERROR attempted to multiply with overflow
45 const VALS_I32
: (i32, i32, i32, i32) =
47 //~^ ERROR attempted to negate with overflow
49 //~^ ERROR attempted to subtract with overflow
51 //~^ ERROR attempted to add with overflow
53 //~^ ERROR attempted to multiply with overflow
56 const VALS_I64
: (i64, i64, i64, i64) =
58 //~^ ERROR attempted to negate with overflow
60 //~^ ERROR attempted to subtract with overflow
62 //~^ ERROR attempted to add with overflow
64 //~^ ERROR attempted to multiply with overflow
67 const VALS_U8
: (u8, u8, u8, u8) =
68 (-(u8::MIN
as i8) as u8,
70 //~^ ERROR attempted to subtract with overflow
72 //~^ ERROR attempted to add with overflow
74 //~^ ERROR attempted to multiply with overflow
77 const VALS_U16
: (u16, u16, u16, u16) =
78 (-(u16::MIN
as i16) as u16,
80 //~^ ERROR attempted to subtract with overflow
82 //~^ ERROR attempted to add with overflow
84 //~^ ERROR attempted to multiply with overflow
87 const VALS_U32
: (u32, u32, u32, u32) =
88 (-(u32::MIN
as i32) as u32,
90 //~^ ERROR attempted to subtract with overflow
92 //~^ ERROR attempted to add with overflow
94 //~^ ERROR attempted to multiply with overflow
97 const VALS_U64
: (u64, u64, u64, u64) =
98 (-(u64::MIN
as i64) as u64,
100 //~^ ERROR attempted to subtract with overflow
102 //~^ ERROR attempted to add with overflow
104 //~^ ERROR attempted to multiply with overflow
107 #[rustc_no_mir] // FIXME #29769 MIR overflow checking is TBD.
120 fn foo
<T
:fmt
::Debug
>(x
: T
) {