Closed
Description
trait Adapter {
const LINKS: usize;
}
struct Foo<A: Adapter> {
adapter: A,
links: [u32; A::LINKS],
}
error[E0599]: no associated item named `LINKS` found for type `A` in the current scope
--> src/lib.rs:7:21
|
7 | links: [u32; A::LINKS],
| ^^^^^ associated item not found in `A`
|
= help: items from traits can only be used if the type parameter is bounded by the trait
help: the following trait defines an item `LINKS`, perhaps you need to restrict type parameter `A` with it:
|
5 | struct Foo<A: Adapter + Adapter> {
| ^^^^^^^^^^^^
At the same time on nightly with #![feature(const_generics)]
error description is much better:
#![feature(const_generics)]
trait Adapter {
const LINKS: usize;
}
struct Foo<A: Adapter> {
adapter: A,
links: [u32; A::LINKS],
}
error: constant expression depends on a generic parameter
--> src/lib.rs:8:5
|
8 | links: [u32; A::LINKS],
| ^^^^^^^^^^^^^^^^^^^^^^
|
= note: this may fail depending on what value the parameter takes