Skip to content

Commit c730359

Browse files
committed
Use Never type in FutureExt::never_error
1 parent b1fb636 commit c730359

File tree

6 files changed

+5
-19
lines changed

6 files changed

+5
-19
lines changed

futures-util/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ io-compat = ["compat", "tokio-io"]
2323
bench = []
2424
nightly = ["futures-core-preview/nightly", "futures-sink-preview/nightly"]
2525
cfg-target-has-atomic = ["futures-core-preview/cfg-target-has-atomic"]
26-
never-type = []
2726
alloc = ["futures-core-preview/alloc", "futures-sink-preview/alloc"]
2827

2928
[dependencies]

futures-util/src/future/mod.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,7 @@ pub use self::inspect::Inspect;
7676
mod unit_error;
7777
pub use self::unit_error::UnitError;
7878

79-
#[cfg(feature = "never-type")]
8079
mod never_error;
81-
#[cfg(feature = "never-type")]
8280
pub use self::never_error::NeverError;
8381

8482
mod either;
@@ -516,9 +514,8 @@ pub trait FutureExt: Future {
516514
UnitError::new(self)
517515
}
518516

519-
#[cfg(feature = "never-type")]
520517
/// Turns a [`Future<Output = T>`](Future) into a
521-
/// [`TryFuture<Ok = T, Error = !`>](futures_core::future::TryFuture).
518+
/// [`TryFuture<Ok = T, Error = Never`>](futures_core::future::TryFuture).
522519
fn never_error(self) -> NeverError<Self>
523520
where Self: Sized
524521
{

futures-util/src/future/never_error.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use core::pin::Pin;
22
use futures_core::future::{FusedFuture, Future};
33
use futures_core::task::{self, Poll};
4+
use futures_core::never::Never;
45
use pin_utils::unsafe_pinned;
56

67
/// Future for the [`never_error`](super::FutureExt::never_error) combinator.
@@ -27,9 +28,9 @@ impl<Fut: FusedFuture> FusedFuture for NeverError<Fut> {
2728
impl<Fut, T> Future for NeverError<Fut>
2829
where Fut: Future<Output = T>,
2930
{
30-
type Output = Result<T, !>;
31+
type Output = Result<T, Never>;
3132

32-
fn poll(self: Pin<&mut Self>, cx: &mut task::Context<'_>) -> Poll<Result<T, !>> {
33+
fn poll(self: Pin<&mut Self>, cx: &mut task::Context<'_>) -> Poll<Self::Output> {
3334
self.future().poll(cx).map(Ok)
3435
}
3536
}

futures-util/src/lib.rs

-4
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
44
#![cfg_attr(feature = "async-await", feature(async_await))]
55
#![cfg_attr(feature = "cfg-target-has-atomic", feature(cfg_target_has_atomic))]
6-
#![cfg_attr(feature = "never-type", feature(never_type))]
76

87
#![cfg_attr(not(feature = "std"), no_std)]
98
#![warn(missing_docs, missing_debug_implementations, rust_2018_idioms, unreachable_pub)]
@@ -18,9 +17,6 @@
1817
#[cfg(all(feature = "cfg-target-has-atomic", not(feature = "nightly")))]
1918
compile_error!("The `cfg-target-has-atomic` feature requires the `nightly` feature as an explicit opt-in to unstable features");
2019

21-
#[cfg(all(feature = "never-type", not(feature = "nightly")))]
22-
compile_error!("The `never-type` feature requires the `nightly` feature as an explicit opt-in to unstable features");
23-
2420
#[cfg(all(feature = "async-await", not(feature = "nightly")))]
2521
compile_error!("The `async-await` feature requires the `nightly` feature as an explicit opt-in to unstable features");
2622

futures/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ default = ["std"]
4444
compat = ["std", "futures-util-preview/compat"]
4545
io-compat = ["compat", "futures-util-preview/io-compat"]
4646
cfg-target-has-atomic = ["futures-core-preview/cfg-target-has-atomic", "futures-util-preview/cfg-target-has-atomic"]
47-
never-type = ["futures-util-preview/never-type"]
4847
alloc = ["futures-core-preview/alloc", "futures-sink-preview/alloc", "futures-util-preview/alloc"]
4948

5049
[package.metadata.docs.rs]

futures/src/lib.rs

+1-7
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
//! completion, but *do not block* the thread running them.
2323
2424
#![cfg_attr(feature = "cfg-target-has-atomic", feature(cfg_target_has_atomic))]
25-
#![cfg_attr(feature = "never-type", feature(never_type))]
2625

2726
#![cfg_attr(not(feature = "std"), no_std)]
2827

@@ -41,9 +40,6 @@ compile_error!("The `async-await` feature requires the `nightly` feature as an e
4140
#[cfg(all(feature = "cfg-target-has-atomic", not(feature = "nightly")))]
4241
compile_error!("The `cfg-target-has-atomic` feature requires the `nightly` feature as an explicit opt-in to unstable features");
4342

44-
#[cfg(all(feature = "never-type", not(feature = "nightly")))]
45-
compile_error!("The `never-type` feature requires the `nightly` feature as an explicit opt-in to unstable features");
46-
4743
#[doc(hidden)] pub use futures_core::core_reexport;
4844

4945
#[doc(hidden)] pub use futures_core::future::Future;
@@ -227,6 +223,7 @@ pub mod future {
227223

228224
FutureExt,
229225
FlattenStream, Flatten, Fuse, Inspect, IntoStream, Map, Then, UnitError,
226+
NeverError,
230227
};
231228

232229
#[cfg(feature = "alloc")]
@@ -261,9 +258,6 @@ pub mod future {
261258
InspectOk, InspectErr, TryFlattenStream, UnwrapOrElse,
262259
};
263260

264-
#[cfg(feature = "never-type")]
265-
pub use futures_util::future::NeverError;
266-
267261
#[cfg(feature = "alloc")]
268262
pub use futures_util::try_future::{
269263
try_join_all, TryJoinAll,

0 commit comments

Comments
 (0)