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
Labels
A-async-await Area: Async & Await A-diagnostics Area: Messages for errors, warnings, and lints AsyncAwait-Triaged Async-await issues that have been triaged during a working group meeting. requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@nycex
Copy link

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)

@Centril Centril added A-async-await Area: Async & Await AsyncAwait-Triaged Async-await issues that have been triaged during a working group meeting. requires-nightly This issue requires a nightly compiler in some way. A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. and removed requires-nightly This issue requires a nightly compiler in some way. labels Aug 8, 2019
@gwik
Copy link

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.

@dtolnay
Copy link
Member

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 as completed Feb 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-async-await Area: Async & Await A-diagnostics Area: Messages for errors, warnings, and lints AsyncAwait-Triaged Async-await issues that have been triaged during a working group meeting. requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

4 participants