Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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 \
Expand Down
2 changes: 1 addition & 1 deletion futures-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion futures-core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
45 changes: 10 additions & 35 deletions futures-core/src/future.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -31,10 +27,10 @@ pub type LocalBoxFuture<'a, T> = Pin<alloc::boxed::Box<dyn Future<Output = T> +
/// 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;
Expand All @@ -56,29 +52,14 @@ where
}
}

mod private_try_future {
use super::Future;

pub trait Sealed {}

impl<F, T, E> Sealed for F where F: ?Sized + Future<Output = Result<T, E>> {}
}

/// 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<Output = Result<Self::Ok, Self::Error>> {
/// 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<Result<Self::Ok, Self::Error>>;
}

impl<F, T, E> TryFuture for F
Expand All @@ -87,11 +68,6 @@ where
{
type Ok = T;
type Error = E;

#[inline]
fn try_poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
self.poll(cx)
}
}

#[cfg(feature = "alloc")]
Expand All @@ -105,11 +81,10 @@ mod if_alloc {
<F as FusedFuture>::is_terminated(&**self)
}
}
}

#[cfg(feature = "std")]
impl<F: FusedFuture> FusedFuture for std::panic::AssertUnwindSafe<F> {
fn is_terminated(&self) -> bool {
<F as FusedFuture>::is_terminated(&**self)
}
impl<F: FusedFuture> FusedFuture for core::panic::AssertUnwindSafe<F> {
fn is_terminated(&self) -> bool {
<F as FusedFuture>::is_terminated(&**self)
}
}
54 changes: 14 additions & 40 deletions futures-core/src/stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -166,32 +166,14 @@ where
}
}

mod private_try_stream {
use super::Stream;

pub trait Sealed {}

impl<S, T, E> Sealed for S where S: ?Sized + Stream<Item = Result<T, E>> {}
}

/// 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<Item = Result<Self::Ok, Self::Error>> {
/// 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<Option<Result<Self::Ok, Self::Error>>>;
}

impl<S, T, E> TryStream for S
Expand All @@ -200,13 +182,6 @@ where
{
type Ok = T;
type Error = E;

fn try_poll_next(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
) -> Poll<Option<Result<Self::Ok, Self::Error>>> {
self.poll_next(cx)
}
}

#[cfg(feature = "alloc")]
Expand All @@ -227,22 +202,21 @@ mod if_alloc {
}
}

#[cfg(feature = "std")]
impl<S: Stream> Stream for std::panic::AssertUnwindSafe<S> {
type Item = S::Item;

fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<S::Item>> {
unsafe { self.map_unchecked_mut(|x| &mut x.0) }.poll_next(cx)
}

fn size_hint(&self) -> (usize, Option<usize>) {
self.0.size_hint()
}
}

impl<S: ?Sized + FusedStream + Unpin> FusedStream for Box<S> {
fn is_terminated(&self) -> bool {
<S as FusedStream>::is_terminated(&**self)
}
}
}

impl<S: Stream> Stream for core::panic::AssertUnwindSafe<S> {
type Item = S::Item;

fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<S::Item>> {
unsafe { self.map_unchecked_mut(|x| &mut x.0) }.poll_next(cx)
}

fn size_hint(&self) -> (usize, Option<usize>) {
self.0.size_hint()
}
}
2 changes: 1 addition & 1 deletion futures-io/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion futures-io/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion futures-sink/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion futures-sink/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions futures-util/src/compat/compat03as01.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ where
type Error = Fut::Error;

fn poll(&mut self) -> Poll01<Self::Item, Self::Error> {
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)))
}
}

Expand All @@ -118,7 +118,7 @@ where
type Error = St::Error;

fn poll(&mut self) -> Poll01<Option<Self::Item>, 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),
Expand Down
4 changes: 2 additions & 2 deletions futures-util/src/future/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions futures-util/src/future/select_ok.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down Expand Up @@ -51,7 +51,7 @@ impl<Fut: TryFuture + Unpin> Future for SelectOk<Fut> {
// 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)),
});
Expand Down
39 changes: 0 additions & 39 deletions futures-util/src/future/try_future/into_future.rs

This file was deleted.

Loading
Loading