Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update E0744 about control flow in const contexts to accurately describe when the error is triggered and why #79087

Merged
merged 1 commit into from
Nov 17, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions compiler/rustc_error_codes/src/error_codes/E0744.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
A control-flow expression was used inside a const context.
An unsupported expression was used inside a const context.

Erroneous code example:

Expand All @@ -12,12 +12,15 @@ const _: i32 = {
};
```

At the moment, `if` and `match`, as well as the looping constructs `for`,
`while`, and `loop`, are forbidden inside a `const`, `static`, or `const fn`.
At the moment, `for` loops, `.await`, and the `Try` operator (`?`) are forbidden
inside a `const`, `static`, or `const fn`.
ThePuzzlemaker marked this conversation as resolved.
Show resolved Hide resolved

This will be allowed at some point in the future, but the implementation is not
yet complete. See the tracking issue for [conditionals] or [loops] in a const
context for the current status.
This may be allowed at some point in the future, but the implementation is not
yet complete. See the tracking issues for [`async`] and [`?`] in `const fn`, and
(to support `for` loops in `const fn`) the tracking issues for [`impl const
Trait for Ty`] and [`&mut T`] in `const fn`.

[conditionals]: https://github.com/rust-lang/rust/issues/49146
[loops]: https://github.com/rust-lang/rust/issues/52000
[`async`]: https://github.com/rust-lang/rust/issues/69431
[`?`]: https://github.com/rust-lang/rust/issues/74935
[`impl const Trait for Ty`]: https://github.com/rust-lang/rust/issues/67792
[`&mut T`]: https://github.com/rust-lang/rust/issues/57349