Skip to content

NLL: error from URL crate #47703

Closed
Closed
@nikomatsakis

Description

@nikomatsakis

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

#![feature(nll)]

struct MyStruct<'a> {
    field: &'a mut (),
    field2: WithDrop
}

struct WithDrop;

impl Drop for WithDrop {

    fn drop(&mut self) {}

}

impl<'a> MyStruct<'a> {

    fn consume(self) -> &'a mut () { self.field }
}

fn main() {}

which yields:

error[E0597]: `*self.field` does not live long enough
  --> src/main.rs:18:38
   |
18 |     fn consume(self) -> &'a mut () { self.field }
   |                                      ^^^^^^^^^^  - borrowed value only lives until here
   |                                      |
   |                                      borrowed value does not live long enough
   |
   = note: borrowed value must be valid for lifetime '_#3r...

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

Metadata

Metadata

Assignees

Labels

A-NLLArea: Non-lexical lifetimes (NLL)C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCT-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