Open
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.