Closed
Description
Defaults are currently not implemented in const generics. With min_const_generics
stabilising soon, I've been using them more and one thing that is surprising is the lack of defaults. Especially when you try to declare a default, the error message provides a unexpected syntax error, when I would expect a "defaults in const generics is not implemented" error, leading you to think that there's another syntax that you need to use as opposed to it just not being available.
#![feature(min_const_generics)]
fn foo<const NUM: usize = 0>() -> usize {
NUM
}
Error Message
error: expected one of `!`, `(`, `+`, `,`, `::`, `<`, or `>`, found `=`
--> src/lib.rs:3:25
|
3 | fn foo<const NUM: usize = 0>() -> usize {
| ^ expected one of 7 possible tokens
error: aborting due to previous error
Metadata
Metadata
Assignees
Labels
Area: const generics (parameters and arguments)Area: Messages for errors, warnings, and lintsArea: The lexing & parsing of Rust source code to an ASTCategory: An issue proposing an enhancement or a PR with one.Relevant to the compiler team, which will review and decide on the PR/issue.An error is correctly emitted, but is confusing, for `min_const_generics`.