Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unhelpful error message with async usage of Iterator #63385

Closed
nycex opened this issue Aug 8, 2019 · 2 comments
Closed

Unhelpful error message with async usage of Iterator #63385

nycex opened this issue Aug 8, 2019 · 2 comments

Comments

@nycex
Copy link

@nycex nycex commented Aug 8, 2019

I'm not sure, if the behaviour itself is a bug or not, but the error message is surely not helpful.
Code:

#![feature(async_await)]
use futures::future::FutureExt;
use futures::future::TryFutureExt;
use futures::stream::StreamExt;
fn main() {
    tokio::run(function().unit_error().boxed().compat());
}
async fn function() {
    let id_list = "test_string";
    let futures = futures::stream::iter(id_list.lines())
        .map(move |id| some_async_function(id.to_string()))
        .buffer_unordered(10);
    futures.for_each(|_| async {}).await;
}
async fn some_async_function(str: String) {}

The error I get:

error: implementation of `std::iter::Iterator` is not general enough
 --> src/main.rs:6:40
  |
6 |     tokio::run(function().unit_error().boxed().compat());
  |                                        ^^^^^
  |
  = note: `std::iter::Iterator` would have to be implemented for the type `std::str::Lines<'0>`, for any lifetime `'0`
  = note: but `std::iter::Iterator` is actually implemented for the type `std::str::Lines<'1>`, for some specific lifetime `'1`

error: aborting due to previous error

error: Could not compile `async_debug`.

To learn more, run the command again with --verbose.

dependencies:

[depdendencies]
tokio = "0.1.22"
futures-preview = { version = "0.3.0-alpha.17", features = ["compat"]}

rustc version: rustc 1.38.0-nightly (ad7c55e 2019-08-07)

@gwik
Copy link

@gwik gwik commented Feb 17, 2020

I had the same error using using filter() combinator on a stream and then trying to spawn it. The message leaves me clueless.

Loading

@dtolnay
Copy link
Member

@dtolnay dtolnay commented Feb 25, 2020

Closing in favor of #64552 which is the same issue but has some more investigation in the thread.

Loading

@dtolnay dtolnay closed this Feb 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants