Open
Description
I tried this code:
let _: &(dyn Future<Output = ()> + Send) = &async {
let _drop_after_await = std::iter::empty()
.map(|_: &()| [async {}])
.flatten();
async {}.await;
};
I expected that the code should compile without errors.
However, it produces a compile error:
error: implementation of `FnOnce` is not general enough
--> src/main.rs:4:48
|
4 | let _: &(dyn Future<Output = ()> + Send) = &async {
| ________________________________________________^
5 | | let _drop_after_await = std::iter::empty()
6 | | .map(|_: &()| [async {}])
7 | | .flatten();
8 | |
9 | | async {}.await;
10 | | };
| |_____^ implementation of `FnOnce` is not general enough
|
= note: closure with signature `fn(&'0 ()) -> [impl Future<Output = ()>; 1]` must implement `FnOnce<(&'1 (),)>`, for any two lifetimes `'0` and `'1`...
= note: ...but it actually implements `FnOnce<(&(),)>`
The bug doesn't reproduce if we remove the Send
requirement or .flatten()
combinator 🤔.
Meta
rustc -V
:
rustc 1.61.0 (fe5b13d68 2022-05-18)
Metadata
Metadata
Assignees
Labels
Area: Async & AwaitArea: Lifetimes / regionsArea: Trait systemAsync-await issues that have been triaged during a working group meeting.Category: This is a bug.Relevant to the compiler team, which will review and decide on the PR/issue.Relevant to the types team, which will review and decide on the PR/issue.Working group: Async & await