Enabling the next iteration of the borrow checker on nightly
8 hours ago
- Rust is enabling the next iteration of the borrow checker, Polonius Alpha, on nightly, aiming for stabilization in the next few months.
- Polonius Alpha introduces flow-sensitive borrow checking of lifetime outlives relationships, allowing more code to compile than the current NLL borrow checker.
- Key examples of code that now compiles include conditional branches where a borrow is not live in all paths, such as `get_mut_or_default` and `reborrow` functions.
- Polonius Alpha is not a full replacement; some programs that compiled under the original (slow) Polonius do not compile with Polonius Alpha, though some new programs also work.
- Performance regressions are generally minimal among the top 10,000 crates, with a few outliers showing up to 2–3x slowdowns in cases with many borrows.
- Users can opt out on nightly by passing `-Zpolonius=off` to rustc or via `.cargo/config.toml`.
- The team will monitor for issues and performance regressions before stabilization, aiming to stabilize by the end of the year.