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

Too many type inside async object must be known in this context errors #66445

Open
olegnn opened this issue Nov 15, 2019 · 3 comments
Open

Too many type inside async object must be known in this context errors #66445

olegnn opened this issue Nov 15, 2019 · 3 comments
Assignees
Labels
A-async-await A-diagnostics A-inference AsyncAwait-Triaged C-bug D-verbose E-needs-test T-compiler

Comments

@olegnn
Copy link
Contributor

@olegnn olegnn commented Nov 15, 2019

This code (Playground)

use futures::stream::{iter/*, StreamExt*/};

async fn produce_11_errors() {
    iter(vec![1, 2, 3])/*.collect::<Vec<_>>()*/.await;
}

fn main() {}

currently produces 11 errors:

  • 1 of the trait bound is not satisfied
  • 10 of type inside async object must be known in this context.

If you add elements to vec, it will generate even more.

@jonas-schievink jonas-schievink added A-async-await A-diagnostics A-inference C-bug T-compiler labels Nov 15, 2019
@nikomatsakis nikomatsakis added the AsyncAwait-Triaged label Nov 19, 2019
@estebank estebank added the D-verbose label Dec 3, 2019
@eholk eholk added this to On deck in wg-async work Sep 20, 2021
@doc-jones
Copy link

@doc-jones doc-jones commented Sep 20, 2021

@rustbot claim

@tmandry tmandry moved this from On deck to Claimed in wg-async work Sep 30, 2021
@estebank
Copy link
Contributor

@estebank estebank commented Dec 9, 2021

Current output since 1.54:

error[E0277]: `futures::stream::Iter<std::vec::IntoIter<{integer}>>` is not a future
 --> src/main.rs:4:5
  |
4 |     iter(vec![1, 2, 3])/*.collect::<Vec<_>>()*/.await;
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `futures::stream::Iter<std::vec::IntoIter<{integer}>>` is not a future
  |
  = help: the trait `futures::Future` is not implemented for `futures::stream::Iter<std::vec::IntoIter<{integer}>>`
  = note: futures::stream::Iter<std::vec::IntoIter<{integer}>> must be a future or must implement `IntoFuture` to be awaited
  = note: required because of the requirements on the impl of `std::future::IntoFuture` for `futures::stream::Iter<std::vec::IntoIter<{integer}>>`

@olegnn are there other changes you'd like to see here?

@estebank estebank added the E-needs-test label Dec 9, 2021
@olegnn
Copy link
Contributor Author

@olegnn olegnn commented Dec 21, 2021

@estebank now it looks much better!

However, code like this still produces the same error twice

use futures::stream::*;

async fn same_error_twice() -> Vec<u8> {
    once(async { 0.0 }).collect().await
}

fn main() {}
error[E0277]: the trait bound `Vec<u8>: Extend<{float}>` is not satisfied
  --> src/main.rs:4:5
   |
4  |     once(async { 0.0 }).collect().await
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Extend<{float}>` is not implemented for `Vec<u8>`
   |
   = help: the following implementations were found:
             <Vec<T, A> as Extend<&'a T>>
             <Vec<T, A> as Extend<T>>
   = note: required because of the requirements on the impl of `futures::Future` for `Collect<futures::stream::Once<impl futures::Future>, Vec<u8>>`
note: required by `futures::Future::poll`

error[E0277]: the trait bound `Vec<u8>: Extend<{float}>` is not satisfied
 --> src/main.rs:4:25
  |
4 |     once(async { 0.0 }).collect().await
  |                         ^^^^^^^ the trait `Extend<{float}>` is not implemented for `Vec<u8>`
  |
  = help: the following implementations were found:
            <Vec<T, A> as Extend<&'a T>>
            <Vec<T, A> as Extend<T>>

For more information about this error, try `rustc --explain E0277`.
error: could not compile `playground` due to 2 previous errors

https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=a63224be65d4e278f12786dc0dd497fd

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-async-await A-diagnostics A-inference AsyncAwait-Triaged C-bug D-verbose E-needs-test T-compiler
Projects
Development

No branches or pull requests

5 participants