]> git.proxmox.com Git - rustc.git/blame - src/test/compile-fail/issue32829.rs
New upstream version 1.24.1+dfsg1
[rustc.git] / src / test / compile-fail / issue32829.rs
CommitLineData
a7813a04
XL
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#![feature(const_fn)]
11
12const bad : u32 = {
13 {
14 5; //~ ERROR: blocks in constants are limited to items and tail expressions
15 0
16 }
17};
18
19const bad_two : u32 = {
20 {
21 invalid();
22 //~^ ERROR: blocks in constants are limited to items and tail expressions
23 //~^^ ERROR: calls in constants are limited to constant functions, struct and enum
24 0
25 }
26};
27
28const bad_three : u32 = {
29 {
30 valid();
31 //~^ ERROR: blocks in constants are limited to items and tail expressions
32 0
33 }
34};
35
36static bad_four : u32 = {
37 {
38 5; //~ ERROR: blocks in statics are limited to items and tail expressions
39 0
40 }
41};
42
43static bad_five : u32 = {
44 {
45 invalid();
46 //~^ ERROR: blocks in statics are limited to items and tail expressions
47 //~^^ ERROR: calls in statics are limited to constant functions, struct and enum
48 0
49 }
50};
51
52static bad_six : u32 = {
53 {
54 valid();
55 //~^ ERROR: blocks in statics are limited to items and tail expressions
56 0
57 }
58};
59
60static mut bad_seven : u32 = {
61 {
62 5; //~ ERROR: blocks in statics are limited to items and tail expressions
63 0
64 }
65};
66
67static mut bad_eight : u32 = {
68 {
69 invalid();
70 //~^ ERROR: blocks in statics are limited to items and tail expressions
71 //~^^ ERROR: calls in statics are limited to constant functions, struct and enum
72 0
73 }
74};
75
76static mut bad_nine : u32 = {
77 {
78 valid();
79 //~^ ERROR: blocks in statics are limited to items and tail expressions
80 0
81 }
82};
83
84
85fn invalid() {}
86const fn valid() {}
87
88fn main() {}