Closed
Description
I tried this code:
trait Foo {
fn foo() -> impl Stream<Item = impl Stream<Item = impl Future<Output = ()>>> {
if true {
unimplemented!()
} else {
let f = futures::future::ready(());
let s1 = futures::stream::once(async { f });
futures::stream::once(async { s1 })
}
}
}
I expected to see this happen: compiles, or a helpful error message
Instead, this happened: Confusing error message, there doesn't seem to be a future that could be awaited?...
Interestingly if the default implementation is removed, it compiles. Playground: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=6d9d947523afbecf604d1971f58bbc48
error[E0271]: type mismatch resolving `<impl Stream<Item = impl Future<Output = ()>> as Stream>::Item == impl Future<Output = ()>`
--> /home/akos/projects/rust/tarpc/tarpc/src/server/incoming.rs:49:36
|
49 | fn foo() -> impl Stream<Item = impl Stream<Item = impl Future<Output = ()>>> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected associated type, found future
|
= help: consider `await`ing on both `Future`s
note: required by a bound in `Foo::{opaque#0}`
--> /home/akos/projects/rust/tarpc/tarpc/src/server/incoming.rs:49:48
|
49 | fn foo() -> impl Stream<Item = impl Stream<Item = impl Future<Output = ()>>> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `Foo::{opaque#0}`
For more information about this error, try `rustc --explain E0271`.
Meta
rustc --version --verbose
:
rustc 1.75.0-nightly (1c05d50c8 2023-10-21)
binary: rustc
commit-hash: 1c05d50c8403c56d9a8b6fb871f15aaa26fb5d07
commit-date: 2023-10-21
host: x86_64-unknown-linux-gnu
release: 1.75.0-nightly
LLVM version: 17.0.3
Backtrace
N/A