]> git.proxmox.com Git - rustc.git/blob - src/test/run-pass/const-negation.rs
Imported Upstream version 1.9.0+dfsg1
[rustc.git] / src / test / run-pass / const-negation.rs
1 // Copyright 2016 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 #![feature(stmt_expr_attributes)]
12
13 #[deny(const_err)]
14
15 fn main() {
16 #[cfg(target_pointer_width = "32")]
17 const I: isize = -2147483648isize;
18 #[cfg(target_pointer_width = "64")]
19 const I: isize = -9223372036854775808isize;
20 assert_eq!(::std::i32::MIN as u64, 0xffffffff80000000);
21 assert_eq!(-2147483648isize as u64, 0xffffffff80000000);
22 assert_eq!(::std::i64::MIN as u64, 0x8000000000000000);
23 #[cfg(target_pointer_width = "64")]
24 assert_eq!(-9223372036854775808isize as u64, 0x8000000000000000);
25 #[cfg(target_pointer_width = "32")]
26 assert_eq!(-9223372036854775808isize as u64, 0);
27 const J: usize = ::std::i32::MAX as usize;
28 const K: usize = -1i32 as u32 as usize;
29 const L: usize = ::std::i32::MIN as usize;
30 const M: usize = ::std::i64::MIN as usize;
31 match 5 {
32 J => {},
33 K => {},
34 L => {},
35 M => {},
36 _ => {}
37 }
38 match 5 {
39 I => {},
40 _ => {}
41 }
42 }