]> git.proxmox.com Git - rustc.git/blame - src/test/compile-fail/const-integer-bool-ops.rs
Imported Upstream version 1.9.0+dfsg1
[rustc.git] / src / test / compile-fail / const-integer-bool-ops.rs
CommitLineData
92a42be0
SL
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
54a0048b 11const X: usize = 42 && 39; //~ ERROR: can't do this op on integrals
92a42be0
SL
12const ARR: [i32; X] = [99; 34]; //~ NOTE: for array length here
13
54a0048b 14const X1: usize = 42 || 39; //~ ERROR: can't do this op on integrals
92a42be0
SL
15const ARR1: [i32; X1] = [99; 47]; //~ NOTE: for array length here
16
54a0048b 17const X2: usize = -42 || -39; //~ ERROR: unary negation of unsigned integer
92a42be0
SL
18const ARR2: [i32; X2] = [99; 18446744073709551607]; //~ NOTE: for array length here
19
54a0048b 20const X3: usize = -42 && -39; //~ ERROR: unary negation of unsigned integer
92a42be0
SL
21const ARR3: [i32; X3] = [99; 6]; //~ NOTE: for array length here
22
23const Y: usize = 42.0 == 42.0;
54a0048b 24const ARRR: [i32; Y] = [99; 1]; //~ ERROR: expected usize value for array length
92a42be0 25const Y1: usize = 42.0 >= 42.0;
54a0048b 26const ARRR1: [i32; Y] = [99; 1]; //~ ERROR: expected usize value for array length
92a42be0 27const Y2: usize = 42.0 <= 42.0;
54a0048b 28const ARRR2: [i32; Y] = [99; 1]; //~ ERROR: expected usize value for array length
92a42be0 29const Y3: usize = 42.0 > 42.0;
54a0048b 30const ARRR3: [i32; Y] = [99; 0]; //~ ERROR: expected usize value for array length
92a42be0 31const Y4: usize = 42.0 < 42.0;
54a0048b 32const ARRR4: [i32; Y] = [99; 0]; //~ ERROR: expected usize value for array length
92a42be0 33const Y5: usize = 42.0 != 42.0;
54a0048b 34const ARRR5: [i32; Y] = [99; 0]; //~ ERROR: expected usize value for array length
92a42be0
SL
35
36fn main() {
37 let _ = ARR;
38 let _ = ARRR;
39 let _ = ARRR1;
40 let _ = ARRR2;
41 let _ = ARRR3;
42 let _ = ARRR4;
43 let _ = ARRR5;
44}