-
-
Notifications
You must be signed in to change notification settings - Fork 15k
Using while in const fn results in a misleading error message on stable #61508
Copy link
Copy link
Closed
Labels
A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)Area: Constant evaluation, covers all const contexts (static, const fn, ...)A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsE-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.
Description
Metadata
Metadata
Assignees
Labels
A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)Area: Constant evaluation, covers all const contexts (static, const fn, ...)A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsE-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.
Type
Fields
Give feedbackNo fields configured for issues without a type.
Playground Link
When
whileis used in aconst fnon 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
whileis 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