The next-solver is not yet enabled on nightly, but will be soon. This issue is currently still WIP to collect all the relevant changes and relevant information.
The the next-generation trait solver will be enabled on nightly by default. This is the largest single change to the Rust compiler since its initial stable release. It completely replaces the existing type system components responsible for proving where-clauses, normalizing associated types, and much more.
It is an internal component of rustc and the main benefits will come in the future as the removal of the old implementation will unblock features such a Type Alias Impl Trait and Return Type Notation, adding new implicit default trait bounds, e.g. Move and Forget, large future compile-time performance improvements and will enable us to fix the remaining type system unsoundnesses. Even so, there are already a lot of intended behavior changes. When developing on nightly, you may rely on subtle type inference or method and trait resolution changes which cause your project to not compile on the previous stable version.
This issue collects intended changes and their impact, both intended and any remaining bugs and issues. If you are affected by this change, please tell us about it. Either here, in a separate GitHub issue, or on zulip.
This is only being enabled on nightly. To disable the next-generation trait solver, you can pass -Znext-solver=coherence to rustc, use RUSTFLAGS=-Znext-solver=coherence, or change your project's .cargo/config.toml configuration file:
[target.x86_64-unknown-linux-gnu]
rustflags = ["-Znext-solver=coherence"]
We want to not only know about what changes due to the new implementation, but also how widespread its impact is. Please tell us if you're working on a project which is not on this list, even if the underlying issue is already known.
Known impact and breakage
When relating higher-ranked types containing associated types, the old implementation sometimes incorrectly guided inference. See mitsuhiko/minijinja#787 for an example of this intended breakage and how to fix it.
The old implementation did not properly track the required recursion depth when using cache entries, causing it to accept programs whose required depth exceeded the recursion_limit. The next-generation trait solver tracks the depth required for cache entries and therefore causes some crates to now hit the recursion limit which previously did not. We have weakened these errors to a Future Compatibility Warning for now.
Proving where-clauses can sometimes result in cycles. The way they are handled is quite involved depending on which bounds participate in a cycle. The old implementation incorrectly treats some cycles as an error even though these cycles should result in ambiguity. This can then be used to avoid ambiguity in method selection.
Handling of Return Position impl Trait
We have significantly changed the way Return Position impl Trait - but also the unstable Type Alias Impl Trait and Return Type Notation - are handled. This results in a lot of minor type inference changes and fixes, but also breaks some crates.
Most changes here are intended, one exception is rust-lang/trait-system-refactor-initiative#248 which we'll fix going forward.
Affected crates
When tracking the affected versions, we're using ❌ for versions which are not patched yet while ✔️ indicates that there is a minor version in which this breakage has been fixed.
Compilation errors
| crate |
cause |
known affected versions |
bevy_ecs |
higher-ranked associated type |
0.15 ✔️ |
commit_verify |
trait solver cycle handling |
0.10-0.11 ❌ |
diskann-wide |
higher-ranked associated type |
0.55 ❌ |
git-url-parse |
non dyn-compatible trait object |
0.6 ❌ |
gizmo-core |
higher-ranked associated type |
0.1-0.8 ❌ |
glaredb_core |
higher-ranked associated type |
25 ❌ |
minijinja |
higher-ranked associated type |
0.23-0.34 ❌ 1 ✔️ 2 ✔️ |
tera |
higher-ranked associated type |
2 ✔️ |
Future compatibility warnings
| crate |
cause |
known affected versions |
generic-array |
recursion depth tracking |
1 ❌ |
wgpu |
recursion depth tracking |
25-30 ❌ |
The the next-generation trait solver will be enabled on nightly by default. This is the largest single change to the Rust compiler since its initial stable release. It completely replaces the existing type system components responsible for proving where-clauses, normalizing associated types, and much more.
It is an internal component of
rustcand the main benefits will come in the future as the removal of the old implementation will unblock features such a Type Alias Impl Trait and Return Type Notation, adding new implicit default trait bounds, e.g.MoveandForget, large future compile-time performance improvements and will enable us to fix the remaining type system unsoundnesses. Even so, there are already a lot of intended behavior changes. When developing on nightly, you may rely on subtle type inference or method and trait resolution changes which cause your project to not compile on the previous stable version.This issue collects intended changes and their impact, both intended and any remaining bugs and issues. If you are affected by this change, please tell us about it. Either here, in a separate GitHub issue, or on zulip.
This is only being enabled on nightly. To disable the next-generation trait solver, you can pass
-Znext-solver=coherencetorustc, useRUSTFLAGS=-Znext-solver=coherence, or change your project's.cargo/config.tomlconfiguration file:We want to not only know about what changes due to the new implementation, but also how widespread its impact is. Please tell us if you're working on a project which is not on this list, even if the underlying issue is already known.
Known impact and breakage
Avoiding incorrect type inference when relating higher-ranked associated types
When relating higher-ranked types containing associated types, the old implementation sometimes incorrectly guided inference. See mitsuhiko/minijinja#787 for an example of this intended breakage and how to fix it.
Correctly tracking the required recursion depth
The old implementation did not properly track the required recursion depth when using cache entries, causing it to accept programs whose required depth exceeded the
recursion_limit. The next-generation trait solver tracks the depth required for cache entries and therefore causes some crates to now hit the recursion limit which previously did not. We have weakened these errors to a Future Compatibility Warning for now.Trait solver cycles were sometimes treated as errors
Proving where-clauses can sometimes result in cycles. The way they are handled is quite involved depending on which bounds participate in a cycle. The old implementation incorrectly treats some cycles as an error even though these cycles should result in ambiguity. This can then be used to avoid ambiguity in method selection.
Handling of Return Position
impl TraitWe have significantly changed the way Return Position
impl Trait- but also the unstable Type Alias Impl Trait and Return Type Notation - are handled. This results in a lot of minor type inference changes and fixes, but also breaks some crates.Most changes here are intended, one exception is rust-lang/trait-system-refactor-initiative#248 which we'll fix going forward.
Affected crates
When tracking the affected versions, we're using ❌ for versions which are not patched yet while ✔️ indicates that there is a minor version in which this breakage has been fixed.
Compilation errors
bevy_ecs0.15✔️commit_verify0.10-0.11❌diskann-wide0.55❌git-url-parse0.6❌gizmo-core0.1-0.8❌glaredb_core25❌minijinja0.23-0.34❌1✔️2✔️tera2✔️Future compatibility warnings
generic-array1❌wgpu25-30❌