]> git.lizzy.rs Git - rust.git/blob - compiler/rustc_error_codes/src/error_codes/E0744.md
Merge commit '928e72dd10749875cbd412f74bfbfd7765dbcd8a' into clippyup
[rust.git] / compiler / rustc_error_codes / src / error_codes / E0744.md
1 An unsupported 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, `for` loops, `.await`, and the `Try` operator (`?`) are forbidden
16 inside a `const`, `static`, or `const fn`.
17
18 This may be allowed at some point in the future, but the implementation is not
19 yet complete. See the tracking issues for [`async`] and [`?`] in `const fn`, and
20 (to support `for` loops in `const fn`) the tracking issues for [`impl const
21 Trait for Ty`] and [`&mut T`] in `const fn`.
22
23 [`async`]: https://github.com/rust-lang/rust/issues/69431
24 [`?`]: https://github.com/rust-lang/rust/issues/74935
25 [`impl const Trait for Ty`]: https://github.com/rust-lang/rust/issues/67792
26 [`&mut T`]: https://github.com/rust-lang/rust/issues/57349