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

Using while in const fn results in a misleading error message on stable #61508

Closed
not-an-aardvark opened this issue Jun 4, 2019 · 0 comments · Fixed by #61518
Closed

Using while in const fn results in a misleading error message on stable #61508

not-an-aardvark opened this issue Jun 4, 2019 · 0 comments · Fixed by #61518
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.

Comments

@not-an-aardvark
Copy link
Contributor

Playground Link

When while is used in a const 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 contain if, 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 when loop {} 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
rustc 1.35.0 (3c235d560 2019-05-20)
binary: rustc
commit-hash: 3c235d5600393dfe6c36eeed34042efad8d4f26e
commit-date: 2019-05-20
host: x86_64-apple-darwin
release: 1.35.0
LLVM version: 8.0
@estebank estebank added A-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. labels Jun 4, 2019
Centril added a commit to Centril/rust that referenced this issue Jun 11, 2019
…s, r=Centril

Add loops to doc list of things not stable in const fn

Closes rust-lang#61508
@RalfJung RalfJung added the A-const-eval Area: Constant evaluation, covers all const contexts (static, const fn, ...) label Dec 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants