Open
Description
I tried this code: [playground]
pub trait Trait {}
pub trait WithAssoc {
type Assoc;
}
pub trait WithSizedAssoc: WithAssoc
where
Self::Assoc: Trait,
{
}
pub struct S<T: WithSizedAssoc>(T::Assoc);
I expected this to compile. Instead, it gives the following error:
error[[E0277]](https://doc.rust-lang.org/stable/error-index.html#E0277): the trait bound `<T as WithAssoc>::Assoc: Trait` is not satisfied
--> src/lib.rs:13:17
|
13 | pub struct S<T: WithSizedAssoc>(T::Assoc);
| ^^^^^^^^^^^^^^ the trait `Trait` is not implemented for `<T as WithAssoc>::Assoc`
|
note: required by a bound in `WithSizedAssoc`
--> src/lib.rs:9:18
|
7 | pub trait WithSizedAssoc: WithAssoc
| -------------- required by a bound in this
8 | where
9 | Self::Assoc: Trait,
| ^^^^^ required by this bound in `WithSizedAssoc`
help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement
|
13 | pub struct S<T: WithSizedAssoc>(T::Assoc) where <T as WithAssoc>::Assoc: Trait;
| ++++++++++++++++++++++++++++++++++++
For more information about this error, try `rustc --explain E0277`.
Meta
playground 1.66.0-nightly (2022-10-21 5c8bff7)