Skip to content

A recent change to beta & nightly channels broke the tokio-core build #40551

Closed
@carllerche

Description

@carllerche

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-betaPerformance or correctness regression from stable to beta.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions