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 · 2 comments

Unhelpful error message with async usage of Iterator #63385

nycex opened this issue Aug 8, 2019 · 2 comments


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.

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)

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.


Copy link

@dtolnay dtolnay commented Feb 25, 2020

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


@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
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants