]> git.proxmox.com Git - rustc.git/blob - src/librustc_error_codes/error_codes/E0744.md
New upstream version 1.47.0~beta.2+dfsg1
[rustc.git] / src / librustc_error_codes / error_codes / E0744.md
1 A control-flow expression was used inside a const context.
2
3 Erroneous code example:
4
5 ```compile_fail,E0744
6 const _: i32 = {
7 let mut x = 0;
8
9 for i in 0..4 { // error!
10 x += i;
11 }
12 };
13 ```
14
15 At the moment, `if` and `match`, as well as the looping constructs `for`,
16 `while`, and `loop`, are forbidden inside a `const`, `static`, or `const fn`.
17
18 This will be allowed at some point in the future, but the implementation is not
19 yet complete. See the tracking issue for [conditionals] or [loops] in a const
20 context for the current status.
21
22 [conditionals]: https://github.com/rust-lang/rust/issues/49146
23 [loops]: https://github.com/rust-lang/rust/issues/52000