]> git.lizzy.rs Git - rust.git/blob - src/test/ui/lint/type-overflow.rs
Move parse-fail tests to UI
[rust.git] / src / test / ui / lint / type-overflow.rs
1 // Copyright 2018 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 // compile-pass
12
13 fn main() {
14     let error = 255i8; //~WARNING literal out of range for i8
15
16     let ok = 0b1000_0001; // should be ok -> i32
17     let ok = 0b0111_1111i8; // should be ok -> 127i8
18
19     let fail = 0b1000_0001i8; //~WARNING literal out of range for i8
20
21     let fail = 0x8000_0000_0000_0000i64; //~WARNING literal out of range for i64
22
23     let fail = 0x1_FFFF_FFFFu32; //~WARNING literal out of range for u32
24
25     let fail: i128 = 0x8000_0000_0000_0000_0000_0000_0000_0000;
26     //~^ WARNING literal out of range for i128
27
28     let fail = 0x8FFF_FFFF_FFFF_FFFE; //~WARNING literal out of range for i32
29
30     let fail = -0b1111_1111i8; //~WARNING literal out of range for i8
31 }