-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-const-genericsArea: const generics (parameters and arguments)Area: const generics (parameters and arguments)A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-parserArea: The lexing & parsing of Rust source code to an ASTArea: The lexing & parsing of Rust source code to an ASTC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.D-confusingDiagnostics: Confusing error or lint that should be reworked.Diagnostics: Confusing error or lint that should be reworked.D-newcomer-roadblockDiagnostics: Confusing error or lint; hard to understand for new users.Diagnostics: Confusing error or lint; hard to understand for new users.D-papercutDiagnostics: An error or lint that needs small tweaks.Diagnostics: An error or lint that needs small tweaks.F-const_generics`#![feature(const_generics)]``#![feature(const_generics)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.const-generics-bad-diagnosticsAn error is correctly emitted, but is confusing, for `min_const_generics`.An error is correctly emitted, but is confusing, for `min_const_generics`.
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
A-const-genericsArea: const generics (parameters and arguments)Area: const generics (parameters and arguments)A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-parserArea: The lexing & parsing of Rust source code to an ASTArea: The lexing & parsing of Rust source code to an ASTC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.D-confusingDiagnostics: Confusing error or lint that should be reworked.Diagnostics: Confusing error or lint that should be reworked.D-newcomer-roadblockDiagnostics: Confusing error or lint; hard to understand for new users.Diagnostics: Confusing error or lint; hard to understand for new users.D-papercutDiagnostics: An error or lint that needs small tweaks.Diagnostics: An error or lint that needs small tweaks.F-const_generics`#![feature(const_generics)]``#![feature(const_generics)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.const-generics-bad-diagnosticsAn error is correctly emitted, but is confusing, for `min_const_generics`.An error is correctly emitted, but is confusing, for `min_const_generics`.