Skip to content

Remove Never type alias #2341

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 10, 2021
Merged
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: 3 additions & 3 deletions futures-sink/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,10 @@ where
#[cfg(feature = "alloc")]
mod if_alloc {
use super::*;
use core::convert::Infallible as Never;
use core::convert::Infallible;

impl<T> Sink<T> for alloc::vec::Vec<T> {
type Error = Never;
type Error = Infallible;

fn poll_ready(self: Pin<&mut Self>, _: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
Poll::Ready(Ok(()))
Expand All @@ -183,7 +183,7 @@ mod if_alloc {
}

impl<T> Sink<T> for alloc::collections::VecDeque<T> {
type Error = Never;
type Error = Infallible;

fn poll_ready(self: Pin<&mut Self>, _: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
Poll::Ready(Ok(()))
Expand Down
6 changes: 3 additions & 3 deletions futures-util/src/future/future/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
#[cfg(feature = "alloc")]
use alloc::boxed::Box;
use core::pin::Pin;
use core::convert::Infallible;

use crate::fns::{inspect_fn, into_fn, ok_fn, InspectFn, IntoFn, OkFn};
use crate::future::{assert_future, Either};
use crate::never::Never;
use crate::stream::assert_stream;
#[cfg(feature = "alloc")]
use futures_core::future::{BoxFuture, LocalBoxFuture};
Expand Down Expand Up @@ -83,7 +83,7 @@ delegate_all!(
delegate_all!(
/// Future for the [`never_error`](super::FutureExt::never_error) combinator.
NeverError<Fut>(
Map<Fut, OkFn<Never>>
Map<Fut, OkFn<Infallible>>
): Debug + Future + FusedFuture + New[|x: Fut| Map::new(x, ok_fn())]
);

Expand Down Expand Up @@ -551,7 +551,7 @@ pub trait FutureExt: Future {
where
Self: Sized,
{
assert_future::<Result<Self::Output, Never>, _>(NeverError::new(self))
assert_future::<Result<Self::Output, Infallible>, _>(NeverError::new(self))
}

/// A convenience for calling `Future::poll` on `Unpin` future types.
Expand Down
2 changes: 0 additions & 2 deletions futures-util/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -324,8 +324,6 @@ pub use crate::sink::{Sink, SinkExt};

pub mod task;

pub mod never;

#[cfg(feature = "compat")]
#[cfg_attr(docsrs, doc(cfg(feature = "compat")))]
pub mod compat;
Expand Down
18 changes: 0 additions & 18 deletions futures-util/src/never.rs

This file was deleted.

8 changes: 4 additions & 4 deletions futures-util/src/sink/drain.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use super::assert_sink;
use crate::never::Never;
use core::convert::Infallible;
use core::marker::PhantomData;
use core::pin::Pin;
use futures_core::task::{Context, Poll};
Expand All @@ -24,16 +24,16 @@ pub struct Drain<T> {
///
/// let mut drain = sink::drain();
/// drain.send(5).await?;
/// # Ok::<(), futures::never::Never>(()) }).unwrap();
/// # Ok::<(), std::convert::Infallible>(()) }).unwrap();
/// ```
pub fn drain<T>() -> Drain<T> {
assert_sink::<T, Never, _>(Drain { marker: PhantomData })
assert_sink::<T, Infallible, _>(Drain { marker: PhantomData })
}

impl<T> Unpin for Drain<T> {}

impl<T> Sink<T> for Drain<T> {
type Error = Never;
type Error = Infallible;

fn poll_ready(
self: Pin<&mut Self>,
Expand Down
4 changes: 2 additions & 2 deletions futures-util/src/sink/unfold.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ pin_project! {
/// async move {
/// sum += i;
/// eprintln!("{}", i);
/// Ok::<_, futures::never::Never>(sum)
/// Ok::<_, std::convert::Infallible>(sum)
/// }
/// });
/// futures::pin_mut!(unfold);
/// unfold.send(5).await?;
/// # Ok::<(), futures::never::Never>(()) }).unwrap();
/// # Ok::<(), std::convert::Infallible>(()) }).unwrap();
/// ```
pub fn unfold<T, F, R, Item, E>(init: T, function: F) -> Unfold<T, F, R>
where
Expand Down
2 changes: 1 addition & 1 deletion futures/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ pub use futures_util::{join, pending, poll, select_biased, try_join}; // Async-a

// Module reexports
#[doc(inline)]
pub use futures_util::{future, never, sink, stream, task};
pub use futures_util::{future, sink, stream, task};

#[cfg(feature = "alloc")]
#[doc(inline)]
Expand Down
6 changes: 3 additions & 3 deletions futures/tests/sink.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
use futures::channel::{mpsc, oneshot};
use futures::executor::block_on;
use futures::future::{self, poll_fn, Future, FutureExt, TryFutureExt};
use futures::never::Never;
use futures::ready;
use futures::sink::{self, Sink, SinkErrInto, SinkExt};
use futures::stream::{self, Stream, StreamExt};
use futures::task::{self, ArcWake, Context, Poll, Waker};
use futures_test::task::panic_context;
use std::cell::{Cell, RefCell};
use std::collections::VecDeque;
use std::convert::Infallible;
use std::fmt;
use std::mem;
use std::pin::Pin;
Expand Down Expand Up @@ -307,7 +307,7 @@ fn with_flush() {
let mut sink = Vec::new().with(|elem| {
mem::replace(&mut block, future::ok(()).boxed())
.map_ok(move |()| elem + 1)
.map_err(|_| -> Never { panic!() })
.map_err(|_| -> Infallible { panic!() })
});

assert_eq!(Pin::new(&mut sink).start_send(0).ok(), Some(()));
Expand All @@ -328,7 +328,7 @@ fn with_flush() {
// test simple use of with to change data
#[test]
fn with_as_map() {
let mut sink = Vec::new().with(|item| future::ok::<i32, Never>(item * 2));
let mut sink = Vec::new().with(|item| future::ok::<i32, Infallible>(item * 2));
block_on(sink.send(0)).unwrap();
block_on(sink.send(1)).unwrap();
block_on(sink.send(2)).unwrap();
Expand Down