Closed
Description
I tried this code:
#![feature(const_generics)]
struct Foo<const N: usize>([(); N]);
type A = Foo<std::mem::size_of::<u8>()>;
It fails to parse with
error: expected one of `!`, `+`, `,`, `::`, or `>`, found `(`
--> src/lib.rs:12:37
|
4 | type A = Foo<std::mem::size_of::<u8>()>;
| ^ expected one of `!`, `+`, `,`, `::`, or `>`
I assume that this is supposed to work though, since this code is accepted:
const X: usize = std::mem::size_of::<u8>();
type A = Foo<X>;
Meta
rustc --version --verbose
:
1.44.0-nightly (2020-04-02 537ccdf3ac44c8c7a8d3)
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.Diagnostics: Confusing error or lint that should be reworked.Diagnostics: Confusing error or lint; hard to understand for new users.Diagnostics: An error or lint that needs small tweaks.`#![feature(const_generics)]`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`.