2024-10-09 13:34:45 +00:00
|
|
|
//@ compile-flags: --edition=2021
|
|
|
|
|
2024-11-02 22:44:12 +00:00
|
|
|
use std::future::Future;
|
2024-10-09 13:34:45 +00:00
|
|
|
|
2024-11-02 22:44:12 +00:00
|
|
|
fn invalid_future() -> impl Future {}
|
2024-12-26 19:13:50 +00:00
|
|
|
//~^ ERROR `()` is not a future
|
2024-10-09 13:34:45 +00:00
|
|
|
|
2024-11-02 22:44:12 +00:00
|
|
|
fn create_complex_future() -> impl Future<Output = impl ReturnsSend> {
|
|
|
|
async { &|| async { invalid_future().await } }
|
2024-10-09 13:34:45 +00:00
|
|
|
}
|
|
|
|
|
2024-11-02 22:44:12 +00:00
|
|
|
fn coerce_impl_trait() -> impl Future<Output = impl Send> {
|
|
|
|
create_complex_future()
|
2024-10-09 13:34:45 +00:00
|
|
|
}
|
|
|
|
|
2024-11-02 22:44:12 +00:00
|
|
|
trait ReturnsSend {}
|
2024-10-09 13:34:45 +00:00
|
|
|
|
2024-11-02 22:44:12 +00:00
|
|
|
impl<F, R> ReturnsSend for F
|
2024-10-09 13:34:45 +00:00
|
|
|
where
|
|
|
|
F: Fn() -> R,
|
|
|
|
R: Send,
|
|
|
|
{
|
|
|
|
}
|
2024-12-26 19:13:50 +00:00
|
|
|
|
|
|
|
fn main() {}
|