Closed
Description
I have this program
#![allow(incomplete_features)]
#![feature(async_fn_in_trait)]
use std::marker::PhantomData;
struct Y<'s,'e:'s>(PhantomData<(&'s (), &'e mut &'e ())>);
trait Tr<'e> {
// Removing async works fine
async fn f<'s>(&self, y: Y<'s, 'e>) -> Y<'s,'e>;
}
That throws this strange compilation error on nightly
Compiling playground v0.0.1 (/playground)
error[[E0478]](https://doc.rust-lang.org/nightly/error-index.html#E0478): lifetime bound not satisfied
--> src/lib.rs:8:44
|
8 | async fn f<'s>(&self, y: Y<'s, 'e>) -> Y<'s,'e>;
| ^^^^^^^^
|
note: lifetime parameter instantiated with the lifetime `'e` as defined here
--> src/lib.rs:6:10
|
6 | trait Tr<'e> {
| ^^
note: but lifetime parameter must outlive the lifetime `'s` as defined here
--> src/lib.rs:8:16
|
8 | async fn f<'s>(&self, y: Y<'s, 'e>) -> Y<'s,'e>;
| ^^
For more information about this error, try `rustc --explain E0478`.
error: could not compile `playground` due to previous error
If I remove async
it works fine. Any idea why this happens?
Edit: this program compiles normally:
use std::marker::PhantomData;
struct Y<'s,'e:'s>(PhantomData<(&'s (), &'e mut &'e ())>);
struct A<'e>(PhantomData<&'e ()>);
impl<'e> A<'e> {
async fn f<'s>(&self, y: Y<'s, 'e>) -> Y<'s,'e> {
y
}
}