Rust Next Trait Solver Lands in 1.102 After Speed Fixes

The Rust next trait solver will finally land in Rust 1.102.0, replacing a large piece of the compiler that developers have been trying to swap out for years. Performance was the last major blocker before stabilization. In one hard case, a crate called wg-grammar went from about 200 billion CPU cycles to compile to roughly 7 billion.

The optimization work was presented at EuroRust on October 15, 2026 by a compiler contributor focused on the new solver’s speed.

What the Rust next trait solver does

A trait is a property of a type, such as being cloneable. When the compiler checks your code, it often has to confirm that a type has the property a function needs. The trait solver answers those questions.

It looks for proof in three places: impl blocks, built-in compiler rules and where bounds. Proving that i32 implements Add comes from an impl block in the standard library. Proving it is Sized, which every local variable needs, is built into the compiler. Inside a generic function, a where bound acts as a given. Proofs can spawn sub-questions: a struct is Sized only if every field is, so the solver recurses. Compiling the standard library triggers about 800,000 Sized questions.

The design resembles Prolog, a logic language. The earlier Chalk project, started 72 days after Rust 1.0 in 2015, tried to formalize the trait system as a Prolog-like solver. It has since been sunset. Work on the new solver began officially in October 2022.

A chart showing, for various crates, how many percent of questions are cached. Diesel (81.8% hit rate), Serde (86.6% hit rate), Syn (81.4% hit rate) and wg-grammar (73% hit rate). It also shows an "improved" wg-grammar with 79% hit rate
Image: donsz.nl

Why Rust needed a new trait solver

The goal is correctness, summed up as “project zero” soundness bugs in the type system. Some bugs in the old solver can’t be fixed in its design. One, open since May 28, 2015, abuses implied bounds to stretch a short lifetime into a ‘static one, which allows use of a reference after it’s freed.

A plot of the wg-grammar benchmark from perf.rust-lang.org between may and august 2026
Image: donsz.nl

Why trait solving gets slow

Two things drive cost: the compiler calls the solver constantly, and one call can effectively run arbitrary computation up to a recursion limit. Rust’s type system is Turing complete, and people have built numbers and even a chess engine inside it.

Replacing the solver is harder than it sounds. Existing programs depend on the old solver’s assumptions, so some compile faster with the new one and some slower, by polynomial or even exponential factors. One crate that compiled fine before became about 200 times slower under the new solver.

Caching, and when not to cache

The main fix is caching, plus a trick: skipping the cache when a question is trivial. Looking up i32: Sized costs more than just answering it.

A naive cache keyed on questions fails twice. Renaming a type parameter makes an identical question look different, so questions are canonicalized first. And where bounds differ per function, so the key must include the parameter environment. Caching can avoid almost 80% of trait solving in popular crates.

The wg-grammar fix

The Rust next trait solver also had to account for opaque types, the kind a function returns with impl Trait. They were part of the cache key, so two functions asking the same question, such as i32: Clone, couldn’t share an entry if one returned an opaque type. Async code and parser generators that return impl Parser hit this constantly.

In practice opaque types almost never change an answer. So the team moved them out of the key and into the cached value as a record of when they might matter. The solver assumes they don’t. If a cached answer turns out to depend on them, it retries the question without that assumption. That occasionally repeats work, but the cache hit rate for wg-grammar rose from 73% to 79%.

That 6-point gain halved compile time, from 28 seconds to 14. Combined with other changes, the crate fell from nearly 200 billion CPU cycles to about 7 billion.

What the Rust 1.102.0 release means

For most developers, the change will be invisible except for fewer long-standing soundness holes and, hopefully, similar compile times.

Source: donsz.nl

Written by

Saksham Bhargava

Saksham Bhargava runs Alteroid and has been writing about consumer technology for over five years, covering iPhone, Android, Windows, AI tools and gaming. With an MCA and six years of hands-on web development experience, he tests the features he writes about on his own devices and focuses on clear, practical guides that solve real problems. Away from the screen, he enjoys travelling to places most tourists skip.