diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4578ca1697..e098d6a857 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -78,7 +78,7 @@ jobs: rust: # This is the minimum Rust version supported by futures-core, futures-io, futures-sink. # When updating this, the reminder to update the minimum required version in README.md and Cargo.toml. - - '1.36' + - '1.52' runs-on: ubuntu-latest timeout-minutes: 60 steps: @@ -91,7 +91,9 @@ jobs: tool: rust@${{ matrix.rust }},cargo-hack fallback: none # remove dev-dependencies to avoid https://github.com/rust-lang/cargo/issues/4866 - - run: cargo hack --remove-dev-deps --workspace + - run: | + cargo hack --remove-dev-deps --workspace \ + --exclude futures --exclude futures-util --exclude futures-task --exclude futures-macro --exclude futures-executor --exclude futures-channel --exclude futures-test # Check no-default-features - run: | cargo hack build --workspace --ignore-private --no-default-features \ diff --git a/futures-core/Cargo.toml b/futures-core/Cargo.toml index 0f76188b01..749a7a91ae 100644 --- a/futures-core/Cargo.toml +++ b/futures-core/Cargo.toml @@ -3,7 +3,7 @@ name = "futures-core" version = "1.0.0-alpha.0" edition = "2018" # NB: Sync with "Usage" section in README.md and core-msrv job in .github/workflows/ci.yml -rust-version = "1.36" +rust-version = "1.52" license = "MIT OR Apache-2.0" repository = "https://github.com/rust-lang/futures-rs" homepage = "https://rust-lang.github.io/futures-rs" diff --git a/futures-core/README.md b/futures-core/README.md index 96e0e064bc..3600822a81 100644 --- a/futures-core/README.md +++ b/futures-core/README.md @@ -11,7 +11,7 @@ Add this to your `Cargo.toml`: futures-core = "0.3" ``` -The current `futures-core` requires Rust 1.36 or later. +The current `futures-core` requires Rust 1.52 or later. ## License diff --git a/futures-core/src/future.rs b/futures-core/src/future.rs index 042fa81fab..4b59248010 100644 --- a/futures-core/src/future.rs +++ b/futures-core/src/future.rs @@ -2,11 +2,7 @@ #[doc(no_inline)] pub use core::future::Future; -use core::{ - ops::DerefMut, - pin::Pin, - task::{Context, Poll}, -}; +use core::{ops::DerefMut, pin::Pin}; /// An owned dynamically typed [`Future`] for use in cases where you can't /// statically type your result or need to add some indirection. @@ -31,10 +27,10 @@ pub type LocalBoxFuture<'a, T> = Pin + /// should no longer be polled. /// /// `is_terminated` will return `true` if a future should no longer be polled. -/// Usually, this state occurs after `poll` (or `try_poll`) returned -/// `Poll::Ready`. However, `is_terminated` may also return `true` if a future -/// has become inactive and can no longer make progress and should be ignored -/// or dropped rather than being `poll`ed again. +/// Usually, this state occurs after `poll` returned `Poll::Ready`. However, +/// `is_terminated` may also return `true` if a future has become inactive +/// and can no longer make progress and should be ignored or dropped rather +/// than being `poll`ed again. pub trait FusedFuture: Future { /// Returns `true` if the underlying future should no longer be polled. fn is_terminated(&self) -> bool; @@ -56,29 +52,14 @@ where } } -mod private_try_future { - use super::Future; - - pub trait Sealed {} - - impl Sealed for F where F: ?Sized + Future> {} -} - /// A convenience for futures that return `Result` values that includes /// a variety of adapters tailored to such futures. -pub trait TryFuture: Future + private_try_future::Sealed { +pub trait TryFuture: Future> { /// The type of successful values yielded by this future type Ok; /// The type of failures yielded by this future type Error; - - /// Poll this `TryFuture` as if it were a `Future`. - /// - /// This method is a stopgap for a compiler limitation that prevents us from - /// directly inheriting from the `Future` trait; in the future it won't be - /// needed. - fn try_poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll>; } impl TryFuture for F @@ -87,11 +68,6 @@ where { type Ok = T; type Error = E; - - #[inline] - fn try_poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { - self.poll(cx) - } } #[cfg(feature = "alloc")] @@ -105,11 +81,10 @@ mod if_alloc { ::is_terminated(&**self) } } +} - #[cfg(feature = "std")] - impl FusedFuture for std::panic::AssertUnwindSafe { - fn is_terminated(&self) -> bool { - ::is_terminated(&**self) - } +impl FusedFuture for core::panic::AssertUnwindSafe { + fn is_terminated(&self) -> bool { + ::is_terminated(&**self) } } diff --git a/futures-core/src/stream.rs b/futures-core/src/stream.rs index e9b7afb535..9ad385d0e1 100644 --- a/futures-core/src/stream.rs +++ b/futures-core/src/stream.rs @@ -141,7 +141,7 @@ where /// should no longer be polled. /// /// `is_terminated` will return `true` if a future should no longer be polled. -/// Usually, this state occurs after `poll_next` (or `try_poll_next`) returned +/// Usually, this state occurs after `poll_next` returned /// `Poll::Ready(None)`. However, `is_terminated` may also return `true` if a /// stream has become inactive and can no longer make progress and should be /// ignored or dropped rather than being polled again. @@ -166,32 +166,14 @@ where } } -mod private_try_stream { - use super::Stream; - - pub trait Sealed {} - - impl Sealed for S where S: ?Sized + Stream> {} -} - /// A convenience for streams that return `Result` values that includes /// a variety of adapters tailored to such futures. -pub trait TryStream: Stream + private_try_stream::Sealed { +pub trait TryStream: Stream> { /// The type of successful values yielded by this future type Ok; /// The type of failures yielded by this future type Error; - - /// Poll this `TryStream` as if it were a `Stream`. - /// - /// This method is a stopgap for a compiler limitation that prevents us from - /// directly inheriting from the `Stream` trait; in the future it won't be - /// needed. - fn try_poll_next( - self: Pin<&mut Self>, - cx: &mut Context<'_>, - ) -> Poll>>; } impl TryStream for S @@ -200,13 +182,6 @@ where { type Ok = T; type Error = E; - - fn try_poll_next( - self: Pin<&mut Self>, - cx: &mut Context<'_>, - ) -> Poll>> { - self.poll_next(cx) - } } #[cfg(feature = "alloc")] @@ -227,22 +202,21 @@ mod if_alloc { } } - #[cfg(feature = "std")] - impl Stream for std::panic::AssertUnwindSafe { - type Item = S::Item; - - fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll> { - unsafe { self.map_unchecked_mut(|x| &mut x.0) }.poll_next(cx) - } - - fn size_hint(&self) -> (usize, Option) { - self.0.size_hint() - } - } - impl FusedStream for Box { fn is_terminated(&self) -> bool { ::is_terminated(&**self) } } } + +impl Stream for core::panic::AssertUnwindSafe { + type Item = S::Item; + + fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll> { + unsafe { self.map_unchecked_mut(|x| &mut x.0) }.poll_next(cx) + } + + fn size_hint(&self) -> (usize, Option) { + self.0.size_hint() + } +} diff --git a/futures-io/Cargo.toml b/futures-io/Cargo.toml index 1554ad2d1d..90e893fdcc 100644 --- a/futures-io/Cargo.toml +++ b/futures-io/Cargo.toml @@ -3,7 +3,7 @@ name = "futures-io" version = "0.3.33" edition = "2018" # NB: Sync with "Usage" section in README.md and core-msrv job in .github/workflows/ci.yml -rust-version = "1.36" +rust-version = "1.52" license = "MIT OR Apache-2.0" repository = "https://github.com/rust-lang/futures-rs" homepage = "https://rust-lang.github.io/futures-rs" diff --git a/futures-io/README.md b/futures-io/README.md index da6eec28ba..b87b82d78b 100644 --- a/futures-io/README.md +++ b/futures-io/README.md @@ -11,7 +11,7 @@ Add this to your `Cargo.toml`: futures-io = "0.3" ``` -The current `futures-io` requires Rust 1.36 or later. +The current `futures-io` requires Rust 1.52 or later. ## License diff --git a/futures-sink/Cargo.toml b/futures-sink/Cargo.toml index 81a6c808de..7a44b76793 100644 --- a/futures-sink/Cargo.toml +++ b/futures-sink/Cargo.toml @@ -3,7 +3,7 @@ name = "futures-sink" version = "0.4.0-alpha.0" edition = "2018" # NB: Sync with "Usage" section in README.md and core-msrv job in .github/workflows/ci.yml -rust-version = "1.36" +rust-version = "1.52" license = "MIT OR Apache-2.0" repository = "https://github.com/rust-lang/futures-rs" homepage = "https://rust-lang.github.io/futures-rs" diff --git a/futures-sink/README.md b/futures-sink/README.md index 1d683e95b5..3fec194282 100644 --- a/futures-sink/README.md +++ b/futures-sink/README.md @@ -11,7 +11,7 @@ Add this to your `Cargo.toml`: futures-sink = "0.3" ``` -The current `futures-sink` requires Rust 1.36 or later. +The current `futures-sink` requires Rust 1.52 or later. ## License diff --git a/futures-util/src/compat/compat03as01.rs b/futures-util/src/compat/compat03as01.rs index 68b9724f93..0b4144d904 100644 --- a/futures-util/src/compat/compat03as01.rs +++ b/futures-util/src/compat/compat03as01.rs @@ -106,7 +106,7 @@ where type Error = Fut::Error; fn poll(&mut self) -> Poll01 { - with_context(self, |inner, cx| poll_03_to_01(inner.try_poll(cx))) + with_context(self, |inner, cx| poll_03_to_01(inner.poll(cx))) } } @@ -118,7 +118,7 @@ where type Error = St::Error; fn poll(&mut self) -> Poll01, Self::Error> { - with_context(self, |inner, cx| match inner.try_poll_next(cx)? { + with_context(self, |inner, cx| match inner.poll_next(cx)? { task03::Poll::Ready(None) => Ok(Async01::Ready(None)), task03::Poll::Ready(Some(t)) => Ok(Async01::Ready(Some(t))), task03::Poll::Pending => Ok(Async01::NotReady), diff --git a/futures-util/src/future/mod.rs b/futures-util/src/future/mod.rs index a9153dce15..e7e9c782db 100644 --- a/futures-util/src/future/mod.rs +++ b/futures-util/src/future/mod.rs @@ -39,8 +39,8 @@ mod try_future; #[cfg_attr(docsrs, doc(cfg(feature = "sink")))] pub use self::try_future::FlattenSink; pub use self::try_future::{ - AndThen, ErrInto, InspectErr, InspectOk, IntoFuture, MapErr, MapOk, MapOkOrElse, OkInto, - OrElse, TryFlatten, TryFlattenStream, TryFutureExt, UnwrapOrElse, + AndThen, ErrInto, InspectErr, InspectOk, MapErr, MapOk, MapOkOrElse, OkInto, OrElse, + TryFlatten, TryFlattenStream, TryFutureExt, UnwrapOrElse, }; // Primitive futures diff --git a/futures-util/src/future/select_ok.rs b/futures-util/src/future/select_ok.rs index 3436996787..b464f75548 100644 --- a/futures-util/src/future/select_ok.rs +++ b/futures-util/src/future/select_ok.rs @@ -7,7 +7,7 @@ use futures_core::{ }; use super::assert_future; -use crate::future::TryFutureExt; +use crate::future::FutureExt; /// Future for the [`select_ok`] function. #[derive(Debug)] @@ -51,7 +51,7 @@ impl Future for SelectOk { // loop until we've either exhausted all errors, a success was hit, or nothing is ready loop { let item = - self.inner.iter_mut().enumerate().find_map(|(i, f)| match f.try_poll_unpin(cx) { + self.inner.iter_mut().enumerate().find_map(|(i, f)| match f.poll_unpin(cx) { Poll::Pending => None, Poll::Ready(e) => Some((i, e)), }); diff --git a/futures-util/src/future/try_future/into_future.rs b/futures-util/src/future/try_future/into_future.rs deleted file mode 100644 index c0dc13251b..0000000000 --- a/futures-util/src/future/try_future/into_future.rs +++ /dev/null @@ -1,39 +0,0 @@ -use core::pin::Pin; - -use futures_core::{ - future::{FusedFuture, Future, TryFuture}, - task::{Context, Poll}, -}; -use pin_project_lite::pin_project; - -pin_project! { - /// Future for the [`into_future`](super::TryFutureExt::into_future) method. - #[derive(Debug)] - #[must_use = "futures do nothing unless you `.await` or poll them"] - pub struct IntoFuture { - #[pin] - future: Fut, - } -} - -impl IntoFuture { - #[inline] - pub(crate) fn new(future: Fut) -> Self { - Self { future } - } -} - -impl FusedFuture for IntoFuture { - fn is_terminated(&self) -> bool { - self.future.is_terminated() - } -} - -impl Future for IntoFuture { - type Output = Result; - - #[inline] - fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { - self.project().future.try_poll(cx) - } -} diff --git a/futures-util/src/future/try_future/mod.rs b/futures-util/src/future/try_future/mod.rs index 81bf8fac36..7ca5f94a9c 100644 --- a/futures-util/src/future/try_future/mod.rs +++ b/futures-util/src/future/try_future/mod.rs @@ -3,13 +3,7 @@ //! This module contains a number of functions for working with `Future`s, //! including the `FutureExt` trait which adds methods to `Future` types. -use core::pin::Pin; - -use futures_core::{ - future::TryFuture, - stream::TryStream, - task::{Context, Poll}, -}; +use futures_core::{future::TryFuture, stream::TryStream}; #[cfg(feature = "sink")] use futures_sink::Sink; @@ -26,7 +20,6 @@ use crate::{ }; // Combinators -mod into_future; mod try_flatten; mod try_flatten_err; @@ -92,45 +85,43 @@ delegate_all!( delegate_all!( /// Future for the [`inspect_ok`](super::TryFutureExt::inspect_ok) method. InspectOk( - Inspect, InspectOkFn> - ): Debug + Future + FusedFuture + New[|x: Fut, f: F| Inspect::new(IntoFuture::new(x), inspect_ok_fn(f))] + Inspect> + ): Debug + Future + FusedFuture + New[|x: Fut, f: F| Inspect::new(x, inspect_ok_fn(f))] ); delegate_all!( /// Future for the [`inspect_err`](super::TryFutureExt::inspect_err) method. InspectErr( - Inspect, InspectErrFn> - ): Debug + Future + FusedFuture + New[|x: Fut, f: F| Inspect::new(IntoFuture::new(x), inspect_err_fn(f))] + Inspect> + ): Debug + Future + FusedFuture + New[|x: Fut, f: F| Inspect::new(x, inspect_err_fn(f))] ); -pub use self::into_future::IntoFuture; - delegate_all!( /// Future for the [`map_ok`](TryFutureExt::map_ok) method. MapOk( - Map, MapOkFn> - ): Debug + Future + FusedFuture + New[|x: Fut, f: F| Map::new(IntoFuture::new(x), map_ok_fn(f))] + Map> + ): Debug + Future + FusedFuture + New[|x: Fut, f: F| Map::new(x, map_ok_fn(f))] ); delegate_all!( /// Future for the [`map_err`](TryFutureExt::map_err) method. MapErr( - Map, MapErrFn> - ): Debug + Future + FusedFuture + New[|x: Fut, f: F| Map::new(IntoFuture::new(x), map_err_fn(f))] + Map> + ): Debug + Future + FusedFuture + New[|x: Fut, f: F| Map::new(x, map_err_fn(f))] ); delegate_all!( /// Future for the [`map_ok_or_else`](TryFutureExt::map_ok_or_else) method. MapOkOrElse( - Map, MapOkOrElseFn> - ): Debug + Future + FusedFuture + New[|x: Fut, f: F, g: G| Map::new(IntoFuture::new(x), map_ok_or_else_fn(f, g))] + Map> + ): Debug + Future + FusedFuture + New[|x: Fut, f: F, g: G| Map::new(x, map_ok_or_else_fn(f, g))] ); delegate_all!( /// Future for the [`unwrap_or_else`](TryFutureExt::unwrap_or_else) method. UnwrapOrElse( - Map, UnwrapOrElseFn> - ): Debug + Future + FusedFuture + New[|x: Fut, f: F| Map::new(IntoFuture::new(x), unwrap_or_else_fn(f))] + Map> + ): Debug + Future + FusedFuture + New[|x: Fut, f: F| Map::new(x, unwrap_or_else_fn(f))] ); impl TryFutureExt for Fut {} @@ -587,41 +578,4 @@ pub trait TryFutureExt: TryFuture { { Compat::new(self) } - - /// Wraps a [`TryFuture`] into a type that implements - /// [`Future`](std::future::Future). - /// - /// [`TryFuture`]s currently do not implement the - /// [`Future`](std::future::Future) trait due to limitations of the - /// compiler. - /// - /// # Examples - /// - /// ``` - /// use futures::future::{Future, TryFuture, TryFutureExt}; - /// - /// # type T = i32; - /// # type E = (); - /// fn make_try_future() -> impl TryFuture { // ... } - /// # async { Ok::(1) } - /// # } - /// fn take_future(future: impl Future>) { /* ... */ } - /// - /// take_future(make_try_future().into_future()); - /// ``` - fn into_future(self) -> IntoFuture - where - Self: Sized, - { - assert_future::, _>(IntoFuture::new(self)) - } - - /// A convenience method for calling [`TryFuture::try_poll`] on [`Unpin`] - /// future types. - fn try_poll_unpin(&mut self, cx: &mut Context<'_>) -> Poll> - where - Self: Unpin, - { - Pin::new(self).try_poll(cx) - } } diff --git a/futures-util/src/future/try_future/try_flatten.rs b/futures-util/src/future/try_future/try_flatten.rs index a78ac9c85d..dffcc694d4 100644 --- a/futures-util/src/future/try_future/try_flatten.rs +++ b/futures-util/src/future/try_future/try_flatten.rs @@ -46,7 +46,7 @@ where fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { Poll::Ready(loop { match self.as_mut().project() { - TryFlattenProj::First { f } => match ready!(f.try_poll(cx)) { + TryFlattenProj::First { f } => match ready!(f.poll(cx)) { Ok(f) => self.set(Self::Second { f }), Err(e) => { self.set(Self::Empty); @@ -54,7 +54,7 @@ where } }, TryFlattenProj::Second { f } => { - let output = ready!(f.try_poll(cx)); + let output = ready!(f.poll(cx)); self.set(Self::Empty); break output; } @@ -84,7 +84,7 @@ where fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll> { Poll::Ready(loop { match self.as_mut().project() { - TryFlattenProj::First { f } => match ready!(f.try_poll(cx)) { + TryFlattenProj::First { f } => match ready!(f.poll(cx)) { Ok(f) => self.set(Self::Second { f }), Err(e) => { self.set(Self::Empty); @@ -92,7 +92,7 @@ where } }, TryFlattenProj::Second { f } => { - let output = ready!(f.try_poll_next(cx)); + let output = ready!(f.poll_next(cx)); if output.is_none() { self.set(Self::Empty); } @@ -115,7 +115,7 @@ where fn poll_ready(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll> { Poll::Ready(loop { match self.as_mut().project() { - TryFlattenProj::First { f } => match ready!(f.try_poll(cx)) { + TryFlattenProj::First { f } => match ready!(f.poll(cx)) { Ok(f) => self.set(Self::Second { f }), Err(e) => { self.set(Self::Empty); diff --git a/futures-util/src/future/try_future/try_flatten_err.rs b/futures-util/src/future/try_future/try_flatten_err.rs index 7a58c2b5ca..6f0558c3dc 100644 --- a/futures-util/src/future/try_future/try_flatten_err.rs +++ b/futures-util/src/future/try_future/try_flatten_err.rs @@ -43,7 +43,7 @@ where fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { Poll::Ready(loop { match self.as_mut().project() { - TryFlattenErrProj::First { f } => match ready!(f.try_poll(cx)) { + TryFlattenErrProj::First { f } => match ready!(f.poll(cx)) { Err(f) => self.set(Self::Second { f }), Ok(e) => { self.set(Self::Empty); @@ -51,7 +51,7 @@ where } }, TryFlattenErrProj::Second { f } => { - let output = ready!(f.try_poll(cx)); + let output = ready!(f.poll(cx)); self.set(Self::Empty); break output; } diff --git a/futures-util/src/future/try_join_all.rs b/futures-util/src/future/try_join_all.rs index a998c3853b..708b58a512 100644 --- a/futures-util/src/future/try_join_all.rs +++ b/futures-util/src/future/try_join_all.rs @@ -11,8 +11,7 @@ use core::{ task::{Context, Poll}, }; -use super::{IntoFuture, TryFuture, TryMaybeDone, assert_future, join_all}; -use crate::TryFutureExt; +use super::{TryFuture, TryMaybeDone, assert_future, join_all}; #[cfg(target_has_atomic = "ptr")] use crate::stream::{FuturesOrdered, TryCollect, TryStreamExt}; @@ -36,11 +35,11 @@ where F: TryFuture, { Small { - elems: Pin>]>>, + elems: Pin]>>, }, #[cfg(target_has_atomic = "ptr")] Big { - fut: TryCollect>, Vec>, + fut: TryCollect, Vec>, }, } @@ -119,7 +118,7 @@ where I: IntoIterator, I::Item: TryFuture, { - let iter = iter.into_iter().map(TryFutureExt::into_future); + let iter = iter.into_iter(); #[cfg(not(target_has_atomic = "ptr"))] { @@ -159,7 +158,7 @@ where let mut state = FinalState::AllDone; for elem in join_all::iter_pin_mut(elems.as_mut()) { - match elem.try_poll(cx) { + match elem.poll(cx) { Poll::Pending => state = FinalState::Pending, Poll::Ready(Ok(())) => {} Poll::Ready(Err(e)) => { diff --git a/futures-util/src/future/try_maybe_done.rs b/futures-util/src/future/try_maybe_done.rs index d101ad6208..628dc4877c 100644 --- a/futures-util/src/future/try_maybe_done.rs +++ b/futures-util/src/future/try_maybe_done.rs @@ -79,7 +79,7 @@ impl Future for TryMaybeDone { fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { unsafe { match self.as_mut().get_unchecked_mut() { - Self::Future(f) => match ready!(Pin::new_unchecked(f).try_poll(cx)) { + Self::Future(f) => match ready!(Pin::new_unchecked(f).poll(cx)) { Ok(res) => self.set(Self::Done(res)), Err(e) => { self.set(Self::Gone); diff --git a/futures-util/src/future/try_select.rs b/futures-util/src/future/try_select.rs index 11484cdf88..763e16dea8 100644 --- a/futures-util/src/future/try_select.rs +++ b/futures-util/src/future/try_select.rs @@ -5,7 +5,7 @@ use futures_core::{ task::{Context, Poll}, }; -use crate::future::{Either, TryFutureExt}; +use crate::future::{Either, FutureExt}; /// Future for the [`try_select()`] function. #[must_use = "futures do nothing unless you `.await` or poll them"] @@ -73,10 +73,10 @@ where fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { let (mut a, mut b) = self.inner.take().expect("cannot poll Select twice"); - match a.try_poll_unpin(cx) { + match a.poll_unpin(cx) { Poll::Ready(Err(x)) => Poll::Ready(Err(Either::Left((x, b)))), Poll::Ready(Ok(x)) => Poll::Ready(Ok(Either::Left((x, b)))), - Poll::Pending => match b.try_poll_unpin(cx) { + Poll::Pending => match b.poll_unpin(cx) { Poll::Ready(Err(x)) => Poll::Ready(Err(Either::Right((x, a)))), Poll::Ready(Ok(x)) => Poll::Ready(Ok(Either::Right((x, a)))), Poll::Pending => { diff --git a/futures-util/src/sink/send_all.rs b/futures-util/src/sink/send_all.rs index 8fce30d04c..9911974329 100644 --- a/futures-util/src/sink/send_all.rs +++ b/futures-util/src/sink/send_all.rs @@ -83,7 +83,7 @@ where loop { let this = self.as_mut().project(); - match this.stream.try_poll_next(cx)? { + match this.stream.poll_next(cx)? { Poll::Ready(Some(item)) => ready!(self.as_mut().try_start_send(cx, item))?, Poll::Ready(None) => { ready!(Pin::new(this.sink).poll_flush(cx))?; diff --git a/futures-util/src/stream/mod.rs b/futures-util/src/stream/mod.rs index b931c56f18..ce740b2191 100644 --- a/futures-util/src/stream/mod.rs +++ b/futures-util/src/stream/mod.rs @@ -53,9 +53,9 @@ pub use self::try_stream::IntoAsyncRead; #[cfg_attr(docsrs, doc(cfg(feature = "sink")))] pub use self::try_stream::TryForward; pub use self::try_stream::{ - AndThen, ErrInto, InspectErr, InspectOk, IntoStream, MapErr, MapOk, OrElse, TryAll, TryAny, - TryCollect, TryConcat, TryFilter, TryFilterMap, TryFlatten, TryNext, TrySkipWhile, - TryStreamExt, TryTakeWhile, TryUnfold, try_unfold, + AndThen, ErrInto, InspectErr, InspectOk, MapErr, MapOk, OrElse, TryAll, TryAny, TryCollect, + TryConcat, TryFilter, TryFilterMap, TryFlatten, TryNext, TrySkipWhile, TryStreamExt, + TryTakeWhile, TryUnfold, try_unfold, }; #[cfg(target_has_atomic = "ptr")] #[cfg(feature = "alloc")] diff --git a/futures-util/src/stream/stream/try_fold.rs b/futures-util/src/stream/stream/try_fold.rs index f5fc68dbfa..b1d9f1567b 100644 --- a/futures-util/src/stream/stream/try_fold.rs +++ b/futures-util/src/stream/stream/try_fold.rs @@ -72,7 +72,7 @@ where Poll::Ready(loop { if let Some(fut) = this.future.as_mut().as_pin_mut() { // we're currently processing a future to produce a new accum value - let res = ready!(fut.try_poll(cx)); + let res = ready!(fut.poll(cx)); this.future.set(None); match res { Ok(a) => *this.accum = Some(a), diff --git a/futures-util/src/stream/stream/try_for_each.rs b/futures-util/src/stream/stream/try_for_each.rs index 4594e4cd83..0bc70ed8a4 100644 --- a/futures-util/src/stream/stream/try_for_each.rs +++ b/futures-util/src/stream/stream/try_for_each.rs @@ -56,7 +56,7 @@ where let mut this = self.project(); loop { if let Some(fut) = this.future.as_mut().as_pin_mut() { - ready!(fut.try_poll(cx))?; + ready!(fut.poll(cx))?; this.future.set(None); } else { match ready!(this.stream.as_mut().poll_next(cx)) { diff --git a/futures-util/src/stream/try_stream/and_then.rs b/futures-util/src/stream/try_stream/and_then.rs index 07e841d395..be21aa54f9 100644 --- a/futures-util/src/stream/try_stream/and_then.rs +++ b/futures-util/src/stream/try_stream/and_then.rs @@ -61,10 +61,10 @@ where Poll::Ready(loop { if let Some(fut) = this.future.as_mut().as_pin_mut() { - let item = ready!(fut.try_poll(cx)); + let item = ready!(fut.poll(cx)); this.future.set(None); break Some(item); - } else if let Some(item) = ready!(this.stream.as_mut().try_poll_next(cx)?) { + } else if let Some(item) = ready!(this.stream.as_mut().poll_next(cx)?) { this.future.set(Some((this.f)(item))); } else { break None; diff --git a/futures-util/src/stream/try_stream/into_async_read.rs b/futures-util/src/stream/try_stream/into_async_read.rs index ef0ff93e0e..c6b6d89cf8 100644 --- a/futures-util/src/stream/try_stream/into_async_read.rs +++ b/futures-util/src/stream/try_stream/into_async_read.rs @@ -69,7 +69,7 @@ where return Poll::Ready(Ok(len)); } - ReadState::PendingChunk => match ready!(this.stream.as_mut().try_poll_next(cx)) { + ReadState::PendingChunk => match ready!(this.stream.as_mut().poll_next(cx)) { Some(Ok(chunk)) => { if !chunk.as_ref().is_empty() { *this.state = ReadState::Ready { chunk, chunk_start: 0 }; @@ -122,7 +122,7 @@ where let mut this = self.project(); while let ReadState::PendingChunk = this.state { - match ready!(this.stream.as_mut().try_poll_next(cx)) { + match ready!(this.stream.as_mut().poll_next(cx)) { Some(Ok(chunk)) => { if !chunk.as_ref().is_empty() { *this.state = ReadState::Ready { chunk, chunk_start: 0 }; diff --git a/futures-util/src/stream/try_stream/into_stream.rs b/futures-util/src/stream/try_stream/into_stream.rs deleted file mode 100644 index bf4eab62dd..0000000000 --- a/futures-util/src/stream/try_stream/into_stream.rs +++ /dev/null @@ -1,55 +0,0 @@ -use core::pin::Pin; - -use futures_core::{ - stream::{FusedStream, Stream, TryStream}, - task::{Context, Poll}, -}; -#[cfg(feature = "sink")] -use futures_sink::Sink; -use pin_project_lite::pin_project; - -pin_project! { - /// Stream for the [`into_stream`](super::TryStreamExt::into_stream) method. - #[derive(Debug)] - #[must_use = "streams do nothing unless polled"] - pub struct IntoStream { - #[pin] - stream: St, - } -} - -impl IntoStream { - #[inline] - pub(super) fn new(stream: St) -> Self { - Self { stream } - } - - delegate_access_inner!(stream, St, ()); -} - -impl FusedStream for IntoStream { - fn is_terminated(&self) -> bool { - self.stream.is_terminated() - } -} - -impl Stream for IntoStream { - type Item = Result; - - #[inline] - fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll> { - self.project().stream.try_poll_next(cx) - } - - fn size_hint(&self) -> (usize, Option) { - self.stream.size_hint() - } -} - -// Forwarding impl of Sink from the underlying stream -#[cfg(feature = "sink")] -impl, Item> Sink for IntoStream { - type Error = S::Error; - - delegate_sink!(stream, Item); -} diff --git a/futures-util/src/stream/try_stream/mod.rs b/futures-util/src/stream/try_stream/mod.rs index 1bde9e178f..34dc7a6bf5 100644 --- a/futures-util/src/stream/try_stream/mod.rs +++ b/futures-util/src/stream/try_stream/mod.rs @@ -5,12 +5,10 @@ #[cfg(feature = "alloc")] use alloc::vec::Vec; -use core::pin::Pin; use futures_core::{ future::{Future, TryFuture}, stream::TryStream, - task::{Context, Poll}, }; #[cfg(feature = "sink")] use futures_sink::Sink; @@ -39,32 +37,29 @@ delegate_all!( delegate_all!( /// Stream for the [`inspect_ok`](super::TryStreamExt::inspect_ok) method. InspectOk( - Inspect, InspectOkFn> - ): Debug + Sink + Stream + FusedStream + AccessInner[St, (. .)] + New[|x: St, f: F| Inspect::new(IntoStream::new(x), inspect_ok_fn(f))] + Inspect> + ): Debug + Sink + Stream + FusedStream + AccessInner[St, (.)] + New[|x: St, f: F| Inspect::new(x, inspect_ok_fn(f))] ); delegate_all!( /// Stream for the [`inspect_err`](super::TryStreamExt::inspect_err) method. InspectErr( - Inspect, InspectErrFn> - ): Debug + Sink + Stream + FusedStream + AccessInner[St, (. .)] + New[|x: St, f: F| Inspect::new(IntoStream::new(x), inspect_err_fn(f))] + Inspect> + ): Debug + Sink + Stream + FusedStream + AccessInner[St, (.)] + New[|x: St, f: F| Inspect::new(x, inspect_err_fn(f))] ); -mod into_stream; -pub use self::into_stream::IntoStream; - delegate_all!( /// Stream for the [`map_ok`](super::TryStreamExt::map_ok) method. MapOk( - Map, MapOkFn> - ): Debug + Sink + Stream + FusedStream + AccessInner[St, (. .)] + New[|x: St, f: F| Map::new(IntoStream::new(x), map_ok_fn(f))] + Map> + ): Debug + Sink + Stream + FusedStream + AccessInner[St, (.)] + New[|x: St, f: F| Map::new(x, map_ok_fn(f))] ); delegate_all!( /// Stream for the [`map_err`](super::TryStreamExt::map_err) method. MapErr( - Map, MapErrFn> - ): Debug + Sink + Stream + FusedStream + AccessInner[St, (. .)] + New[|x: St, f: F| Map::new(IntoStream::new(x), map_err_fn(f))] + Map> + ): Debug + Sink + Stream + FusedStream + AccessInner[St, (.)] + New[|x: St, f: F| Map::new(x, map_err_fn(f))] ); mod or_else; @@ -355,34 +350,6 @@ pub trait TryStreamExt: TryStream { assert_stream::, _>(InspectErr::new(self, f)) } - /// Wraps a [`TryStream`] into a type that implements - /// [`Stream`](futures_core::stream::Stream) - /// - /// [`TryStream`]s currently do not implement the - /// [`Stream`](futures_core::stream::Stream) trait because of limitations - /// of the compiler. - /// - /// # Examples - /// - /// ``` - /// use futures::stream::{Stream, TryStream, TryStreamExt}; - /// - /// # type T = i32; - /// # type E = (); - /// fn make_try_stream() -> impl TryStream { // ... } - /// # futures::stream::empty() - /// # } - /// fn take_stream(stream: impl Stream>) { /* ... */ } - /// - /// take_stream(make_try_stream().into_stream()); - /// ``` - fn into_stream(self) -> IntoStream - where - Self: Sized, - { - assert_stream::, _>(IntoStream::new(self)) - } - /// Creates a future that attempts to resolve the next item in the stream. /// If an error is encountered before the next item, the error is returned /// instead. @@ -948,10 +915,10 @@ pub trait TryStreamExt: TryStream { /// /// let mut buffered = stream_of_futures.try_buffered(10); /// - /// assert!(buffered.try_poll_next_unpin(cx).is_pending()); + /// assert!(buffered.poll_next_unpin(cx).is_pending()); /// /// send_two.send(2i32)?; - /// assert!(buffered.try_poll_next_unpin(cx).is_pending()); + /// assert!(buffered.poll_next_unpin(cx).is_pending()); /// Ok::<_, i32>(buffered) /// }).await?; /// @@ -992,20 +959,6 @@ pub trait TryStreamExt: TryStream { )) } - // TODO: false positive warning from rustdoc. Verify once #43466 settles - // - /// A convenience method for calling [`TryStream::try_poll_next`] on [`Unpin`] - /// stream types. - fn try_poll_next_unpin( - &mut self, - cx: &mut Context<'_>, - ) -> Poll>> - where - Self: Unpin, - { - Pin::new(self).try_poll_next(cx) - } - /// Wraps a [`TryStream`] into a stream compatible with libraries using /// futures 0.1 `Stream`. Requires the `compat` feature to be enabled. /// ``` diff --git a/futures-util/src/stream/try_stream/or_else.rs b/futures-util/src/stream/try_stream/or_else.rs index a6e6da0485..62188796f0 100644 --- a/futures-util/src/stream/try_stream/or_else.rs +++ b/futures-util/src/stream/try_stream/or_else.rs @@ -61,11 +61,11 @@ where Poll::Ready(loop { if let Some(fut) = this.future.as_mut().as_pin_mut() { - let item = ready!(fut.try_poll(cx)); + let item = ready!(fut.poll(cx)); this.future.set(None); break Some(item); } else { - match ready!(this.stream.as_mut().try_poll_next(cx)) { + match ready!(this.stream.as_mut().poll_next(cx)) { Some(Ok(item)) => break Some(Ok(item)), Some(Err(e)) => { this.future.set(Some((this.f)(e))); diff --git a/futures-util/src/stream/try_stream/try_all.rs b/futures-util/src/stream/try_stream/try_all.rs index 330bef1195..91b80c6431 100644 --- a/futures-util/src/stream/try_stream/try_all.rs +++ b/futures-util/src/stream/try_stream/try_all.rs @@ -79,7 +79,7 @@ where } // early exit } else if !*this.done { // we're waiting on a new item from the stream - match ready!(this.stream.as_mut().try_poll_next(cx)) { + match ready!(this.stream.as_mut().poll_next(cx)) { Some(Ok(item)) => { this.future.set(Some((this.f)(item))); } diff --git a/futures-util/src/stream/try_stream/try_any.rs b/futures-util/src/stream/try_stream/try_any.rs index 84ccba719b..c6111ed678 100644 --- a/futures-util/src/stream/try_stream/try_any.rs +++ b/futures-util/src/stream/try_stream/try_any.rs @@ -79,7 +79,7 @@ where } // early exit } else if !*this.done { // we're waiting on a new item from the stream - match ready!(this.stream.as_mut().try_poll_next(cx)) { + match ready!(this.stream.as_mut().poll_next(cx)) { Some(Ok(item)) => { this.future.set(Some((this.f)(item))); } diff --git a/futures-util/src/stream/try_stream/try_buffer_unordered.rs b/futures-util/src/stream/try_stream/try_buffer_unordered.rs index cd76ba7dc5..2e3660bdc7 100644 --- a/futures-util/src/stream/try_stream/try_buffer_unordered.rs +++ b/futures-util/src/stream/try_stream/try_buffer_unordered.rs @@ -9,10 +9,7 @@ use futures_core::{ use futures_sink::Sink; use pin_project_lite::pin_project; -use crate::{ - future::{IntoFuture, TryFutureExt}, - stream::{Fuse, FuturesUnordered, IntoStream, StreamExt}, -}; +use crate::stream::{Fuse, FuturesUnordered, StreamExt}; pin_project! { /// Stream for the @@ -23,8 +20,8 @@ pin_project! { where St: TryStream { #[pin] - stream: Fuse>, - in_progress_queue: FuturesUnordered>, + stream: Fuse, + in_progress_queue: FuturesUnordered, max: Option, } } @@ -36,13 +33,13 @@ where { pub(super) fn new(stream: St, n: Option) -> Self { Self { - stream: IntoStream::new(stream).fuse(), + stream: stream.fuse(), in_progress_queue: FuturesUnordered::new(), max: n.and_then(NonZeroUsize::new), } } - delegate_access_inner!(stream, St, (. .)); + delegate_access_inner!(stream, St, (.)); } impl Stream for TryBufferUnordered @@ -59,7 +56,7 @@ where // our queue of futures. Propagate errors from the stream immediately. while this.max.map(|max| this.in_progress_queue.len() < max.get()).unwrap_or(true) { match this.stream.as_mut().poll_next(cx)? { - Poll::Ready(Some(fut)) => this.in_progress_queue.push(fut.into_future()), + Poll::Ready(Some(fut)) => this.in_progress_queue.push(fut), Poll::Ready(None) | Poll::Pending => break, } } diff --git a/futures-util/src/stream/try_stream/try_buffered.rs b/futures-util/src/stream/try_stream/try_buffered.rs index 030938ca93..1f0945ce6e 100644 --- a/futures-util/src/stream/try_stream/try_buffered.rs +++ b/futures-util/src/stream/try_stream/try_buffered.rs @@ -9,10 +9,7 @@ use futures_core::{ use futures_sink::Sink; use pin_project_lite::pin_project; -use crate::{ - future::{IntoFuture, TryFutureExt}, - stream::{Fuse, FuturesOrdered, IntoStream, StreamExt}, -}; +use crate::stream::{Fuse, FuturesOrdered, StreamExt}; pin_project! { /// Stream for the [`try_buffered`](super::TryStreamExt::try_buffered) method. @@ -24,8 +21,8 @@ pin_project! { St::Ok: TryFuture, { #[pin] - stream: Fuse>, - in_progress_queue: FuturesOrdered>, + stream: Fuse, + in_progress_queue: FuturesOrdered, max: Option, } } @@ -37,13 +34,13 @@ where { pub(super) fn new(stream: St, n: Option) -> Self { Self { - stream: IntoStream::new(stream).fuse(), + stream: stream.fuse(), in_progress_queue: FuturesOrdered::new(), max: n.and_then(NonZeroUsize::new), } } - delegate_access_inner!(stream, St, (. .)); + delegate_access_inner!(stream, St, (.)); } impl Stream for TryBuffered @@ -60,7 +57,7 @@ where // our queue of futures. Propagate errors from the stream immediately. while this.max.map(|max| this.in_progress_queue.len() < max.get()).unwrap_or(true) { match this.stream.as_mut().poll_next(cx)? { - Poll::Ready(Some(fut)) => this.in_progress_queue.push_back(fut.into_future()), + Poll::Ready(Some(fut)) => this.in_progress_queue.push_back(fut), Poll::Ready(None) | Poll::Pending => break, } } diff --git a/futures-util/src/stream/try_stream/try_chunks.rs b/futures-util/src/stream/try_stream/try_chunks.rs index aa83cf50e5..558813907c 100644 --- a/futures-util/src/stream/try_stream/try_chunks.rs +++ b/futures-util/src/stream/try_stream/try_chunks.rs @@ -10,7 +10,7 @@ use futures_core::{ use futures_sink::Sink; use pin_project_lite::pin_project; -use crate::stream::{Fuse, IntoStream, StreamExt}; +use crate::stream::{Fuse, StreamExt}; pin_project! { /// Stream for the [`try_chunks`](super::TryStreamExt::try_chunks) method. @@ -18,7 +18,7 @@ pin_project! { #[must_use = "streams do nothing unless polled"] pub struct TryChunks { #[pin] - stream: Fuse>, + stream: Fuse, items: Vec, cap: usize, // https://github.com/rust-lang/futures-rs/issues/1475 } @@ -28,11 +28,7 @@ impl TryChunks { pub(super) fn new(stream: St, capacity: usize) -> Self { assert!(capacity > 0); - Self { - stream: IntoStream::new(stream).fuse(), - items: Vec::with_capacity(capacity), - cap: capacity, - } + Self { stream: stream.fuse(), items: Vec::with_capacity(capacity), cap: capacity } } fn take(self: Pin<&mut Self>) -> Vec { @@ -40,7 +36,7 @@ impl TryChunks { mem::replace(self.project().items, Vec::with_capacity(cap)) } - delegate_access_inner!(stream, St, (. .)); + delegate_access_inner!(stream, St, (.)); } type TryChunksStreamError = TryChunksError<::Ok, ::Error>; @@ -51,7 +47,7 @@ impl Stream for TryChunks { fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll> { let mut this = self.as_mut().project(); loop { - match ready!(this.stream.as_mut().try_poll_next(cx)) { + match ready!(this.stream.as_mut().poll_next(cx)) { // Push the item into the buffer and check whether it is full. // If so, replace our buffer with a new and empty one and return // the full one. diff --git a/futures-util/src/stream/try_stream/try_collect.rs b/futures-util/src/stream/try_stream/try_collect.rs index a406a533bf..9fb092e1df 100644 --- a/futures-util/src/stream/try_stream/try_collect.rs +++ b/futures-util/src/stream/try_stream/try_collect.rs @@ -45,7 +45,7 @@ where fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { let mut this = self.project(); Poll::Ready(Ok(loop { - match ready!(this.stream.as_mut().try_poll_next(cx)?) { + match ready!(this.stream.as_mut().poll_next(cx)?) { Some(x) => this.items.extend(Some(x)), None => break mem::take(this.items), } diff --git a/futures-util/src/stream/try_stream/try_concat.rs b/futures-util/src/stream/try_stream/try_concat.rs index caafd094fe..2d6855f694 100644 --- a/futures-util/src/stream/try_stream/try_concat.rs +++ b/futures-util/src/stream/try_stream/try_concat.rs @@ -40,7 +40,7 @@ where let mut this = self.project(); Poll::Ready(Ok(loop { - if let Some(x) = ready!(this.stream.as_mut().try_poll_next(cx)?) { + if let Some(x) = ready!(this.stream.as_mut().poll_next(cx)?) { if let Some(a) = this.accum { a.extend(x) } else { *this.accum = Some(x) } } else { break this.accum.take().unwrap_or_default(); diff --git a/futures-util/src/stream/try_stream/try_filter.rs b/futures-util/src/stream/try_stream/try_filter.rs index bd9c6f935a..e26b1ada4b 100644 --- a/futures-util/src/stream/try_stream/try_filter.rs +++ b/futures-util/src/stream/try_stream/try_filter.rs @@ -82,7 +82,7 @@ where break this.pending_item.take().map(Ok); } *this.pending_item = None; - } else if let Some(item) = ready!(this.stream.as_mut().try_poll_next(cx)?) { + } else if let Some(item) = ready!(this.stream.as_mut().poll_next(cx)?) { this.pending_fut.set(Some((this.f)(&item))); *this.pending_item = Some(item); } else { diff --git a/futures-util/src/stream/try_stream/try_filter_map.rs b/futures-util/src/stream/try_stream/try_filter_map.rs index 03b0b8d741..c36d288abc 100644 --- a/futures-util/src/stream/try_stream/try_filter_map.rs +++ b/futures-util/src/stream/try_stream/try_filter_map.rs @@ -69,13 +69,13 @@ where Poll::Ready(loop { if let Some(p) = this.pending.as_mut().as_pin_mut() { // We have an item in progress, poll that until it's done - let res = ready!(p.try_poll(cx)); + let res = ready!(p.poll(cx)); this.pending.set(None); let item = res?; if item.is_some() { break item.map(Ok); } - } else if let Some(item) = ready!(this.stream.as_mut().try_poll_next(cx)?) { + } else if let Some(item) = ready!(this.stream.as_mut().poll_next(cx)?) { // No item in progress, but the stream is still going this.pending.set(Some((this.f)(item))); } else { diff --git a/futures-util/src/stream/try_stream/try_flatten.rs b/futures-util/src/stream/try_stream/try_flatten.rs index b80fc205db..53578e1621 100644 --- a/futures-util/src/stream/try_stream/try_flatten.rs +++ b/futures-util/src/stream/try_stream/try_flatten.rs @@ -61,12 +61,12 @@ where Poll::Ready(loop { if let Some(s) = this.next.as_mut().as_pin_mut() { - if let Some(item) = ready!(s.try_poll_next(cx)?) { + if let Some(item) = ready!(s.poll_next(cx)?) { break Some(Ok(item)); } else { this.next.set(None); } - } else if let Some(s) = ready!(this.stream.as_mut().try_poll_next(cx)?) { + } else if let Some(s) = ready!(this.stream.as_mut().poll_next(cx)?) { this.next.set(Some(s)); } else { break None; diff --git a/futures-util/src/stream/try_stream/try_flatten_unordered.rs b/futures-util/src/stream/try_stream/try_flatten_unordered.rs index 0695a6c228..4df6b9405a 100644 --- a/futures-util/src/stream/try_stream/try_flatten_unordered.rs +++ b/futures-util/src/stream/try_stream/try_flatten_unordered.rs @@ -10,11 +10,9 @@ use futures_sink::Sink; use pin_project_lite::pin_project; use crate::{ - TryStreamExt, future::Either, - stream::{ - IntoStream, - stream::flatten_unordered::{FlattenUnorderedWithFlowController, FlowController, FlowStep}, + stream::stream::flatten_unordered::{ + FlattenUnorderedWithFlowController, FlowController, FlowStep, }, }; @@ -130,15 +128,15 @@ where { // Item is either an inner stream or a stream containing a single error. // This will allow using `Either`'s `Stream` implementation as both branches are actually streams of `Result`'s. - type Item = Either, SingleStreamResult>; + type Item = Either>; fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll> { - let item = ready!(self.project().stream.try_poll_next(cx)); + let item = ready!(self.project().stream.poll_next(cx)); let out = match item { Some(res) => match res { // Emit successful inner stream as is - Ok(stream) => Either::Left(stream.into_stream()), + Ok(stream) => Either::Left(stream), // Wrap an error into a stream containing a single item err @ Err(_) => { let res = err.map(|_: St::Ok| unreachable!()).map_err(Into::into); diff --git a/futures-util/src/stream/try_stream/try_forward.rs b/futures-util/src/stream/try_stream/try_forward.rs index fe345993e0..bbedbfac2d 100644 --- a/futures-util/src/stream/try_stream/try_forward.rs +++ b/futures-util/src/stream/try_stream/try_forward.rs @@ -8,7 +8,7 @@ use futures_core::{ use futures_sink::Sink; use pin_project_lite::pin_project; -use crate::stream::{Fuse, IntoStream, Stream, TryStream}; +use crate::stream::{Fuse, Stream, TryStream}; pin_project! { /// Future for the [`try_forward`](super::TryStreamExt::try_forward) method. @@ -19,14 +19,14 @@ pin_project! { #[pin] sink: Option, #[pin] - stream: Fuse>, + stream: Fuse, buffered_item: Option, } } impl TryForward { pub(crate) fn new(stream: St, sink: Si) -> Self { - Self { sink: Some(sink), stream: Fuse::new(IntoStream::new(stream)), buffered_item: None } + Self { sink: Some(sink), stream: Fuse::new(stream), buffered_item: None } } } diff --git a/futures-util/src/stream/try_stream/try_next.rs b/futures-util/src/stream/try_stream/try_next.rs index 4a2d303d4e..7e57b94ad2 100644 --- a/futures-util/src/stream/try_stream/try_next.rs +++ b/futures-util/src/stream/try_stream/try_next.rs @@ -6,7 +6,7 @@ use futures_core::{ task::{Context, Poll}, }; -use crate::stream::TryStreamExt; +use crate::stream::StreamExt; /// Future for the [`try_next`](super::TryStreamExt::try_next) method. #[derive(Debug)] @@ -33,6 +33,6 @@ impl Future for TryNext<'_, St> { type Output = Result, St::Error>; fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { - self.stream.try_poll_next_unpin(cx)?.map(Ok) + self.stream.poll_next_unpin(cx)?.map(Ok) } } diff --git a/futures-util/src/stream/try_stream/try_ready_chunks.rs b/futures-util/src/stream/try_stream/try_ready_chunks.rs index 5d237ac9bc..3dc5d2ea93 100644 --- a/futures-util/src/stream/try_stream/try_ready_chunks.rs +++ b/futures-util/src/stream/try_stream/try_ready_chunks.rs @@ -9,7 +9,7 @@ use futures_core::{ use futures_sink::Sink; use pin_project_lite::pin_project; -use crate::stream::{Fuse, IntoStream, StreamExt}; +use crate::stream::{Fuse, StreamExt}; pin_project! { /// Stream for the [`try_ready_chunks`](super::TryStreamExt::try_ready_chunks) method. @@ -17,7 +17,7 @@ pin_project! { #[must_use = "streams do nothing unless polled"] pub struct TryReadyChunks { #[pin] - stream: Fuse>, + stream: Fuse, cap: usize, // https://github.com/rust-lang/futures-rs/issues/1475 } } @@ -26,10 +26,10 @@ impl TryReadyChunks { pub(super) fn new(stream: St, capacity: usize) -> Self { assert!(capacity > 0); - Self { stream: IntoStream::new(stream).fuse(), cap: capacity } + Self { stream: stream.fuse(), cap: capacity } } - delegate_access_inner!(stream, St, (. .)); + delegate_access_inner!(stream, St, (.)); } type TryReadyChunksStreamError = diff --git a/futures-util/src/stream/try_stream/try_skip_while.rs b/futures-util/src/stream/try_stream/try_skip_while.rs index 2eea2e76c4..18687172a0 100644 --- a/futures-util/src/stream/try_stream/try_skip_while.rs +++ b/futures-util/src/stream/try_stream/try_skip_while.rs @@ -66,12 +66,12 @@ where let mut this = self.project(); if *this.done_skipping { - return this.stream.try_poll_next(cx); + return this.stream.poll_next(cx); } Poll::Ready(loop { if let Some(fut) = this.pending_fut.as_mut().as_pin_mut() { - let res = ready!(fut.try_poll(cx)); + let res = ready!(fut.poll(cx)); this.pending_fut.set(None); let skipped = res?; let item = this.pending_item.take(); @@ -79,7 +79,7 @@ where *this.done_skipping = true; break item.map(Ok); } - } else if let Some(item) = ready!(this.stream.as_mut().try_poll_next(cx)?) { + } else if let Some(item) = ready!(this.stream.as_mut().poll_next(cx)?) { this.pending_fut.set(Some((this.f)(&item))); *this.pending_item = Some(item); } else { diff --git a/futures-util/src/stream/try_stream/try_take_while.rs b/futures-util/src/stream/try_stream/try_take_while.rs index e2da18a724..b7e7ff538a 100644 --- a/futures-util/src/stream/try_stream/try_take_while.rs +++ b/futures-util/src/stream/try_stream/try_take_while.rs @@ -74,7 +74,7 @@ where Poll::Ready(loop { if let Some(fut) = this.pending_fut.as_mut().as_pin_mut() { - let res = ready!(fut.try_poll(cx)); + let res = ready!(fut.poll(cx)); this.pending_fut.set(None); let take = res?; let item = this.pending_item.take(); @@ -84,7 +84,7 @@ where *this.done_taking = true; break None; } - } else if let Some(item) = ready!(this.stream.as_mut().try_poll_next(cx)?) { + } else if let Some(item) = ready!(this.stream.as_mut().poll_next(cx)?) { this.pending_fut.set(Some((this.f)(&item))); *this.pending_item = Some(item); } else { diff --git a/futures-util/src/stream/try_stream/try_unfold.rs b/futures-util/src/stream/try_stream/try_unfold.rs index b77ff9d3d0..ed6a1dc9af 100644 --- a/futures-util/src/stream/try_stream/try_unfold.rs +++ b/futures-util/src/stream/try_stream/try_unfold.rs @@ -108,7 +108,7 @@ where Poll::Ready(None) } Some(future) => { - let step = ready!(future.try_poll(cx)); + let step = ready!(future.poll(cx)); this.fut.set(None); match step { diff --git a/futures/tests/auto_traits.rs b/futures/tests/auto_traits.rs index b5aec6c2ca..6350786f58 100644 --- a/futures/tests/auto_traits.rs +++ b/futures/tests/auto_traits.rs @@ -345,13 +345,6 @@ mod future { assert_impl!(InspectOk: Unpin); assert_not_impl!(InspectOk: Unpin); - assert_impl!(IntoFuture: Send); - assert_not_impl!(IntoFuture: Send); - assert_impl!(IntoFuture: Sync); - assert_not_impl!(IntoFuture: Sync); - assert_impl!(IntoFuture: Unpin); - assert_not_impl!(IntoFuture: Unpin); - assert_impl!(IntoStream: Send); assert_not_impl!(IntoStream: Send); assert_impl!(IntoStream: Sync); @@ -1381,13 +1374,6 @@ mod stream { // IntoAsyncRead requires `St: Unpin` // assert_not_impl!(IntoAsyncRead, io::Error>>: Unpin); - assert_impl!(IntoStream<()>: Send); - assert_not_impl!(IntoStream<*const ()>: Send); - assert_impl!(IntoStream<()>: Sync); - assert_not_impl!(IntoStream<*const ()>: Sync); - assert_impl!(IntoStream<()>: Unpin); - assert_not_impl!(IntoStream: Unpin); - assert_impl!(Iter<()>: Send); assert_not_impl!(Iter<*const ()>: Send); assert_impl!(Iter<()>: Sync);