Skip to content

error message found by NLL in librustc_codegen_llvm #53221

Closed
@nikomatsakis

Description

@nikomatsakis

Trying to port librustc_codegen_llvm to use NLL (cc #53172) yields these errors:

https://gist.github.com/memoryruins/14a2aad7fc85d0429ae9e4240ec0dacb

The error seem legitimate. I reduced the pattern in question to this test case:

https://play.rust-lang.org/?gist=6e22b15051f9a108d09f28a0b657f717&version=nightly&mode=debug&edition=2015

As far as I can tell, the Some(child.raw) is interpreted as a Some(&mut *child.raw), which borrows from Child -- but that borrow outlists the variable child. And child has a dtor that frees memory. So something may be legitimately wrong here?

You can solve this by adding a take method that clears the raw field afterwards:

https://play.rust-lang.org/?gist=64c20d529ad49d5871417c391a8dbcde&version=nightly&mode=debug&edition=2015

But I'm not sure what is the intention.

cc @eddyb @irinagpopa

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.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

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions