-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
C-bugCategory: This is a bug.Category: This is a bug.F-generic_const_exprs`#![feature(generic_const_exprs)]``#![feature(generic_const_exprs)]`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
Example:
trait Foo {
const N: usize;
const ARRAY: [i32;Self::N];
}
The compiler will report an error:
error: unconstrained generic constant
--> src/main.rs:38:5
|
38 | const ARRAY: [i32;Self::N];
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: try adding a `where` bound using this expression: `where [(); Self::N]:`
Honestly speaking, I don't get what the suggestion means. Is it allowed to use generic_const_exprs like this? Or the only way to do this is by writing
trait Foo<const N: usize> {
const ARRAY: [i32;N];
}
?
Metadata
Metadata
Assignees
Labels
C-bugCategory: This is a bug.Category: This is a bug.F-generic_const_exprs`#![feature(generic_const_exprs)]``#![feature(generic_const_exprs)]`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.