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

nycex opened this issue Aug 8, 2019 · 0 comments


Copy link

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.

use futures::future::FutureExt;
use futures::future::TryFutureExt;
use futures::stream::StreamExt;
fn main() {
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()))
    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/
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.


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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
2 participants
You can’t perform that action at this time.