Skip to content

trait_solver: Reject canonical responses with placeholder universe leaks - #160955

Open
Dnreikronos wants to merge 5 commits into
rust-lang:mainfrom
Dnreikronos:trait_solver/canonical_response_universe_check_rpit
Open

trait_solver: Reject canonical responses with placeholder universe leaks#160955
Dnreikronos wants to merge 5 commits into
rust-lang:mainfrom
Dnreikronos:trait_solver/canonical_response_universe_check_rpit

Conversation

@Dnreikronos

@Dnreikronos Dnreikronos commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Fixes #160802

-Zassumptions-on-binders plus an impl for<T> Trait<T> RPIT was ICEing in proof-tree replay when unify_query_var_values hit .unwrap() on a Sorts error for the same binder placeholder living in two universes. Imo that unwrap was always a bit cursed on the diagnostics path, idk why we kept trusting it this long.

Canonical response/state apply is fallible now and turns those leaks into NoSolution instead of panicking. Region-only placeholders don't block valid region lowering. Also made CoerceVisitor Break when nested candidate replay fails, since Continue was treating a failed instantiate as "unsizing ok" (btw VisitorResult::output is Continue for ControlFlow, easy to miss). Added the issue repro plus a few universe-leak regressions.

Fyi the prev_universe proof-tree fix is already on main and I kept it. Irl I'd rather get this in asap than bike-shed the diagnostics wording further, but ltm if you'd rather the failed replay surface louder than a quiet NoSolution.

Cover opaque returns of `impl for<T> Trait<T>` under -Zassumptions-on-binders
so proof-tree replay no longer ICEs on placeholder universe mismatches.
Proof-tree visitors previously treated instantiate_nested_goals failure as a
successful visit via VisitorResult::output(), which is Continue for
ControlFlow. CoerceVisitor must Break instead so coerce_unsized rejects
inapplicable candidate replay rather than treating it as a valid unsizing path.
@rustbot

rustbot commented Aug 12, 2026

Copy link
Copy Markdown
Collaborator

Some changes occurred to the core trait solver

cc @rust-lang/initiative-trait-system-refactor

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Aug 12, 2026
@rustbot rustbot added the WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver) label Aug 12, 2026
@rustbot

rustbot commented Aug 12, 2026

Copy link
Copy Markdown
Collaborator

r? @folkertdev

rustbot has assigned @folkertdev.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: compiler
  • compiler expanded to 75 candidates
  • Random selection from 19 candidates

@folkertdev

Copy link
Copy Markdown
Contributor

r? types

@rustbot rustbot added the T-types Relevant to the types team, which will review and decide on the PR/issue. label Aug 12, 2026
@rustbot rustbot assigned oli-obk and unassigned folkertdev Aug 12, 2026
@oli-obk

This comment was marked as resolved.

@oli-obk oli-obk closed this Aug 13, 2026
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 13, 2026
@oli-obk oli-obk reopened this Aug 13, 2026
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 13, 2026
@oli-obk

oli-obk commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

r? @BoxyUwU for assumptions on binders stuff

@rustbot rustbot assigned BoxyUwU and unassigned oli-obk Aug 14, 2026
@rustbot

rustbot commented Aug 14, 2026

Copy link
Copy Markdown
Collaborator

BoxyUwU is currently at their maximum review capacity.
They may take a while to respond.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-types Relevant to the types team, which will review and decide on the PR/issue. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[ICE]: AOB: called Result::unwrap() on an Err value: Sorts(ExpectedFound

5 participants