]> git.lizzy.rs Git - rust.git/blob - src/test/ui/issues/issue32829.rs
2b223bac8e67b7d849f19e6387a916c404878107
[rust.git] / src / test / ui / issues / issue32829.rs
1 // Copyright 2016 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 // ignore-tidy-linelength
12
13 #![feature(const_fn)]
14
15 const bad : u32 = {
16     {
17         5;
18         //~^ ERROR statements in constants are unstable
19         0
20     }
21 };
22
23 const bad_two : u32 = {
24     {
25         invalid();
26         //~^ ERROR statements in constants are unstable
27         //~^^ ERROR: calls in constants are limited to constant functions, tuple structs and tuple variants
28         0
29     }
30 };
31
32 const bad_three : u32 = {
33     {
34         valid();
35         //~^ ERROR statements in constants are unstable
36         0
37     }
38 };
39
40 static bad_four : u32 = {
41     {
42         5;
43         //~^ ERROR statements in statics are unstable
44         0
45     }
46 };
47
48 static bad_five : u32 = {
49     {
50         invalid();
51         //~^ ERROR: calls in statics are limited to constant functions, tuple structs and tuple variants
52         //~| ERROR statements in statics are unstable
53         0
54     }
55 };
56
57 static bad_six : u32 = {
58     {
59         valid();
60         //~^ ERROR statements in statics are unstable
61         0
62     }
63 };
64
65 static mut bad_seven : u32 = {
66     {
67         5;
68         //~^ ERROR statements in statics are unstable
69         0
70     }
71 };
72
73 static mut bad_eight : u32 = {
74     {
75         invalid();
76         //~^ ERROR statements in statics are unstable
77         //~| ERROR: calls in statics are limited to constant functions, tuple structs and tuple variants
78         0
79     }
80 };
81
82 static mut bad_nine : u32 = {
83     {
84         valid();
85         //~^ ERROR statements in statics are unstable
86         0
87     }
88 };
89
90
91 fn invalid() {}
92 const fn valid() {}
93
94 fn main() {}