Skip to content

Unhelpful error message with async usage of Iterator #63385

@nycex

Description

@nycex

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-async-awaitArea: Async & AwaitA-diagnosticsArea: Messages for errors, warnings, and lintsAsyncAwait-TriagedAsync-await issues that have been triaged during a working group meeting.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.requires-nightlyThis issue requires a nightly compiler in some way. When possible, use a F-* label instead.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions