blob: 2b8561a2644888486e4cf3648bd54b2405e3d3cc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
const _: () = loop { break (); };
static FOO: i32 = loop { break 4; };
const fn foo() {
loop {}
}
pub trait Foo {
const BAR: i32 = loop { break 4; };
}
impl Foo for () {
const BAR: i32 = loop { break 4; };
}
fn non_const_outside() {
const fn const_inside() {
loop {}
}
}
const fn const_outside() {
fn non_const_inside() {
loop {}
}
}
fn main() {
let x = [0; {
while false {}
4
}];
}
const _: i32 = {
let mut x = 0;
while x < 4 {
x += 1;
}
while x < 8 {
x += 1;
}
x
};
const _: i32 = {
let mut x = 0;
for i in 0..4 { //~ ERROR `for` is not allowed in a `const`
x += i;
}
for i in 0..4 { //~ ERROR `for` is not allowed in a `const`
x += i;
}
x
};
const _: i32 = {
let mut x = 0;
loop {
x += 1;
if x == 4 {
break;
}
}
loop {
x += 1;
if x == 8 {
break;
}
}
x
};
const _: i32 = {
let mut x = 0;
while let None = Some(x) { }
while let None = Some(x) { }
x
};
|