Closed
Description
I tried this code:
trait Trait: SuperTrait {
fn array() -> [u8; Self::SIZE];
}
trait SuperTrait {
const SIZE: usize;
}
I expected to see this happen: an error that would help me write the correct code.
Instead, this happened: rustc tells me to duplicate the supertrait bound:
error[E0599]: no associated item named `SIZE` found for type parameter `Self` in the current scope
--> src/lib.rs:2:30
|
2 | fn array() -> [u8; Self::SIZE];
| ^^^^ associated item not found in `Self`
|
= help: items from traits can only be used if the type parameter is bounded by the trait
help: the following trait defines an item `SIZE`, perhaps you need to add another supertrait for it:
|
1 | trait Trait: SuperTrait + SuperTrait {
| ^^^^^^^^^^^^
This happens on both stable and nightly.
(I think it should potentially suggest <Self as SuperTrait>::Size
in this case, but that doesn't seem to work either, see #72192.)