-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Open
Labels
A-NLLArea: Non-lexical lifetimes (NLL)Area: Non-lexical lifetimes (NLL)C-bugCategory: This is a bug.Category: This is a bug.NLL-completeWorking towards the "valid code works" goalWorking towards the "valid code works" goalNLL-poloniusIssues related for using Polonius in the borrow checkerIssues related for using Polonius in the borrow checkerT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
Spawned off of #60914, namely the regression of the cs_review crate
I was looking for examples of soundness issues fixed by NLL for a blog post that I'm working on, and the first crate I looked at stymied me.
Maybe I'm forgetting something crucial, but I would think we might be able to accept this code (play):
struct Node(String, Option<Box<Node>>, Option<Box<Node>>);
fn main() {
let mut data = Some(Box::new(Node("input1".to_string(), None, None)));
let mut input1 = &mut data;
loop {
match {input1} { // the `{ }` fool AST-borrowck into accepting w/o NLL
&mut Some(ref mut n) if {true} => { input1 = &mut n.1; }
// ~~~~~~~~~ ~~~~~~~~~ combo of 1. borrow, 2. guard, ...
_other => { break; }
// ~~~~~~ ... and 3. move cause NLL to reject
// Why does guard cause borrow last longer than it would otherwise here?
}
}
}
Note: I don't think we're going to hit this "regression" too often, because it critically depends on some bug in AST-borrowck where I believe AST-borrowck mishandled { ... }
around the match input. Since I do not think that is a common pattern in match inputs, we probably can get away with not addressing this for a while.
Metadata
Metadata
Assignees
Labels
A-NLLArea: Non-lexical lifetimes (NLL)Area: Non-lexical lifetimes (NLL)C-bugCategory: This is a bug.Category: This is a bug.NLL-completeWorking towards the "valid code works" goalWorking towards the "valid code works" goalNLL-poloniusIssues related for using Polonius in the borrow checkerIssues related for using Polonius in the borrow checkerT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.