]> git.proxmox.com Git - rustc.git/blob - src/test/compile-fail/repeat_count.rs
Imported Upstream version 1.3.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 expected constant integer for repeat count, found variable [E0307]
17 let b = [0; ()];
18 //~^ ERROR mismatched types
19 //~| expected `usize`
20 //~| found `()`
21 //~| expected usize
22 //~| found ()) [E0308]
23 //~| ERROR expected positive integer for repeat count, found tuple [E0306]
24 let c = [0; true];
25 //~^ ERROR mismatched types
26 //~| expected `usize`
27 //~| found `bool`
28 //~| expected usize
29 //~| found bool) [E0308]
30 //~| ERROR expected positive integer for repeat count, found boolean [E0306]
31 let d = [0; 0.5];
32 //~^ ERROR mismatched types
33 //~| expected `usize`
34 //~| found `_`
35 //~| expected usize
36 //~| found floating-point variable) [E0308]
37 //~| ERROR expected positive integer for repeat count, found float [E0306]
38 let e = [0; "foo"];
39 //~^ ERROR mismatched types
40 //~| expected `usize`
41 //~| found `&'static str`
42 //~| expected usize
43 //~| found &-ptr) [E0308]
44 //~| ERROR expected positive integer for repeat count, found string literal [E0306]
45 let f = [0; -4_isize];
46 //~^ ERROR mismatched types
47 //~| expected `usize`
48 //~| found `isize`
49 //~| expected usize
50 //~| found isize) [E0308]
51 //~| ERROR expected positive integer for repeat count, found negative integer [E0306]
52 let f = [0_usize; -1_isize];
53 //~^ ERROR mismatched types
54 //~| expected `usize`
55 //~| found `isize`
56 //~| expected usize
57 //~| found isize) [E0308]
58 //~| ERROR expected positive integer for repeat count, found negative integer [E0306]
59 struct G {
60 g: (),
61 }
62 let g = [0; G { g: () }];
63 //~^ ERROR mismatched types
64 //~| expected `usize`
65 //~| found `main::G`
66 //~| expected usize
67 //~| found struct `main::G`) [E0308]
68 //~| ERROR expected positive integer for repeat count, found struct [E0306]
69 }