Skip to content

[nll] compilation error from mozjs-0.1.10 #47722

Closed
@nikomatsakis

Description

@nikomatsakis

In #47596, @SimonSapin reported several NLL errors in dependencies of the servo crate. @lqd later minimized one of those errors into this example:

#![feature(nll)]

struct AutoGCRooter {
    stackTop: *mut *mut AutoGCRooter,
}

impl AutoGCRooter {
    unsafe fn add_to_root_stack(&mut self) {
        *self.stackTop = self;
    }
}

fn main() {}

which yields:

error[E0506]: cannot assign to `*self.stackTop` because it is borrowed
 --> src/main.rs:9:9
  |
9 |         *self.stackTop = self;
  |         ^^^^^^^^^^^^^^^^^----
  |         |                |
  |         |                borrow of `*self.stackTop` occurs here
  |         assignment to borrowed `*self.stackTop` occurs here

error: aborting due to previous error

Removing feature(nll) makes the code work, so probably this is an NLL bug.

Metadata

Metadata

Assignees

Labels

A-NLLArea: Non-lexical lifetimes (NLL)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