Improve help for const-able values used in array initialization #113912
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Code
Current output
Desired output
Rationale and extra context
I'm basing this suggestion on two things. One, that if you follow it, the code compiles:
and two, that the diagnostic help you get when you try to use a
const fn
in the repeat position suggests something very similar, see "other cases." It would require the compiler to know that a value that is attempted to be repeated isconst
able though, which I don't know whether it can, but I figured I'd suggest this, and you can reject it if it isn't possible to do.Alternatively, the help text could say something like "if the value can be made
const
, consider creating [...]"Other cases
I was inspired to make this issue based on the output you get when you try to use a
const fn
as an array initializer. For instance, the codeproduces the output
Anything else?
No response
The text was updated successfully, but these errors were encountered: