diff --git a/tokio-util/src/io/sink_writer.rs b/tokio-util/src/io/sink_writer.rs index 5d1acc499..f2af262c4 100644 --- a/tokio-util/src/io/sink_writer.rs +++ b/tokio-util/src/io/sink_writer.rs @@ -1,3 +1,4 @@ +use futures_core::ready; use futures_sink::Sink; use pin_project_lite::pin_project; @@ -98,19 +99,11 @@ where buf: &[u8], ) -> Poll> { let mut this = self.project(); - match this.inner.as_mut().poll_ready(cx) { - Poll::Ready(Ok(())) => { - if let Err(e) = this.inner.as_mut().start_send(buf) { - Poll::Ready(Err(e.into())) - } else { - Poll::Ready(Ok(buf.len())) - } - } - Poll::Ready(Err(e)) => Poll::Ready(Err(e.into())), - Poll::Pending => { - cx.waker().wake_by_ref(); - Poll::Pending - } + + ready!(this.inner.as_mut().poll_ready(cx).map_err(Into::into))?; + match this.inner.as_mut().start_send(buf) { + Ok(()) => Poll::Ready(Ok(buf.len())), + Err(e) => Poll::Ready(Err(e.into())), } }