Skip to content

NLL (MIR borrowck) regression in Servo’s layout crate #48358

Closed
@SimonSapin

Description

@SimonSapin

In servo/servo@be902d5 (current master), with rustc 1.25.0-nightly (27a046e 2018-02-18)

cargo +nightly-2018-02-19 rustc -p layout: OK

cargo +nightly-2018-02-19 rustc -p layout -- -Zborrowck=mir:

   Compiling layout v0.0.1 (file:///home/simon/servo/components/layout)
error[E0502]: cannot borrow `self.column_computed_inline_sizes` as immutable because it is also borrowed as mutable
   --> components/layout/table.rs:421:33
    |
419 |                         self.column_computed_inline_sizes[index].size +=
    |                         --------------------------------- mutable borrow occurs here
420 |                             remaining_inline_size.scale_by(
421 |                                 self.column_computed_inline_sizes[index].size.0 as f32 / total_minimum_size);
    |                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ immutable borrow occurs here             - mutable borrow ends here

error[E0503]: cannot use `unscanned_text_fragment_info.selection` because it was mutably borrowed
   --> components/layout/text.rs:527:40
    |
515 |                 Some(ref mut selection) if selection.begin() >= offset => {
    |                      ----------------- borrow of `unscanned_text_fragment_info.selection.0` occurs here
...
527 |                     selection_before = unscanned_text_fragment_info.selection;
    |                                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ use of borrowed `unscanned_text_fragment_info.selection.0`

error[E0506]: cannot assign to `unscanned_text_fragment_info.selection` because it is borrowed
   --> components/layout/text.rs:528:21
    |
515 |                 Some(ref mut selection) if selection.begin() >= offset => {
    |                      ----------------- borrow of `unscanned_text_fragment_info.selection` occurs here
...
528 |                     unscanned_text_fragment_info.selection = None;
    |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ assignment to borrowed `unscanned_text_fragment_info.selection` occurs here

error[E0499]: cannot borrow `unscanned_text_fragment_info.selection.0` as mutable more than once at a time
   --> components/layout/text.rs:520:22
    |
515 |                 Some(ref mut selection) if selection.begin() >= offset => {
    |                      ----------------- first mutable borrow occurs here
...
520 |                 Some(ref mut selection) if selection.end() > offset => {
    |                      ^^^^^^^^^^^^^^^^^ second mutable borrow occurs here
...
530 |             };
    |             - first borrow ends here

error: aborting due to 4 previous errors

error: Could not compile `layout`.

cargo +nightly-2018-02-19 rustc -p layout -- -Znll:

   Compiling layout v0.0.1 (file:///home/simon/servo/components/layout)
error[E0502]: cannot borrow `self.column_computed_inline_sizes` as immutable because it is also borrowed as mutable
   --> components/layout/table.rs:421:33
    |
419 |                         self.column_computed_inline_sizes[index].size +=
    |                         --------------------------------- mutable borrow occurs here
420 |                             remaining_inline_size.scale_by(
421 |                                 self.column_computed_inline_sizes[index].size.0 as f32 / total_minimum_size);
    |                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ immutable borrow occurs here

error: aborting due to previous error

error: Could not compile `layout`.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-NLLArea: Non-lexical lifetimes (NLL)C-bugCategory: This is a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions