Report unsatisfied opaque item bounds instead of a type mismatch under -Znext-solver - #162123
Open
yashksaini-coder wants to merge 2 commits into
Open
Report unsatisfied opaque item bounds instead of a type mismatch under -Znext-solver#162123yashksaini-coder wants to merge 2 commits into
yashksaini-coder wants to merge 2 commits into
Conversation
Collaborator
|
Some changes occurred to the core trait solver cc @rust-lang/initiative-trait-system-refactor |
Collaborator
|
Thanks for the pull request, and welcome! The Rust Project has assigned @lcnr (or someone else) to review your changes, you should hear from them (or someone else) within the next two weeks. Please see the contribution instructions and our LLM policy for more information. |
This comment has been minimized.
This comment has been minimized.
Collaborator
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
This comment has been minimized.
This comment has been minimized.
A `Projection` goal on a free alias -- e.g. the `Ta` in `type Ta = impl Marker;` -- normalizes to the alias' value. When normalizing that value fails, `normalize_free_alias` returns before reaching `evaluate_added_goals_and_make_canonical_response`, so no `MakeCanonicalResponse` step is recorded and the goal ends up with no candidates at all. `BestObligation` then has nothing to descend into and falls back to reporting a bare `Ta == u32` type mismatch. Recurse into the alias' value instead. That reaches the opaque, which does record a candidate and carries its item bounds as nested `GoalSource::AliasWellFormed` goals, so the unsatisfied bound is reported and `#[diagnostic::on_unimplemented]` applies.
yashksaini-coder
force-pushed
the
issue-162093-tait-on-unimplemented
branch
from
September 6, 2026 14:01
d8c69be to
721f4af
Compare
This comment has been minimized.
This comment has been minimized.
Regression test. Also updates stalled-coroutine-obligations, where three errors improve from `type mismatch resolving` to naming the unsatisfied trait bound. The fourth is an RPIT, which has no free alias in front of the opaque and still reports E0271.
yashksaini-coder
force-pushed
the
issue-162093-tait-on-unimplemented
branch
from
September 6, 2026 14:05
721f4af to
812f3a9
Compare
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.
LLM disclosure
I used Claude extensively on this PR: to explore the compiler source. The initial diagnosis it produced was wrong twice — the first patch it suggested compiled but was entirely dead code. The actual cause (
FreeTyrather thanOpaqueTy) came from debug output I added and ran locally at its suggestion. I have read and understand the final patch, and verified it against a local build and the fulltests/uisuite.Fixes #162093
Under
-Znext-solver, a TAIT whose hidden type doesn't satisfy the opaque's item bounds reported a bare type mismatch rather than naming the unsatisfied bound. This also meant#[diagnostic::on_unimplemented]on that trait never applied.Before
After
What was happening
type Ta = impl Marker;is a free type alias whose value is the opaque, so the failing goal is a projection on aFreeTyalias rather than on the opaque directly.normalize_free_aliasnormalizes the alias' value and propagates failure with?, returning beforeevaluate_added_goals_and_make_canonical_response. NoMakeCanonicalResponsestep gets recorded, andcandidates_recuronly builds a candidate whenshallow_certaintywas set — so the goal ends up with no candidates at all.BestObligationhas nothing to descend into and falls back to the projection obligation, whichfulfillment_error_for_no_solutionturns intoE0271.The fix recurses into the alias' value from
detect_error_from_empty_candidates. That reaches the opaque, which does record a candidate and carries its item bounds as nestedGoalSource::AliasWellFormedgoals, so the realu32: Markerfailure surfaces.Test changes
Three errors in
tests/ui/traits/next-solver/stalled-coroutine-obligations.rsimprove fromtype mismatch resolvingto naming the unsatisfied trait bound.Known gaps
-> impl Future + Send) has no free alias in front of the opaque, so it still reportsE0271— this is the fourth error installed-coroutine-obligations, left unchanged.ObligationCauseCode::OpaqueReturnTypecause code isn't attached, so thereturn type was inferred to beu32herenote the old solver emits is still missing undernext. Visible as a difference between thecurrentandnextrevisions of the new test.Full
tests/uirun is clean (20484 passed, 0 failed).r? lcnr