|
8 | 8 | // option. This file may not be copied, modified, or distributed
|
9 | 9 | // except according to those terms.
|
10 | 10 |
|
11 |
| -// error-pattern: calls in statics are limited |
| 11 | +#![feature(const_fn)] |
12 | 12 |
|
13 |
| -static S : u64 = { { panic!("foo"); 0 } }; |
| 13 | +const bad: u32 = { |
| 14 | + { |
| 15 | + 5; //~ ERROR: blocks in constants are limited to items and tail expressions |
| 16 | + 0 |
| 17 | + } |
| 18 | +}; |
14 | 19 |
|
15 |
| -fn main() { |
16 |
| - println!("{:?}", S); |
17 |
| -} |
| 20 | +const bad_two: u32 = { |
| 21 | + { |
| 22 | + invalid(); |
| 23 | + //~^ ERROR: blocks in constants are limited to items and tail expressions |
| 24 | + //~^^ ERROR: calls in constants are limited to constant functions, struct and enum |
| 25 | + 0 |
| 26 | + } |
| 27 | +}; |
| 28 | + |
| 29 | +const bad_three: u32 = { |
| 30 | + { |
| 31 | + valid(); |
| 32 | + //~^ ERROR: blocks in constants are limited to items and tail expressions |
| 33 | + 0 |
| 34 | + } |
| 35 | +}; |
| 36 | + |
| 37 | +static bad_four: u32 = { |
| 38 | + { |
| 39 | + 5; //~ ERROR: blocks in statics are limited to items and tail expressions |
| 40 | + 0 |
| 41 | + } |
| 42 | +}; |
| 43 | + |
| 44 | +static bad_five: u32 = { |
| 45 | + { |
| 46 | + invalid(); |
| 47 | + //~^ ERROR: blocks in statics are limited to items and tail expressions |
| 48 | + //~^^ ERROR: calls in statics are limited to constant functions, struct and enum |
| 49 | + 0 |
| 50 | + } |
| 51 | +}; |
| 52 | + |
| 53 | +static bad_six: u32 = { |
| 54 | + { |
| 55 | + valid(); |
| 56 | + //~^ ERROR: blocks in statics are limited to items and tail expressions |
| 57 | + 0 |
| 58 | + } |
| 59 | +}; |
| 60 | + |
| 61 | +static mut bad_seven: u32 = { |
| 62 | + { |
| 63 | + 5; //~ ERROR: blocks in statics are limited to items and tail expressions |
| 64 | + 0 |
| 65 | + } |
| 66 | +}; |
| 67 | + |
| 68 | +static mut bad_eight: u32 = { |
| 69 | + { |
| 70 | + invalid(); |
| 71 | + //~^ ERROR: blocks in statics are limited to items and tail expressions |
| 72 | + //~^^ ERROR: calls in statics are limited to constant functions, struct and enum |
| 73 | + 0 |
| 74 | + } |
| 75 | +}; |
| 76 | + |
| 77 | +static mut bad_nine: u32 = { |
| 78 | + { |
| 79 | + valid(); |
| 80 | + //~^ ERROR: blocks in statics are limited to items and tail expressions |
| 81 | + 0 |
| 82 | + } |
| 83 | +}; |
| 84 | + |
| 85 | +fn invalid() {} |
| 86 | +const fn valid() {} |
| 87 | + |
| 88 | +fn main() {} |
0 commit comments