diff --git a/tokio-util/src/sync/reusable_box.rs b/tokio-util/src/sync/reusable_box.rs index 1b8ef605e15..1fae38cc6ff 100644 --- a/tokio-util/src/sync/reusable_box.rs +++ b/tokio-util/src/sync/reusable_box.rs @@ -1,7 +1,6 @@ use std::alloc::Layout; use std::fmt; -use std::future::Future; -use std::marker::PhantomData; +use std::future::{self, Future}; use std::mem::{self, ManuallyDrop}; use std::pin::Pin; use std::ptr; @@ -61,7 +60,7 @@ impl<'a, T> ReusableBoxFuture<'a, T> { F: Future + Send + 'a, { // future::Pending is a ZST so this never allocates. - let boxed = mem::replace(&mut this.boxed, Box::pin(Pending(PhantomData))); + let boxed = mem::replace(&mut this.boxed, Box::pin(future::pending())); reuse_pin_box(boxed, future, |boxed| this.boxed = Pin::from(boxed)) } @@ -156,16 +155,3 @@ impl O> Drop for CallOnDrop { f(); } } - -/// The same as `std::future::Pending`; we can't use that type directly because on rustc -/// versions <1.60 it didn't unconditionally implement `Send`. -// FIXME: use `std::future::Pending` once the MSRV is >=1.60 -struct Pending(PhantomData T>); - -impl Future for Pending { - type Output = T; - - fn poll(self: Pin<&mut Self>, _cx: &mut Context<'_>) -> Poll { - Poll::Pending - } -}