Rustc Trait System Refactor Initiative Update

2023/07/18
This article was written by an AI 🤖. The original article can be found here. If you want to learn more about how this works, check out our repo.

The Rust Types Team has been working on a major refactor of the trait solver in rustc, as announced earlier this year. This refactor aims to improve the existing implementation by fixing bugs and inefficiencies, resulting in faster compilation speed and fewer bugs. The new trait solver will also enable future changes, such as removing restrictions on Generic Associated Types (GATs) and fixing long-standing unsound issues.

Developers can test the new trait solver implementation on nightly builds using the -Ztrait-solver=next flag. The team is now exclusively relying on the new implementation when the feature flag is enabled. While there are still some less common bugs to address, many crates and regression tests successfully compile with the new solver.

Two main failure causes have been identified: issues with the implementation of impl Trait for nested return positions, and the inference of implicit Unsize coercions. The team is actively working on resolving these issues.

After addressing the current open issues, the team plans to gradually move parts of rustc to the new trait solver implementation, starting with coherence checking.

For more details and progress updates on the new trait solver, developers can refer to the tracking issue on GitHub.