Open
Description
The following code does not compile:
// Crate versions:
// futures-preview v0.3.0-alpha.18
// runtime v0.3.0-alpha.7
use futures::{prelude::*, stream::FuturesUnordered};
#[runtime::main]
async fn main() {
let entries: Vec<_> = vec![()]
.into_iter()
.map(|x| async { vec![()].into_iter().map(|_| x) })
.collect::<FuturesUnordered<_>>()
.map(stream::iter)
.flatten()
.collect()
.await;
}
It produces this error message:
error[E0308]: mismatched types
--> src\main.rs:3:1
|
3 | #[runtime::main]
| ^^^^^^^^^^^^^^^^ one type is more general than the other
|
= note: expected type `std::ops::FnOnce<(std::iter::Map<std::vec::IntoIter<()>, [closure@src\main.rs:7:51: 7:56 x:&()]>,)>`
found type `std::ops::FnOnce<(std::iter::Map<std::vec::IntoIter<()>, [closure@src\main.rs:7:51: 7:56 x:&()]>,)>`
In this case, the code can be made to compile by adding move
in two places on this line:
// ...
.map(|x| async move { vec![()].into_iter().map(move |_| x) })
// ...
Some possibly related issues: #57362, #60658
rustc version: 1.39.0-nightly (97e58c0d3 2019-09-20)
Metadata
Metadata
Assignees
Labels
Area: Async & AwaitArea: Messages for errors, warnings, and lintsAsync-await issues that have been triaged during a working group meeting.Category: An issue proposing an enhancement or a PR with one.Diagnostics: Confusing error or lint that should be reworked.Diagnostics: Confusing error or lint; hard to understand for new users.Relevant to the compiler team, which will review and decide on the PR/issue.