- 
                Notifications
    
You must be signed in to change notification settings  - Fork 13.9k
 
Open
Labels
A-async-awaitArea: Async & AwaitArea: Async & AwaitA-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsAsyncAwait-TriagedAsync-await issues that have been triaged during a working group meeting.Async-await issues that have been triaged during a working group meeting.D-confusingDiagnostics: Confusing error or lint that should be reworked.Diagnostics: Confusing error or lint that should be reworked.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
Credit to @Ciel-MC for discovering this.
I tried this code:
use futures::prelude::future::{join_all, FutureExt};
fn foo_is_send() -> impl Send {
    foo()
}
static THING: () = ();
async fn foo() {
    let updates = [async { &THING }.then(|_| async {})];
    join_all(updates).await;
}I expected the code to compile without errors. Instead, I got the following compile error:
   Compiling playground v0.0.1 (/playground)
error: implementation of `FnOnce` is not general enough
 --> src/lib.rs:4:5
  |
4 |     foo()
  |     ^^^^^ implementation of `FnOnce` is not general enough
  |
  = note: closure with signature `fn(&'0 ()) -> {async block@src/lib.rs:10:46: 10:54}` must implement `FnOnce<(&'1 (),)>`, for any two lifetimes `'0` and `'1`...
  = note: ...but it actually implements `FnOnce<(&(),)>`
error: could not compile `playground` (lib) due to 1 previous errorPossibly related to #126044
See also #126550, which has similar reproduction code.
Meta
Tested on the playground with stable (1.79.0) and nightly (1.81.0-nightly (2024-06-15 3cf924b))
athre0z and tyilo
Metadata
Metadata
Assignees
Labels
A-async-awaitArea: Async & AwaitArea: Async & AwaitA-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsAsyncAwait-TriagedAsync-await issues that have been triaged during a working group meeting.Async-await issues that have been triaged during a working group meeting.D-confusingDiagnostics: Confusing error or lint that should be reworked.Diagnostics: Confusing error or lint that should be reworked.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.