clippy: remove a loop{} which never actually loops

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
Wolfgang Bumiller 2019-09-11 12:31:39 +02:00
parent 44fed91e17
commit bd430c225b
1 changed files with 26 additions and 28 deletions

View File

@ -30,36 +30,21 @@ impl Future for PipeToSendStream {
fn poll(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Self::Output> { fn poll(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Self::Output> {
let this = self.get_mut(); let this = self.get_mut();
loop { if this.data != None {
if this.data != None { // just reserve 1 byte to make sure there's some
// just reserve 1 byte to make sure there's some // capacity available. h2 will handle the capacity
// capacity available. h2 will handle the capacity // management for the actual body chunk.
// management for the actual body chunk. this.body_tx.reserve_capacity(1);
this.body_tx.reserve_capacity(1);
if this.body_tx.capacity() == 0 { if this.body_tx.capacity() == 0 {
loop { loop {
match ready!(this.body_tx.poll_capacity(cx)) { match ready!(this.body_tx.poll_capacity(cx)) {
Some(Err(err)) => return Poll::Ready(Err(Error::from(err))), Some(Err(err)) => return Poll::Ready(Err(Error::from(err))),
Some(Ok(0)) => {} Some(Ok(0)) => {}
Some(Ok(_)) => break, Some(Ok(_)) => break,
None => return Poll::Ready(Err(format_err!("protocol canceled"))), None => return Poll::Ready(Err(format_err!("protocol canceled"))),
}
}
} else {
if let Poll::Ready(reset) = this.body_tx.poll_reset(cx) {
return Poll::Ready(Err(match reset {
Ok(reason) => format_err!("stream received RST_STREAM: {:?}", reason),
Err(err) => Error::from(err),
}));
} }
} }
this.body_tx
.send_data(this.data.take().unwrap(), true)
.map_err(Error::from)?;
return Poll::Ready(Ok(()));
} else { } else {
if let Poll::Ready(reset) = this.body_tx.poll_reset(cx) { if let Poll::Ready(reset) = this.body_tx.poll_reset(cx) {
return Poll::Ready(Err(match reset { return Poll::Ready(Err(match reset {
@ -67,8 +52,21 @@ impl Future for PipeToSendStream {
Err(err) => Error::from(err), Err(err) => Error::from(err),
})); }));
} }
return Poll::Ready(Ok(()));
} }
this.body_tx
.send_data(this.data.take().unwrap(), true)
.map_err(Error::from)?;
return Poll::Ready(Ok(()));
} else {
if let Poll::Ready(reset) = this.body_tx.poll_reset(cx) {
return Poll::Ready(Err(match reset {
Ok(reason) => format_err!("stream received RST_STREAM: {:?}", reason),
Err(err) => Error::from(err),
}));
}
return Poll::Ready(Ok(()));
} }
} }
} }