]> git.lizzy.rs Git - rust.git/blob - src/test/ui/repeat_count.rs
Auto merge of #54720 - davidtwco:issue-51191, r=nikomatsakis
[rust.git] / src / test / ui / 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 attempt to use a non-constant value in a constant [E0435]
17     let b = [0; ()];
18     //~^ ERROR mismatched types
19     //~| expected type `usize`
20     //~| found type `()`
21     //~| expected usize, found ()
22     let c = [0; true];
23     //~^ ERROR mismatched types
24     //~| expected usize, found bool
25     let d = [0; 0.5];
26     //~^ ERROR mismatched types
27     //~| expected type `usize`
28     //~| found type `{float}`
29     //~| expected usize, found floating-point variable
30     let e = [0; "foo"];
31     //~^ ERROR mismatched types
32     //~| expected type `usize`
33     //~| found type `&'static str`
34     //~| expected usize, found reference
35     let f = [0; -4_isize];
36     //~^ ERROR mismatched types
37     //~| expected usize, found isize
38     let f = [0_usize; -1_isize];
39     //~^ ERROR mismatched types
40     //~| expected usize, found isize
41     struct G {
42         g: (),
43     }
44     let g = [0; G { g: () }];
45     //~^ ERROR mismatched types
46     //~| expected type `usize`
47     //~| found type `main::G`
48     //~| expected usize, found struct `main::G`
49 }