File tree Expand file tree Collapse file tree 2 files changed +118
-0
lines changed Expand file tree Collapse file tree 2 files changed +118
-0
lines changed Original file line number Diff line number Diff line change 1+ const _: i32 = {
2+ let mut x = 0 ;
3+
4+ while x < 4 {
5+ //~^ ERROR constant contains unimplemented expression type
6+ //~| ERROR constant contains unimplemented expression type
7+ x += 1 ;
8+ }
9+
10+ while x < 8 {
11+ x += 1 ;
12+ }
13+
14+ x
15+ } ;
16+
17+ const _: i32 = {
18+ let mut x = 0 ;
19+
20+ for i in 0 ..4 {
21+ //~^ ERROR constant contains unimplemented expression type
22+ //~| ERROR constant contains unimplemented expression type
23+ //~| ERROR references in constants may only refer to immutable values
24+ //~| ERROR calls in constants are limited to constant functions, tuple
25+ // structs and tuple variants
26+ x += i;
27+ }
28+
29+ for i in 0 ..4 {
30+ x += i;
31+ }
32+
33+ x
34+ } ;
35+
36+ const _: i32 = {
37+ let mut x = 0 ;
38+
39+ loop {
40+ x += 1 ;
41+ if x == 4 {
42+ //~^ ERROR constant contains unimplemented expression type
43+ //~| ERROR constant contains unimplemented expression type
44+ break ;
45+ }
46+ }
47+
48+ loop {
49+ x += 1 ;
50+ if x == 8 {
51+ break ;
52+ }
53+ }
54+
55+ x
56+ } ;
57+
58+ fn main ( ) { }
Original file line number Diff line number Diff line change 1+ error[E0019]: constant contains unimplemented expression type
2+ --> $DIR/const-loop.rs:4:11
3+ |
4+ LL | while x < 4 {
5+ | ^^^^^
6+
7+ error[E0019]: constant contains unimplemented expression type
8+ --> $DIR/const-loop.rs:4:5
9+ |
10+ LL | / while x < 4 {
11+ LL | |
12+ LL | |
13+ LL | | x += 1;
14+ LL | | }
15+ | |_____^
16+
17+ error[E0015]: calls in constants are limited to constant functions, tuple structs and tuple variants
18+ --> $DIR/const-loop.rs:20:14
19+ |
20+ LL | for i in 0..4 {
21+ | ^^^^
22+
23+ error[E0019]: constant contains unimplemented expression type
24+ --> $DIR/const-loop.rs:20:14
25+ |
26+ LL | for i in 0..4 {
27+ | ^^^^
28+
29+ error[E0017]: references in constants may only refer to immutable values
30+ --> $DIR/const-loop.rs:20:14
31+ |
32+ LL | for i in 0..4 {
33+ | ^^^^ constants require immutable values
34+
35+ error[E0019]: constant contains unimplemented expression type
36+ --> $DIR/const-loop.rs:20:9
37+ |
38+ LL | for i in 0..4 {
39+ | ^
40+
41+ error[E0019]: constant contains unimplemented expression type
42+ --> $DIR/const-loop.rs:41:12
43+ |
44+ LL | if x == 4 {
45+ | ^^^^^^
46+
47+ error[E0019]: constant contains unimplemented expression type
48+ --> $DIR/const-loop.rs:41:9
49+ |
50+ LL | / if x == 4 {
51+ LL | |
52+ LL | |
53+ LL | | break;
54+ LL | | }
55+ | |_________^
56+
57+ error: aborting due to 8 previous errors
58+
59+ Some errors have detailed explanations: E0015, E0017, E0019.
60+ For more information about an error, try `rustc --explain E0015`.
You can’t perform that action at this time.
0 commit comments