Closed
Description
I have a simple program below that is trying to call poll_next
on a T: Stream
. The compiler seems to ignore the trait bound, and suggests adding the exact trait bound that is already in use.
This is using the current beta rust version:
rustc 1.39.0-beta.5 (fa5c2f3e5 2019-10-02)
pub struct StreamForwarder<T> {
upstream: T,
}
impl<T: futures_core::stream::Stream> Stream for StreamForwarder<T> {
type Item = ();
fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
self.upstream.poll_next()
}
}
error[E0599]: no method named `poll_next` found for type `T` in the current scope
--> src/main.rs:13:23
|
13 | self.upstream.poll_next()
| ^^^^^^^^^ method not found in `T`
|
= help: items from traits can only be used if the type parameter is bounded by the trait
help: the following trait defines an item `poll_next`, perhaps you need to restrict type parameter `T` with it:
|
9 | impl<T: futures_core::stream::Stream + futures_core::stream::Stream> Stream for StreamForwarder<T> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to previous error
For more information about this error, try `rustc --explain E0599`.
error: could not compile `poll_next_bug`.
A complete git repo reproducing the issue is here: https://github.com/fuchsnj/poll_next_bug
(remember to run rustup override set beta
)