Mark 'match' as constant expression, if appropriate #42906
Labels
A-const-eval
Area: Constant evaluation, covers all const contexts (static, const fn, ...)
C-enhancement
Category: An issue proposing an enhancement or a PR with one.
Small-ish reproducing example (Play):
Expected / desired behavior of the compiler:
Compiles without warning or error.
More generally:
match
expressions are allowed in definitions of constants, if the matching expression, all clauses, and all value expressions are constant. (Or something like that.)Actual behavior of the compiler:
Compilation error
[E0019]: constant contains unimplemented expression type
.More generally:
match
does not seem to be permitted at all.Occurrence in bugtracker:
I have found no other instance in Google, and GitHub only lists #11411, which is the same error with a different syntax element.
Btw,
if
is not permitted either, soconst MAGIC: u32 = if N == 4 { 42 } else { 1337 };
fails, too.The text was updated successfully, but these errors were encountered: