Skip to content

NLL (two-phase-borrows) regression: image crate #48357

Closed
@SimonSapin

Description

@SimonSapin

rustc 1.25.0-nightly (27a046e 2018-02-18), https://github.com/PistonDevelopers/image, output with an unrelated warning removed.

cargo +nightly build: OK

cargo +nightly rustc -- -Znll: OK

cargo +nightly rustc -- -Znll -Ztwo-phase-borrows

   Compiling image v0.18.0 (file:///home/simon/projects/image)
error[E0499]: cannot borrow `_` as mutable more than once at a time
   --> src/tiff/decoder/mod.rs:403:39
    |
402 |             (ColorType::RGBA(8), DecodingBuffer::U8(ref mut buffer)) => {
    |                                                     -------------- first mutable borrow occurs here
403 |                 try!(reader.read(&mut buffer[..bytes]))
    |                                       ^^^^^^ second mutable borrow occurs here

error[E0499]: cannot borrow `_` as mutable more than once at a time
   --> src/tiff/decoder/mod.rs:403:39
    |
401 |             (ColorType:: RGB(8), DecodingBuffer::U8(ref mut buffer)) |
    |                                                     -------------- first mutable borrow occurs here
402 |             (ColorType::RGBA(8), DecodingBuffer::U8(ref mut buffer)) => {
403 |                 try!(reader.read(&mut buffer[..bytes]))
    |                                       ^^^^^^ second mutable borrow occurs here

error[E0499]: cannot borrow `_` as mutable more than once at a time
   --> src/tiff/decoder/mod.rs:407:30
    |
405 |             (ColorType::RGBA(16), DecodingBuffer::U16(ref mut buffer)) |
    |                                                       -------------- first mutable borrow occurs here
406 |             (ColorType:: RGB(16), DecodingBuffer::U16(ref mut buffer)) => {
407 |                 for datum in buffer[..bytes/2].iter_mut() {
    |                              ^^^^^^ second mutable borrow occurs here

error[E0499]: cannot borrow `_` as mutable more than once at a time
   --> src/tiff/decoder/mod.rs:407:30
    |
406 |             (ColorType:: RGB(16), DecodingBuffer::U16(ref mut buffer)) => {
    |                                                       -------------- first mutable borrow occurs here
407 |                 for datum in buffer[..bytes/2].iter_mut() {
    |                              ^^^^^^ second mutable borrow occurs here

error: aborting due to 4 previous errors

error: Could not compile `image`.

cargo +nightly rustc -- -Zborrowck=mir -Ztwo-phase-borrows

   Compiling image v0.18.0 (file:///home/simon/projects/image)
error[E0499]: cannot borrow `_` as mutable more than once at a time
   --> src/tiff/decoder/mod.rs:403:39
    |
402 |             (ColorType::RGBA(8), DecodingBuffer::U8(ref mut buffer)) => {
    |                                                     -------------- first mutable borrow occurs here
403 |                 try!(reader.read(&mut buffer[..bytes]))
    |                 ----------------------^^^^^^-----------
    |                 |                     |
    |                 |                     second mutable borrow occurs here
    |                 first borrow ends here
    |
    = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)

error[E0499]: cannot borrow `_` as mutable more than once at a time
   --> src/tiff/decoder/mod.rs:407:30
    |
403 |                 try!(reader.read(&mut buffer[..bytes]))
    |                 --------------------------------------- first borrow ends here
404 |             }
405 |             (ColorType::RGBA(16), DecodingBuffer::U16(ref mut buffer)) |
    |                                                       -------------- first mutable borrow occurs here
406 |             (ColorType:: RGB(16), DecodingBuffer::U16(ref mut buffer)) => {
407 |                 for datum in buffer[..bytes/2].iter_mut() {
    |                              ^^^^^^ second mutable borrow occurs here
    |
    = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)

error: aborting due to 2 previous errors

error: Could not compile `image`.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-NLLArea: Non-lexical lifetimes (NLL)C-bugCategory: This is a bug.NLL-completeWorking towards the "valid code works" goal

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions