Skip to content

1.17.0 regression: loop mutable vs immutable alias. #41599

Closed
@dpc

Description

@dpc

https://github.com/dpc/mioco/blob/0a12aae802256468f30a43cde2689e8846176914/examples/http-server.rs#L47

This code compiles on 1.16.0, but errors on 1.17.0:

error[E0502]: cannot borrow `buf` as mutable because it is also borrowed as immutable
  --> examples/http-server.rs:49:63
   |
49 |                                 let len = try!(conn.read(&mut buf[buf_i..]));
   |                                                               ^^^ mutable borrow occurs here
...
58 |                                 let res = req.parse(&buf[0..buf_i]).unwrap();
   |                                                      --- immutable borrow occurs here
...
77 |                         });
   |                         - immutable borrow ends here

Reproduced and confirmed by another person on #rust. I'm working on minimizing, but since it's late, I might not be able to deliver today.

Metadata

Metadata

Assignees

No one assigned

    Labels

    regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions