Perfectly safe Rust code that wouldn't compile until today is now finally compiling! The wait is over.
Polonius: The Next Evolution of Rust's Borrow Checker
Rust's borrow checker keeps our code safe from memory bugs. We all love it, but sometimes the current version, Non-Lexical Lifetimes (NLL), is just a bit too strict. It can throw errors on code that is completely fine, especially when you use conditional branches or work with common data structures.
That is where Polonius comes in. It is the next generation of the borrow checker, and it is now enabled by default on Rust Nightly.
I wanted to see this in action, so I put it to the test with some actual Rust code. I was getting my morning espresso when I ran a very minimalistic reborrow function with an if true statement. I ran the exact same safe code with the two different borrow checkers. With the stable compiler, it threw the classic "cannot borrow as mutable more than once at a time" error. Then I ran it on Nightly with Polonius, and it compiled perfectly. I was genuinely shocked. It honestly looked like witchcraft to see the exact same code fail on one side and pass on the other.







