Open cramertj opened 2 weeks ago
Note: this issue generalizes somewhat to other GAT-containing traits, for example:
trait Super {
type Assoc<'a>;
}
trait Child: Super {}
fn take_dyn(_: &dyn Child) {}
reports
error[E0038]: the trait `Super` cannot be made into an object
--> src/lib.rs:7:21
|
7 | fn take_dyn(_: &dyn Child) {}
| ^^^^^ `Super` cannot be made into an object
|
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> src/lib.rs:2:10
|
1 | trait Super {
| ----- this trait cannot be made into an object...
2 | type Assoc<'a>;
| ^^^^^ ...because it contains the generic associated type `Assoc`
= help: consider moving `Assoc` to another trait
error[E0038]: the trait `Child` cannot be made into an object
--> src/lib.rs:7:17
|
7 | fn take_dyn(_: &dyn Child) {}
| ^^^^^^^^^ `Child` cannot be made into an object
|
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> src/lib.rs:2:10
|
2 | type Assoc<'a>;
| ^^^^^ ...because it contains the generic associated type `Assoc`
...
5 | trait Child: Super {}
| ----- this trait cannot be made into an object...
= help: consider moving `Assoc` to another trait
For more information about this error, try `rustc --explain E0038`.
error: could not compile `playground` (lib) due to 2 previous errors
Code
Current output
Desired output
Rationale and extra context
The current error output spits out four related issues where only one is needed. Additionally, none provides quite the right context, and all reference implementation details of
AsyncFn
that users may not be concerned with.Rust Version
2024-11-05 nightly