You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Trait associated types where Self: Sized interact oddly with dyn safety #106522
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 `dynTrait<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 `dynTrait<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.
Activity
fmease commentedon Jan 26, 2024
The code you posted:
nowadays compiles successfully, namely since oli's PR #112319. Closing as completed then.