Skip to content

[nll] better error message when returning refs to upvars #53040

Closed

Description

In an example like:

fn f() {
let mut x: Box<()> = Box::new(());
|| {
&mut x
};
}

AST-borrowck accepts such code, but NLL will start rejecting it.

@nikomatsakis concluded in a comment back in April (#49824 (comment)) that similar code (or at least it looks similar to me) is in fact incorrect, and decided that NLL was correct in rejecting such cases.

This issue is just marking that this change in semantics has occurred, so that I can link to it from places like #52663

Known instances:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Labels

A-NLLArea: Non-lexical lifetimes (NLL)NLL-diagnosticsWorking towards the "diagnostic parity" goalT-langRelevant to the language 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