Open
Description
Code
use futures::prelude::future::{join_all, FutureExt};
const THING: () = ();
async fn foo() {
let updates = [async {}.then(|()| async move {
&THING
})];
join_all(updates).await;
}
fn trouble() -> impl Send {
foo()
}
Current output
error[E0308]: mismatched types
--> src/main.rs:12:5
|
5 | let updates = [async {}.then(|()| async move {
| _______________________________________-
6 | | &THING
7 | | })];
| | -
| | |
| |_____the expected `async` block
| the found `async` block
...
12 | foo()
| ^^^^^ one type is more general than the other
|
= note: expected `async` block `{async block@src/main.rs:5:39: 7:6}`
found `async` block `{async block@src/main.rs:5:39: 7:6}`
For more information about this error, try `rustc --explain E0308`.
error: could not compile `test_project` (bin "test_project") due to 1 previous error
Desired output
No response
Rationale and extra context
No response
Other cases
No response
Rust Version
rustc 1.79.0 (129f3b996 2024-06-10)
binary: rustc
commit-hash: 129f3b9964af4d4a709d1383930ade12dfe7c081
commit-date: 2024-06-10
host: x86_64-unknown-linux-gnu
release: 1.79.0
LLVM version: 18.1.7
(Happens on nightly too)
Anything else?
The code compiles without the reference, so I'm guessing it's to do with the Future being made "unique" by that even though it doesn't actually contain any "real" captures that should make the closure different.