Skip to content

NLL: isolate borrowck errors in Servo dependencies #47596

Closed
@SimonSapin

Description

@SimonSapin

UPDATE by @nikomatsakis: In the original issue below, @SimonSapin found several issues when building servo. The goal now is to isolate those issues into standalone test cases and investigate them. Mentoring instructions for doing that isolation can be found here.

The list of tests to be isolated is:

Original issue report

How I got these results:

The relevant code is from crates.io, so easier steps to reproduce might be to build the same crate outside of Servo. And these errors would probably be caught by crater, so they might be already known.

error[E0597]: `*orig.value` does not live long enough
   --> /home/simon/.cargo/registry/src/github.com-1ecc6299db9ec823/atomic_refcell-0.1.0/src/lib.rs:309:22
    |
309 |             value: f(orig.value),
    |                      ^^^^^^^^^^ borrowed value does not live long enough
...
312 |     }
    |      - borrowed value only lives until here
    |
    = note: borrowed value must be valid for lifetime '_#3r...

error: aborting due to previous error

error: Could not compile `atomic_refcell`.

Caused by:
  process didn't exit successfully: `rustc --crate-name atomic_refcell /home/simon/.cargo/registry/src/github.com-1ecc6299db9ec823/atomic_refcell-0.1.0/src/lib.rs --crate-type lib --emit=dep-info,link -C debuginfo=2 -C metadata=2c09db59a67c03f8 -C extra-filename=-2c09db59a67c03f8 --out-dir /home/simon/servo/target/debug/deps -L dependency=/home/simon/servo/target/debug/deps --cap-lints allow -Znll` (exit code: 101)
warning: build failed, waiting for other jobs to finish...
error[E0503]: cannot use `state` because it was mutably borrowed
    --> /home/simon/.cargo/registry/src/github.com-1ecc6299db9ec823/getopts-0.2.14/src/lib.rs:1008:33
     |
955  |       let mut machine = |cont: &mut bool, (i, c): (usize, char)| {
     |  _______________________-
956  | |         let whitespace = if c.is_whitespace() { Ws }       else { Cr };
957  | |         let limit      = if (i - slice_start + 1) <= lim  { UnderLim } else { OverLim };
958  | |
...    |
1002 | |         *cont
1003 | |     };
     | |_____- borrow of `state` occurs here
...
1008 |       while cont && match state { B | C => true, A => false } {
     |                                   ^ use of borrowed `state`

error: aborting due to previous error

error: Could not compile `getopts`.

Caused by:
  process didn't exit successfully: `rustc --crate-name getopts /home/simon/.cargo/registry/src/github.com-1ecc6299db9ec823/getopts-0.2.14/src/lib.rs --crate-type lib --emit=dep-info,link -C debuginfo=2 -C metadata=3a72542378e72657 -C extra-filename=-3a72542378e72657 --out-dir /home/simon/servo/target/debug/deps -L dependency=/home/simon/servo/target/debug/deps --cap-lints allow -Znll` (exit code: 101)
warning: build failed, waiting for other jobs to finish...
error[E0597]: `*self.url` does not live long enough
   --> /home/simon/.cargo/registry/src/github.com-1ecc6299db9ec823/url-1.6.0/src/form_urlencoded.rs:261:40
    |
261 |     fn finish(self) -> &'a mut ::Url { self.url }
    |                                        ^^^^^^^^  - borrowed value only lives until here
    |                                        |
    |                                        borrowed value does not live long enough
    |
    = note: borrowed value must be valid for lifetime '_#3r...

error: aborting due to previous error

error: Could not compile `url`.

Caused by:
  process didn't exit successfully: `rustc --crate-name url /home/simon/.cargo/registry/src/github.com-1ecc6299db9ec823/url-1.6.0/src/lib.rs --crate-type lib --emit=dep-info,link -C debuginfo=2 -C metadata=d10e0ca03d0b9ab8 -C extra-filename=-d10e0ca03d0b9ab8 --out-dir /home/simon/servo/target/debug/deps -L dependency=/home/simon/servo/target/debug/deps --extern idna=/home/simon/servo/target/debug/deps/libidna-ee1a4ff6e79abeee.rlib --extern matches=/home/simon/servo/target/debug/deps/libmatches-41f6731261a42312.rlib --extern percent_encoding=/home/simon/servo/target/debug/deps/libpercent_encoding-5b0f452077b83df8.rlib --cap-lints allow -Znll` (exit code: 101)
error[E0506]: cannot assign to `*self.stackTop` because it is borrowed
   --> /home/simon/.cargo/registry/src/github.com-1ecc6299db9ec823/mozjs-0.1.10/src/rust.rs:524:9
    |
524 |         *self.stackTop = self;
    |         ^^^^^^^^^^^^^^^^^----
    |         |                |
    |         |                borrow of `*self.stackTop` occurs here
    |         assignment to borrowed `*self.stackTop` occurs here

error: aborting due to previous error

error: Could not compile `mozjs`.

Caused by:
  process didn't exit successfully: `rustc --crate-name mozjs /home/simon/.cargo/registry/src/github.com-1ecc6299db9ec823/mozjs-0.1.10/src/lib.rs --crate-type lib --emit=dep-info,link -C debuginfo=2 --cfg feature="mozjs_sys" --cfg feature="promises" -C metadata=8e35027187093d35 -C extra-filename=-8e35027187093d35 --out-dir /home/simon/servo/target/debug/deps -L dependency=/home/simon/servo/target/debug/deps --extern libc=/home/simon/servo/target/debug/deps/liblibc-b118c84ee3630a2a.rlib --extern mozjs_sys=/home/simon/servo/target/debug/deps/libmozjs_sys-d53c511cbe7b3779.rlib --extern lazy_static=/home/simon/servo/target/debug/deps/liblazy_static-72140f6120427c36.rlib --extern log=/home/simon/servo/target/debug/deps/liblog-ae6a67986025a716.rlib --extern num_traits=/home/simon/servo/target/debug/deps/libnum_traits-e126d3e7dde5d2ac.rlib --cap-lints allow -Znll -L native=/home/simon/servo/target/debug/build/mozjs-fe9b4a432325640f/out/lib -l static=jsglue -L native=/home/simon/servo/target/debug/build/mozjs_sys-8afe9ad964841801/out/js/src -L native=/usr/lib/x86_64-linux-gnu` (exit code: 101)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-NLLArea: Non-lexical lifetimes (NLL)E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions