Closed
Description
I just noticed that tokio-core builds started to fail on Travis when using the beta and nightly channels. We are going to change our code to fix it, but I wanted to report the regression:
The build: https://travis-ci.org/tokio-rs/tokio-core/jobs/211426672
The function:
fn read_buf<B: BufMut>(&mut self, buf: &mut B) -> Poll<usize, io::Error> {
if let Async::NotReady = <TcpStream>::poll_read(self) {
return Err(::would_block())
}
let mut bufs: [_; 16] = Default::default();
unsafe {
let n = buf.bytes_vec_mut(&mut bufs);
match self.io.get_ref().read_bufs(&mut bufs[..n]) {
Ok(n) => {
buf.advance_mut(n);
Ok(Async::Ready(n))
}
Err(e) => {
if e.kind() == io::ErrorKind::WouldBlock {
self.io.need_write();
}
Err(e)
}
}
}
}
The error:
error[E0499]: cannot borrow `*buf` as mutable more than once at a time
--> src/net/tcp.rs:521:21
|
518 | let n = buf.bytes_vec_mut(&mut bufs);
| --- first mutable borrow occurs here
...
521 | buf.advance_mut(n);
| ^^^ second mutable borrow occurs here
...
532 | }
| - first borrow ends here