|
| 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 | +const X: usize = 42 && 39; //~ ERROR: can't do this op on unsigned integrals |
| 12 | +const ARR: [i32; X] = [99; 34]; //~ NOTE: for array length here |
| 13 | + |
| 14 | +const X1: usize = 42 || 39; //~ ERROR: can't do this op on unsigned integrals |
| 15 | +const ARR1: [i32; X1] = [99; 47]; //~ NOTE: for array length here |
| 16 | + |
| 17 | +// FIXME: the error should be `on signed integrals` |
| 18 | +const X2: usize = -42 || -39; //~ ERROR: can't do this op on unsigned integrals |
| 19 | +const ARR2: [i32; X2] = [99; 18446744073709551607]; //~ NOTE: for array length here |
| 20 | + |
| 21 | +// FIXME: the error should be `on signed integrals` |
| 22 | +const X3: usize = -42 && -39; //~ ERROR: can't do this op on unsigned integrals |
| 23 | +const ARR3: [i32; X3] = [99; 6]; //~ NOTE: for array length here |
| 24 | + |
| 25 | +const Y: usize = 42.0 == 42.0; |
| 26 | +const ARRR: [i32; Y] = [99; 1]; //~ ERROR: expected constant integer expression for array length |
| 27 | +const Y1: usize = 42.0 >= 42.0; |
| 28 | +const ARRR1: [i32; Y] = [99; 1]; //~ ERROR: expected constant integer expression for array length |
| 29 | +const Y2: usize = 42.0 <= 42.0; |
| 30 | +const ARRR2: [i32; Y] = [99; 1]; //~ ERROR: expected constant integer expression for array length |
| 31 | +const Y3: usize = 42.0 > 42.0; |
| 32 | +const ARRR3: [i32; Y] = [99; 0]; //~ ERROR: expected constant integer expression for array length |
| 33 | +const Y4: usize = 42.0 < 42.0; |
| 34 | +const ARRR4: [i32; Y] = [99; 0]; //~ ERROR: expected constant integer expression for array length |
| 35 | +const Y5: usize = 42.0 != 42.0; |
| 36 | +const ARRR5: [i32; Y] = [99; 0]; //~ ERROR: expected constant integer expression for array length |
| 37 | + |
| 38 | +fn main() { |
| 39 | + let _ = ARR; |
| 40 | + let _ = ARRR; |
| 41 | + let _ = ARRR1; |
| 42 | + let _ = ARRR2; |
| 43 | + let _ = ARRR3; |
| 44 | + let _ = ARRR4; |
| 45 | + let _ = ARRR5; |
| 46 | +} |
0 commit comments