Using while
in const fn
results in a misleading error message on stable
#61508
Labels
A-const-eval
Area: Constant evaluation, covers all const contexts (static, const fn, ...)
A-diagnostics
Area: Messages for errors, warnings, and lints
E-easy
Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.
Playground Link
When
while
is used in aconst fn
on stable, it produces an error message:`if`, `match`, `&&` and `||` are not stable in const fn
. This is a bit confusing because the function does not explicitly containif
,match
,&&
, or||
.I would expect the error message to also mention that
while
is disallowed, or say that "loops are not allowed in const fn" (which it does whenloop {}
construct is encountered).(It seems like it would be even better to have a specific error message for the disallowed construct that the compiler encounters rather than just providing a list of disallowed constructs, if this is possible architecturally.)
rustc version
The text was updated successfully, but these errors were encountered: