Rust's compiler team is nearing completion of a long-term rewrite of the trait solver — the component that resolves which concrete function to call for trait method implementations. The current solver fails on self-referential trait obligation cycles, producing overflow errors even when a valid implementation exists. The new solver addresses this using a provisional caching strategy: when it encounters a trait obligation, it marks it as provisionally true in the cache, follows the chain of inferences, and upgrades provisional entries to fully true if no unresolved obligations remain. This allows cyclic trait proofs to succeed where the old solver would fail. The rewrite also introduces canonicalization to maximize cache hits and enable reconstructible proof trees for better error messages. The new solver is already used in stable Rust for coherence checking, and can be enabled globally in nightly with `-Znext-solver=globally`. Around 76 open bugs remain, mostly internal compiler errors and performance issues, before stabilization.

11m read timeFrom lwn.net
Post cover image
Table of contents
Welcome to LWN.netcircular reasoning is a potential source of unsoundnesscircular reasoning is a potential source of unsoundnesscircular reasoning is a potential source of unsoundnesscircular reasoning is a potential source of unsoundnesscircular reasoning is a potential source of unsoundnesscircular reasoning is a potential source of unsoundnesscircular reasoning is a potential source of unsoundnesscircular reasoning is a potential source of unsoundnessSoundness bugsSoundness bugsFasterFasterSuperb articleSuperb article

Sort: