Earlier quoted context omitted.
Non-lexical lifetimes/borrows. This is a dealbreaker IMO.
For those who are not so Rust inclined, can we have an example of what this means?
fn main() {
let mut x = 10;
let y = &mut x;
*y = 11;
println!("{}", x);
}
This will complain error: cannot borrow `x` as immutable because it is also borrowed as mutable
This is because an `&mut` borrow is exclusive: while `y` is alive, we cannot use `x`. We can fix this by making a new scope for `y`: fn main() {
let mut x = 10;
{
let y = &mut x;
*y = 11;
}
println!("{}", x);
}
This works, and will print `11`.Non-lexical lifetimes would allow the compiler to demonstrate that these two things are the same, and allow the first one to compile with the behavior of the second.
It's an interesting tradeoff, because right now, the rules are very simple and conservative. Scope is fairly easy to reason about. Non-lexical lifetimes would make certain things easier, but also a bit harder to reason about, because the rules are more complex.