-Znext-solver: fix opaque type implied bounds unsoundness - #160425
Closed
lcnr wants to merge 1 commit into
Closed
Conversation
lcnr
force-pushed
the
fix-implied-bounds
branch
from
August 3, 2026 09:57
ef7abd9 to
253845d
Compare
This comment has been minimized.
This comment has been minimized.
lcnr
force-pushed
the
fix-implied-bounds
branch
from
August 3, 2026 10:05
253845d to
99d2b02
Compare
This comment has been minimized.
This comment has been minimized.
lcnr
force-pushed
the
fix-implied-bounds
branch
from
August 3, 2026 10:16
61b3dd5 to
27bab43
Compare
Contributor
Author
|
proper fix in #160443 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This fixes rust-lang/trait-system-refactor-initiative#159 for RPIT and RPITIT. It does not fix the issue for TAIT and RTN, this is blocked on the proper fix as implemented in #152051. This is sufficient to unblock the stabilization of the new trait solver.
The core idea is to explicitly mark in the signature as rigid, even if we're in their defining scope. With RPITIT we can also get opaque types in the
ParamEnvviaProjection(synthetic_assoc_ty, opaque_ty)clauses. We also need to mark theopaque_tyfrom these as rigid. We do this by manually modifying theParamEnvused by normalization and implied bounds computation.This is very similar to actually being outside of the defining scope as we never try to renormalize rigid aliases. However, reasoning about its correctness is quite subtle!
On stable, the only place where we encounter opaque types is in the return type of methods. Either directly, or hidden behind the synthetic assoc type for RPITIT. There is no way you get an opaque type into a function signature without it being in the
ParamEnvor the signature itself. This isn't actually correct. We can get opaque types via item bounds of other opaquesWe could get implied bounds using opaques from the signature of a closure. However, closure signatures are already fully normalized so it doesn't reference any potentially normalizeable opaque types directly.