Given the trait
pub trait Trait {
type Assoc
where
Self: Sized;
fn method(&self);
}
we get that
&dyn Trait is not valid,
error[E0191]: the value of the associated type `Assoc` (from trait `Trait`) must be specified
--> src/lib.rs:9:21
|
2 | type Assoc
| ---------- `Assoc` defined here
...
9 | pub fn test(t: &dyn Trait) {
| ^^^^^ help: specify the associated type: `Trait<Assoc = Type>`
&dyn Trait<Assoc=()> is valid,
- but trying to call methods fails.
error[E0277]: the size for values of type `dyn Trait<Assoc = ()>` cannot be known at compilation time
--> src/lib.rs:10:5
|
10 | t.method();
| ^ ------ required by a bound introduced by this call
| |
| doesn't have a size known at compile-time
|
= help: the trait `Sized` is not implemented for `dyn Trait<Assoc = ()>`
The error message says that the call to Trait::method introduces a Self: Sized bound. There is no such bound on method, however; the bound is on Trait::Assoc.
I have no clue what the "correct" behavior is for this, but it's probably not this.
Given the trait
we get that
&dyn Traitis not valid,&dyn Trait<Assoc=()>is valid,The error message says that the call to
Trait::methodintroduces aSelf: Sizedbound. There is no such bound onmethod, however; the bound is onTrait::Assoc.I have no clue what the "correct" behavior is for this, but it's probably not this.