Skip to content

Commit b7f417d

Browse files
committed
Remove try_poll_next method
1 parent 3601bb7 commit b7f417d

18 files changed

+24
-63
lines changed

futures-core/src/stream.rs

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -154,32 +154,14 @@ where
154154
}
155155
}
156156

157-
mod private_try_stream {
158-
use super::Stream;
159-
160-
pub trait Sealed {}
161-
162-
impl<S, T, E> Sealed for S where S: ?Sized + Stream<Item = Result<T, E>> {}
163-
}
164-
165157
/// A convenience for streams that return `Result` values that includes
166158
/// a variety of adapters tailored to such futures.
167-
pub trait TryStream: Stream + private_try_stream::Sealed {
159+
pub trait TryStream: Stream<Item = Result<Self::Ok, Self::Error>> {
168160
/// The type of successful values yielded by this future
169161
type Ok;
170162

171163
/// The type of failures yielded by this future
172164
type Error;
173-
174-
/// Poll this `TryStream` as if it were a `Stream`.
175-
///
176-
/// This method is a stopgap for a compiler limitation that prevents us from
177-
/// directly inheriting from the `Stream` trait; in the future it won't be
178-
/// needed.
179-
fn try_poll_next(
180-
self: Pin<&mut Self>,
181-
cx: &mut Context<'_>,
182-
) -> Poll<Option<Result<Self::Ok, Self::Error>>>;
183165
}
184166

185167
impl<S, T, E> TryStream for S
@@ -188,13 +170,6 @@ where
188170
{
189171
type Ok = T;
190172
type Error = E;
191-
192-
fn try_poll_next(
193-
self: Pin<&mut Self>,
194-
cx: &mut Context<'_>,
195-
) -> Poll<Option<Result<Self::Ok, Self::Error>>> {
196-
self.poll_next(cx)
197-
}
198173
}
199174

200175
#[cfg(feature = "alloc")]

futures-util/src/compat/compat03as01.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ where
114114
type Error = St::Error;
115115

116116
fn poll(&mut self) -> Poll01<Option<Self::Item>, Self::Error> {
117-
with_context(self, |inner, cx| match inner.try_poll_next(cx)? {
117+
with_context(self, |inner, cx| match inner.poll_next(cx)? {
118118
task03::Poll::Ready(None) => Ok(Async01::Ready(None)),
119119
task03::Poll::Ready(Some(t)) => Ok(Async01::Ready(Some(t))),
120120
task03::Poll::Pending => Ok(Async01::NotReady),

futures-util/src/future/try_future/try_flatten.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ where
9595
}
9696
},
9797
TryFlattenProj::Second { f } => {
98-
let output = ready!(f.try_poll_next(cx));
98+
let output = ready!(f.poll_next(cx));
9999
if output.is_none() {
100100
self.set(Self::Empty);
101101
}

futures-util/src/sink/send_all.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ where
8181

8282
loop {
8383
let this = self.as_mut().project();
84-
match this.stream.try_poll_next(cx)? {
84+
match this.stream.poll_next(cx)? {
8585
Poll::Ready(Some(item)) => ready!(self.as_mut().try_start_send(cx, item))?,
8686
Poll::Ready(None) => {
8787
ready!(Pin::new(this.sink).poll_flush(cx))?;

futures-util/src/stream/try_stream/and_then.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ where
6262
let item = ready!(fut.try_poll(cx));
6363
this.future.set(None);
6464
break Some(item);
65-
} else if let Some(item) = ready!(this.stream.as_mut().try_poll_next(cx)?) {
65+
} else if let Some(item) = ready!(this.stream.as_mut().poll_next(cx)?) {
6666
this.future.set(Some((this.f)(item)));
6767
} else {
6868
break None;

futures-util/src/stream/try_stream/into_async_read.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::stream::TryStreamExt;
1+
use crate::stream::StreamExt;
22
use core::pin::Pin;
33
use futures_core::ready;
44
use futures_core::stream::TryStream;
@@ -69,7 +69,7 @@ where
6969

7070
return Poll::Ready(Ok(len));
7171
}
72-
ReadState::PendingChunk => match ready!(self.stream.try_poll_next_unpin(cx)) {
72+
ReadState::PendingChunk => match ready!(self.stream.poll_next_unpin(cx)) {
7373
Some(Ok(chunk)) => {
7474
if !chunk.as_ref().is_empty() {
7575
self.state = ReadState::Ready { chunk, chunk_start: 0 };
@@ -121,7 +121,7 @@ where
121121
{
122122
fn poll_fill_buf(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<&[u8]>> {
123123
while let ReadState::PendingChunk = self.state {
124-
match ready!(self.stream.try_poll_next_unpin(cx)) {
124+
match ready!(self.stream.poll_next_unpin(cx)) {
125125
Some(Ok(chunk)) => {
126126
if !chunk.as_ref().is_empty() {
127127
self.state = ReadState::Ready { chunk, chunk_start: 0 };

futures-util/src/stream/try_stream/into_stream.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ impl<St: TryStream> Stream for IntoStream<St> {
3535

3636
#[inline]
3737
fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
38-
self.project().stream.try_poll_next(cx)
38+
self.project().stream.poll_next(cx)
3939
}
4040

4141
fn size_hint(&self) -> (usize, Option<usize>) {

futures-util/src/stream/try_stream/mod.rs

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -829,10 +829,10 @@ pub trait TryStreamExt: TryStream {
829829
///
830830
/// let mut buffered = stream_of_futures.try_buffered(10);
831831
///
832-
/// assert!(buffered.try_poll_next_unpin(cx).is_pending());
832+
/// assert!(buffered.poll_next_unpin(cx).is_pending());
833833
///
834834
/// send_two.send(2i32)?;
835-
/// assert!(buffered.try_poll_next_unpin(cx).is_pending());
835+
/// assert!(buffered.poll_next_unpin(cx).is_pending());
836836
/// Ok::<_, i32>(buffered)
837837
/// }).await?;
838838
///
@@ -873,20 +873,6 @@ pub trait TryStreamExt: TryStream {
873873
))
874874
}
875875

876-
// TODO: false positive warning from rustdoc. Verify once #43466 settles
877-
//
878-
/// A convenience method for calling [`TryStream::try_poll_next`] on [`Unpin`]
879-
/// stream types.
880-
fn try_poll_next_unpin(
881-
&mut self,
882-
cx: &mut Context<'_>,
883-
) -> Poll<Option<Result<Self::Ok, Self::Error>>>
884-
where
885-
Self: Unpin,
886-
{
887-
Pin::new(self).try_poll_next(cx)
888-
}
889-
890876
/// Wraps a [`TryStream`] into a stream compatible with libraries using
891877
/// futures 0.1 `Stream`. Requires the `compat` feature to be enabled.
892878
/// ```

futures-util/src/stream/try_stream/or_else.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ where
6363
this.future.set(None);
6464
break Some(item);
6565
} else {
66-
match ready!(this.stream.as_mut().try_poll_next(cx)) {
66+
match ready!(this.stream.as_mut().poll_next(cx)) {
6767
Some(Ok(item)) => break Some(Ok(item)),
6868
Some(Err(e)) => {
6969
this.future.set(Some((this.f)(e)));

futures-util/src/stream/try_stream/try_chunks.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ impl<St: TryStream> Stream for TryChunks<St> {
4848
fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
4949
let mut this = self.as_mut().project();
5050
loop {
51-
match ready!(this.stream.as_mut().try_poll_next(cx)) {
51+
match ready!(this.stream.as_mut().poll_next(cx)) {
5252
// Push the item into the buffer and check whether it is full.
5353
// If so, replace our buffer with a new and empty one and return
5454
// the full one.

futures-util/src/stream/try_stream/try_collect.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ where
4343
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
4444
let mut this = self.project();
4545
Poll::Ready(Ok(loop {
46-
match ready!(this.stream.as_mut().try_poll_next(cx)?) {
46+
match ready!(this.stream.as_mut().poll_next(cx)?) {
4747
Some(x) => this.items.extend(Some(x)),
4848
None => break mem::replace(this.items, Default::default()),
4949
}

futures-util/src/stream/try_stream/try_concat.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ where
3737
let mut this = self.project();
3838

3939
Poll::Ready(Ok(loop {
40-
if let Some(x) = ready!(this.stream.as_mut().try_poll_next(cx)?) {
40+
if let Some(x) = ready!(this.stream.as_mut().poll_next(cx)?) {
4141
if let Some(a) = this.accum {
4242
a.extend(x)
4343
} else {

futures-util/src/stream/try_stream/try_filter.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ where
8080
break this.pending_item.take().map(Ok);
8181
}
8282
*this.pending_item = None;
83-
} else if let Some(item) = ready!(this.stream.as_mut().try_poll_next(cx)?) {
83+
} else if let Some(item) = ready!(this.stream.as_mut().poll_next(cx)?) {
8484
this.pending_fut.set(Some((this.f)(&item)));
8585
*this.pending_item = Some(item);
8686
} else {

futures-util/src/stream/try_stream/try_filter_map.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ where
7373
if item.is_some() {
7474
break item.map(Ok);
7575
}
76-
} else if let Some(item) = ready!(this.stream.as_mut().try_poll_next(cx)?) {
76+
} else if let Some(item) = ready!(this.stream.as_mut().poll_next(cx)?) {
7777
// No item in progress, but the stream is still going
7878
this.pending.set(Some((this.f)(item)));
7979
} else {

futures-util/src/stream/try_stream/try_flatten.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,12 @@ where
5858

5959
Poll::Ready(loop {
6060
if let Some(s) = this.next.as_mut().as_pin_mut() {
61-
if let Some(item) = ready!(s.try_poll_next(cx)?) {
61+
if let Some(item) = ready!(s.poll_next(cx)?) {
6262
break Some(Ok(item));
6363
} else {
6464
this.next.set(None);
6565
}
66-
} else if let Some(s) = ready!(this.stream.as_mut().try_poll_next(cx)?) {
66+
} else if let Some(s) = ready!(this.stream.as_mut().poll_next(cx)?) {
6767
this.next.set(Some(s));
6868
} else {
6969
break None;

futures-util/src/stream/try_stream/try_next.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::stream::TryStreamExt;
1+
use crate::stream::StreamExt;
22
use core::pin::Pin;
33
use futures_core::future::{FusedFuture, Future};
44
use futures_core::stream::{FusedStream, TryStream};
@@ -29,6 +29,6 @@ impl<St: ?Sized + TryStream + Unpin> Future for TryNext<'_, St> {
2929
type Output = Result<Option<St::Ok>, St::Error>;
3030

3131
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
32-
self.stream.try_poll_next_unpin(cx)?.map(Ok)
32+
self.stream.poll_next_unpin(cx)?.map(Ok)
3333
}
3434
}

futures-util/src/stream/try_stream/try_skip_while.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ where
6464
let mut this = self.project();
6565

6666
if *this.done_skipping {
67-
return this.stream.try_poll_next(cx);
67+
return this.stream.poll_next(cx);
6868
}
6969

7070
Poll::Ready(loop {
@@ -77,7 +77,7 @@ where
7777
*this.done_skipping = true;
7878
break item.map(Ok);
7979
}
80-
} else if let Some(item) = ready!(this.stream.as_mut().try_poll_next(cx)?) {
80+
} else if let Some(item) = ready!(this.stream.as_mut().poll_next(cx)?) {
8181
this.pending_fut.set(Some((this.f)(&item)));
8282
*this.pending_item = Some(item);
8383
} else {

futures-util/src/stream/try_stream/try_take_while.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ where
8282
*this.done_taking = true;
8383
break None;
8484
}
85-
} else if let Some(item) = ready!(this.stream.as_mut().try_poll_next(cx)?) {
85+
} else if let Some(item) = ready!(this.stream.as_mut().poll_next(cx)?) {
8686
this.pending_fut.set(Some((this.f)(&item)));
8787
*this.pending_item = Some(item);
8888
} else {

0 commit comments

Comments
 (0)