-
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 ASTD-confusingDiagnostics: Confusing error or lint that should be reworked.Diagnostics: Confusing error or lint that should be reworked.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.
Description
Given the following code (playground):
struct NInts<const N: usize>([u8; N]);
impl NInts<const N: usize> {}
The current output is fairly uninformative:
error: expected one of `>`, a const expression, lifetime, or type, found keyword `const`
--> src/lib.rs:2:11
|
2 | impl NInts<const N: usize> {}
| ^^^^^ expected one of `>`, a const expression, lifetime, or type
Ideally the output should look something like this (perhaps with slightly clearer wording 😅):
error: generic parameter declarations on `impl` blocks must be attached to `impl`
--> src/lib.rs:2:11
|
2 | impl NInts<const N: usize> {}
| ^^^^^^^^^^^^^^ cannot declare a const parameter here
help: move the generic parameter declaration
|
2 | impl<const N: usize> NInts<N> {}
| ---------------- -
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 ASTD-confusingDiagnostics: Confusing error or lint that should be reworked.Diagnostics: Confusing error or lint that should be reworked.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.