playground
trait TcpStack {
type Connection<'a>: Sized where Self: 'a;
async fn connect<'a>(&'a self) -> Self::Connection<'a>;
}
fails with
error[E0309]: the parameter type `Self` may not live long enough
--> src/lib.rs:6:39
|
6 | async fn connect<'a>(&'a self) -> Self::Connection<'a>;
| ^^^^^^^^^^^^^^^^^^^^
|
= help: consider adding an explicit lifetime bound `Self: 'a`...
= note: ...so that the type `Self` will meet its required lifetime bounds...
note: ...that is required by this bound
--> src/lib.rs:5:44
|
5 | type Connection<'a>: Sized where Self: 'a;
| ^^
However, in the method context, Self: 'a is already implied by having a &'a self argument. The equivalent without async builds fine thanks to that, I think the async one should too.
@rustbot label F-async_fn_in_trait
playground
fails with
However, in the method context,
Self: 'ais already implied by having a&'a selfargument. The equivalent withoutasyncbuilds fine thanks to that, I think theasyncone should too.@rustbot label F-async_fn_in_trait