]>
Commit | Line | Data |
---|---|---|
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; //~ ERROR: blocks in constants are limited to items and tail expressions | |
18 | 0 | |
19 | } | |
20 | }; | |
21 | ||
22 | const bad_two : u32 = { | |
23 | { | |
24 | invalid(); | |
25 | //~^ ERROR: blocks in constants are limited to items and tail expressions | |
26 | //~^^ ERROR: calls in constants are limited to constant functions, tuple structs and tuple variants | |
27 | 0 | |
28 | } | |
29 | }; | |
30 | ||
31 | const bad_three : u32 = { | |
32 | { | |
33 | valid(); | |
34 | //~^ ERROR: blocks in constants are limited to items and tail expressions | |
35 | 0 | |
36 | } | |
37 | }; | |
38 | ||
39 | static bad_four : u32 = { | |
40 | { | |
41 | 5; //~ ERROR: blocks in statics are limited to items and tail expressions | |
42 | 0 | |
43 | } | |
44 | }; | |
45 | ||
46 | static bad_five : u32 = { | |
47 | { | |
48 | invalid(); | |
49 | //~^ ERROR: blocks in statics are limited to items and tail expressions | |
50 | //~^^ ERROR: calls in statics are limited to constant functions, tuple structs and tuple variants | |
51 | 0 | |
52 | } | |
53 | }; | |
54 | ||
55 | static bad_six : u32 = { | |
56 | { | |
57 | valid(); | |
58 | //~^ ERROR: blocks in statics are limited to items and tail expressions | |
59 | 0 | |
60 | } | |
61 | }; | |
62 | ||
63 | static mut bad_seven : u32 = { | |
64 | { | |
65 | 5; //~ ERROR: blocks in statics are limited to items and tail expressions | |
66 | 0 | |
67 | } | |
68 | }; | |
69 | ||
70 | static mut bad_eight : u32 = { | |
71 | { | |
72 | invalid(); | |
73 | //~^ ERROR: blocks in statics are limited to items and tail expressions | |
74 | //~^^ ERROR: calls in statics are limited to constant functions, tuple structs and tuple variants | |
75 | 0 | |
76 | } | |
77 | }; | |
78 | ||
79 | static mut bad_nine : u32 = { | |
80 | { | |
81 | valid(); | |
82 | //~^ ERROR: blocks in statics are limited to items and tail expressions | |
83 | 0 | |
84 | } | |
85 | }; | |
86 | ||
87 | ||
88 | fn invalid() {} | |
89 | const fn valid() {} | |
90 | ||
91 | fn main() {} |