aboutsummaryrefslogtreecommitdiff
path: root/src/io/util/fill_buf.rs
diff options
context:
space:
mode:
authorJoel Galenson <jgalenson@google.com>2021-09-30 08:55:02 -0700
committerJoel Galenson <jgalenson@google.com>2021-09-30 08:55:40 -0700
commit5fe87985ba723ee4d9532495587d7114e4b6e143 (patch)
tree71a18fec0599d209bd7c1b95140dc75566fa3788 /src/io/util/fill_buf.rs
parentd61267ffdfea9ed9be38e805f8e3ff78e384005f (diff)
downloadtokio-5fe87985ba723ee4d9532495587d7114e4b6e143.tar.gz
Upgrade rust/crates/tokio to 1.12.0
Test: make Change-Id: I4b0bd405c0b615f886e5a6606e0bf7c0ac7c6699
Diffstat (limited to 'src/io/util/fill_buf.rs')
-rw-r--r--src/io/util/fill_buf.rs13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/io/util/fill_buf.rs b/src/io/util/fill_buf.rs
index 98ae2ea..3655c01 100644
--- a/src/io/util/fill_buf.rs
+++ b/src/io/util/fill_buf.rs
@@ -34,15 +34,16 @@ impl<'a, R: AsyncBufRead + ?Sized + Unpin> Future for FillBuf<'a, R> {
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
let me = self.project();
- // Due to a limitation in the borrow-checker, we cannot return the value
- // directly on Ready. Once Rust starts using the polonius borrow checker,
- // this can be simplified.
let reader = me.reader.take().expect("Polled after completion.");
match Pin::new(&mut *reader).poll_fill_buf(cx) {
- Poll::Ready(_) => match Pin::new(reader).poll_fill_buf(cx) {
- Poll::Ready(slice) => Poll::Ready(slice),
- Poll::Pending => panic!("poll_fill_buf returned Pending while having data"),
+ Poll::Ready(Ok(slice)) => unsafe {
+ // Safety: This is necessary only due to a limitation in the
+ // borrow checker. Once Rust starts using the polonius borrow
+ // checker, this can be simplified.
+ let slice = std::mem::transmute::<&[u8], &'a [u8]>(slice);
+ Poll::Ready(Ok(slice))
},
+ Poll::Ready(Err(err)) => Poll::Ready(Err(err)),
Poll::Pending => {
*me.reader = Some(reader);
Poll::Pending