]> git.proxmox.com Git - rustc.git/blob - src/test/compile-fail/const-eval-overflow-2.rs
Imported Upstream version 1.9.0+dfsg1
[rustc.git] / src / test / compile-fail / const-eval-overflow-2.rs
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.
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 // Evaluation of constants in refutable patterns goes through
12 // different compiler control-flow paths.
13
14 #![allow(unused_imports)]
15
16 use std::fmt;
17 use std::{i8, i16, i32, i64, isize};
18 use std::{u8, u16, u32, u64, usize};
19
20 const NEG_128: i8 = -128;
21 const NEG_NEG_128: i8 = -NEG_128;
22 //~^ ERROR constant evaluation error: attempted to negate with overflow
23 //~| ERROR attempted to negate with overflow
24 //~| ERROR attempted to negate with overflow
25
26 fn main() {
27 match -128i8 {
28 NEG_NEG_128 => println!("A"), //~ NOTE in pattern here
29 _ => println!("B"),
30 }
31 }