-
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)C-bugCategory: This is a bug.Category: This is a bug.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.requires-nightlyThis issue requires a nightly compiler in some way.This issue requires a nightly compiler in some way.
Description
The following code does NOT compile:
#![feature(const_generics)]
struct Collatz<const N: Option<usize>>;
impl <const N: usize> Collatz<{Some(N)}> {
}
fn main() {
}
it errors with:
error[E0207]: the const parameter `N` is not constrained by the impl trait, self type, or predicates
--> src/main.rs:5:13
|
5 | impl <const N: usize> Collatz<{Some(N)}> {
| ^ unconstrained const parameter
However, when using normal generics in the places of the const generics, wrapping the T
in an Option
and sticking that into the Collatz
struct does work:
struct Collatz<T>([T; 0]);
impl <T> Collatz<Option<T>> {}
Is it intended that const generic dont mimmic this behaviour?
MingweiSamuel
Metadata
Metadata
Assignees
Labels
A-const-genericsArea: const generics (parameters and arguments)Area: const generics (parameters and arguments)C-bugCategory: This is a bug.Category: This is a bug.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.requires-nightlyThis issue requires a nightly compiler in some way.This issue requires a nightly compiler in some way.