Enabling the next-generation trait solver on nightly | Rust Blog
Rust has been actively developing a next-generation trait solver for nearly four years. This change, the largest since the compiler's initial release, is now being enabled by default on nightly to identify any remaining issues before its stabilization in the coming months. The new solver replaces the old method for proving where-clauses and normalizing associated types, offering significant improvements in compile times and fixing numerous issues.
The main benefits of this update will become apparent in the future, with the removal of the old implementation unblocking features such as Type Alias Impl Trait and Return Type Notation. It will also allow for the addition of new implicit default trait bounds (e.g., Move and Forget) and fix remaining type system unsoundnesses.
Despite the underapproximation currently identifying over 200 issues fixed by this change, it significantly impacts compile times. Developers using nightly should be aware of potential breakage and update to the latest version to test their projects and libraries. The new solver may require adjustments, as most changes are intended improvements to type inference or the removal of undesirable behavior.
This change notably affects the handling of opaque types, such as return-position impl Trait (RPIT) and Type Alias Impl Trait (TAIT), as well as associated types referencing bound variables. These changes help align the type system's behavior, fix bugs, and improve consistency. The compiler's performance has been improved, with many cases now performing quadratic or even exponentially faster than the old solver. Continued optimization is expected, with nearly all crates benefiting from the new solver in the long term.
Written by urgent.news from Lobsters's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.