]> git.proxmox.com Git - rustc.git/blob - src/test/compile-fail/repeat_count.rs
New upstream version 1.12.0+dfsg1
[rustc.git] / src / test / compile-fail / repeat_count.rs
1 // Copyright 2013-2014 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 // Regression test for issue #3645
12
13 fn main() {
14 let n = 1;
15 let a = [0; n];
16 //~^ ERROR constant evaluation error
17 //~| non-constant path in constant expression
18 let b = [0; ()];
19 //~^ ERROR mismatched types
20 //~| expected type `usize`
21 //~| found type `()`
22 //~| expected usize, found ()
23 //~| ERROR expected `usize` for repeat count, found tuple [E0306]
24 //~| expected `usize`
25 let c = [0; true];
26 //~^ ERROR mismatched types
27 //~| expected usize, found bool
28 //~| ERROR expected `usize` for repeat count, found boolean [E0306]
29 //~| expected `usize`
30 let d = [0; 0.5];
31 //~^ ERROR mismatched types
32 //~| expected type `usize`
33 //~| found type `{float}`
34 //~| expected usize, found floating-point variable
35 //~| ERROR expected `usize` for repeat count, found float [E0306]
36 //~| expected `usize`
37 let e = [0; "foo"];
38 //~^ ERROR mismatched types
39 //~| expected type `usize`
40 //~| found type `&'static str`
41 //~| expected usize, found reference
42 //~| ERROR expected `usize` for repeat count, found string literal [E0306]
43 //~| expected `usize`
44 let f = [0; -4_isize];
45 //~^ ERROR constant evaluation error
46 //~| expected usize, found isize
47 //~| ERROR mismatched types
48 //~| expected usize, found isize
49 let f = [0_usize; -1_isize];
50 //~^ ERROR constant evaluation error
51 //~| expected usize, found isize
52 //~| ERROR mismatched types
53 //~| expected usize, found isize
54 struct G {
55 g: (),
56 }
57 let g = [0; G { g: () }];
58 //~^ ERROR mismatched types
59 //~| expected type `usize`
60 //~| found type `main::G`
61 //~| expected usize, found struct `main::G`
62 //~| ERROR expected `usize` for repeat count, found struct [E0306]
63 //~| expected `usize`
64 }