Skip to content

Commit 5a8f4c0

Browse files
authored
refactor(common): replace Never with Infallible (#3335)
1 parent e8e059e commit 5a8f4c0

File tree

5 files changed

+15
-39
lines changed

5 files changed

+15
-39
lines changed

src/common/mod.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,11 @@ pub(crate) mod date;
1313
#[cfg(not(feature = "http2"))]
1414
pub(crate) mod exec;
1515
pub(crate) mod io;
16-
mod never;
1716
pub(crate) mod task;
1817
#[cfg(any(feature = "http1", feature = "http2", feature = "server"))]
1918
pub(crate) mod time;
2019
pub(crate) mod watch;
2120

22-
#[cfg(any(feature = "http1", feature = "http2"))]
23-
pub(crate) use self::never::Never;
2421
pub(crate) use self::task::Poll;
2522

2623
// group up types normally needed for `Future`

src/common/never.rs

Lines changed: 0 additions & 21 deletions
This file was deleted.

src/common/task.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
#[cfg(feature = "http1")]
2-
use super::Never;
2+
use std::convert::Infallible;
33
pub(crate) use std::task::{Context, Poll};
44

55
/// A function to help "yield" a future, such that it is re-scheduled immediately.
66
///
77
/// Useful for spin counts, so a future doesn't hog too much time.
88
#[cfg(feature = "http1")]
9-
pub(crate) fn yield_now(cx: &mut Context<'_>) -> Poll<Never> {
9+
pub(crate) fn yield_now(cx: &mut Context<'_>) -> Poll<Infallible> {
1010
cx.waker().wake_by_ref();
1111
Poll::Pending
1212
}

src/proto/h1/dispatch.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -549,6 +549,8 @@ cfg_server! {
549549
// ===== impl Client =====
550550

551551
cfg_client! {
552+
use std::convert::Infallible;
553+
552554
impl<B> Client<B> {
553555
pub(crate) fn new(rx: ClientRx<B>) -> Client<B> {
554556
Client {
@@ -565,13 +567,13 @@ cfg_client! {
565567
{
566568
type PollItem = RequestHead;
567569
type PollBody = B;
568-
type PollError = crate::common::Never;
570+
type PollError = Infallible;
569571
type RecvItem = crate::proto::ResponseHead;
570572

571573
fn poll_msg(
572574
mut self: Pin<&mut Self>,
573575
cx: &mut task::Context<'_>,
574-
) -> Poll<Option<Result<(Self::PollItem, Self::PollBody), crate::common::Never>>> {
576+
) -> Poll<Option<Result<(Self::PollItem, Self::PollBody), Infallible>>> {
575577
let mut this = self.as_mut();
576578
debug_assert!(!this.rx_closed);
577579
match this.rx.poll_recv(cx) {

src/proto/h2/client.rs

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
use std::marker::PhantomData;
2-
3-
use std::time::Duration;
1+
use std::{convert::Infallible, marker::PhantomData, time::Duration};
42

53
use crate::rt::{Read, Write};
64
use bytes::Bytes;
@@ -19,7 +17,7 @@ use crate::body::{Body, Incoming as IncomingBody};
1917
use crate::client::dispatch::{Callback, SendWhen};
2018
use crate::common::io::Compat;
2119
use crate::common::time::Time;
22-
use crate::common::{task, Future, Never, Pin, Poll};
20+
use crate::common::{task, Future, Pin, Poll};
2321
use crate::ext::Protocol;
2422
use crate::headers;
2523
use crate::proto::h2::UpgradedSendStream;
@@ -33,11 +31,11 @@ type ClientRx<B> = crate::client::dispatch::Receiver<Request<B>, Response<Incomi
3331

3432
///// An mpsc channel is used to help notify the `Connection` task when *all*
3533
///// other handles to it have been dropped, so that it can shutdown.
36-
type ConnDropRef = mpsc::Sender<Never>;
34+
type ConnDropRef = mpsc::Sender<Infallible>;
3735

3836
///// A oneshot channel watches the `Connection` task, and when it completes,
3937
///// the "dispatch" task will be notified and can shutdown sooner.
40-
type ConnEof = oneshot::Receiver<Never>;
38+
type ConnEof = oneshot::Receiver<Infallible>;
4139

4240
// Our defaults are chosen for the "majority" case, which usually are not
4341
// resource constrained, and so the spec default of 64kb can be too limiting
@@ -267,9 +265,9 @@ pin_project! {
267265
T: Unpin,
268266
{
269267
#[pin]
270-
drop_rx: StreamFuture<Receiver<Never>>,
268+
drop_rx: StreamFuture<Receiver<Infallible>>,
271269
#[pin]
272-
cancel_tx: Option<oneshot::Sender<Never>>,
270+
cancel_tx: Option<oneshot::Sender<Infallible>>,
273271
#[pin]
274272
conn: ConnMapErr<T, B>,
275273
}
@@ -282,8 +280,8 @@ where
282280
{
283281
fn new(
284282
conn: ConnMapErr<T, B>,
285-
drop_rx: StreamFuture<Receiver<Never>>,
286-
cancel_tx: oneshot::Sender<Never>,
283+
drop_rx: StreamFuture<Receiver<Infallible>>,
284+
cancel_tx: oneshot::Sender<Infallible>,
287285
) -> Self {
288286
Self {
289287
drop_rx,
@@ -421,7 +419,7 @@ pin_project! {
421419
#[pin]
422420
pipe: PipeToSendStream<S>,
423421
#[pin]
424-
conn_drop_ref: Option<Sender<Never>>,
422+
conn_drop_ref: Option<Sender<Infallible>>,
425423
#[pin]
426424
ping: Option<Recorder>,
427425
}

0 commit comments

Comments
 (0)