Open
Description
Hello,
I have recently been pointed to this example:
#![feature(nll)]
fn find_best(vec: &mut Vec<i32>) -> Option<&mut i32> {
vec.get_mut(0)
}
fn foo(vec: &mut Vec<i32>) -> &mut i32 {
if let Some(best) = find_best(vec) {
best
} else {
&mut vec[1]
}
}
fn main() {
let mut x = vec![1, 2, 3];
*foo(&mut x) = 42;
}
To me, the code looks sane, and looks like it should compile with NLL enabled (as the borrow to vec
ends at the end of the if
block, and shouldn't propagate to the else
block), yet it looks like it doesn't.
Hope that helps, and as always thank you for your work on rustc
!