]> git.lizzy.rs Git - rust.git/blob - src/librustc_error_codes/error_codes/E0744.md
Auto merge of #66396 - smmalis37:pythontest, r=alexcrichton
[rust.git] / src / librustc_error_codes / error_codes / E0744.md
1 Control-flow expressions are not allowed inside a const context.
2
3 At the moment, `if` and `match`, as well as the looping constructs `for`,
4 `while`, and `loop`, are forbidden inside a `const`, `static`, or `const fn`.
5
6 ```compile_fail,E0744
7 const _: i32 = {
8     let mut x = 0;
9     loop {
10         x += 1;
11         if x == 4 {
12             break;
13         }
14     }
15     x
16 };
17 ```
18
19 This will be allowed at some point in the future, but the implementation is not
20 yet complete. See the tracking issue for [conditionals] or [loops] in a const
21 context for the current status.
22
23 [conditionals]: https://github.com/rust-lang/rust/issues/49146
24 [loops]: https://github.com/rust-lang/rust/issues/52000