Skip to content

trait solver: Resolve region vars before eager placeholder handling - #164103

Open
Dnreikronos wants to merge 3 commits into
rust-lang:mainfrom
Dnreikronos:trait_solver_resolve_region_vars
Open

Dnreikronos wants to merge 3 commits into
rust-lang:mainfrom
Dnreikronos:trait_solver_resolve_region_vars

Conversation

@Dnreikronos

@Dnreikronos Dnreikronos commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Region vars can already have known values in the unification table while the stored constraint still contains the vars. max_universe looks through the table, but PlaceholderReplacer sees the stored terms. In Boxy's nested binder case, that leaves an alias constraint ambiguous even after equating its regions.

I used deeply_resolve_via_unification_table at the start of eager handling for each universe. That leaves only the current universe's placeholder to bind and lets the result match the actual assumption on the outer binder. Unknown vars stay unknown.

The test DSL needed a small equality operation, 'a2 = 'a, to reach this state. The paired outlives constraints in the original example go straight into solver storage and don't populate the table on current main. I added the version with real table equalities, plus a chained-var case. Both adjusted cases fail when the resolution call is removed and pass with it.

I think keeping this separate makes #157984 easier to review. The broader equality and subtyping work stays there.

@rustbot

rustbot commented Oct 10, 2026

Copy link
Copy Markdown
Collaborator

The parser was modified, potentially altering the grammar of (stable) Rust
which would be a breaking change.

cc @fmease

@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 Oct 10, 2026
@rustbot

rustbot commented Oct 10, 2026

Copy link
Copy Markdown
Collaborator

r? @davidtwco

rustbot has assigned @davidtwco.
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 77 candidates
  • Random selection from 18 candidates

@Dnreikronos

Copy link
Copy Markdown
Contributor Author

r? @BoxyUwU

@rustbot rustbot assigned BoxyUwU and unassigned davidtwco Oct 10, 2026
@rustbot

rustbot commented Oct 10, 2026

Copy link
Copy Markdown
Collaborator

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

@BoxyUwU

This comment was marked as outdated.

@BoxyUwU

BoxyUwU commented Oct 12, 2026

Copy link
Copy Markdown
Member

@rustbot author

thanks for splitting this out, and good job on the test DSL changes :3

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 12, 2026
@rustbot

rustbot commented Oct 12, 2026

Copy link
Copy Markdown
Collaborator

Reminder, once the PR becomes ready for a review, use @rustbot ready.

@BoxyUwU

BoxyUwU commented Oct 12, 2026

Copy link
Copy Markdown
Member

ah actually ignore my previous comment, didn't realise that we don't put unify vars in the table if there's universe errors. that's just a problem for when we yeet the unificiation table in favour of region graph based resolution

@rustbot ready
@bors r+ rollup

@rust-bors

rust-bors Bot commented Oct 12, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 67e2ab8 has been approved by BoxyUwU

It is now in the queue for this repository.

@rustbot rustbot removed the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Oct 12, 2026
@rust-bors rust-bors Bot added the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Oct 12, 2026
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Oct 12, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Oct 12, 2026
…egion_vars, r=BoxyUwU

trait solver: Resolve region vars before eager placeholder handling

Region vars can already have known values in the unification table while the stored constraint still contains the vars. `max_universe` looks through the table, but `PlaceholderReplacer` sees the stored terms. In Boxy's nested binder case, that leaves an alias constraint ambiguous even after equating its regions.

I used `deeply_resolve_via_unification_table` at the start of eager handling for each universe. That leaves only the current universe's placeholder to bind and lets the result match the actual assumption on the outer binder. Unknown vars stay unknown.

The test DSL needed a small equality operation, `'a2 = 'a`, to reach this state. The paired outlives constraints in the original example go straight into solver storage and don't populate the table on current main. I kept that example as an ambiguity control and added the version with real table equalities, plus a chained-var case. Both adjusted cases fail when the resolution call is removed and pass with it.

I think keeping this separate makes rust-lang#157984 easier to review. The broader equality and subtyping work stays there.
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Oct 12, 2026
…egion_vars, r=BoxyUwU

trait solver: Resolve region vars before eager placeholder handling

Region vars can already have known values in the unification table while the stored constraint still contains the vars. `max_universe` looks through the table, but `PlaceholderReplacer` sees the stored terms. In Boxy's nested binder case, that leaves an alias constraint ambiguous even after equating its regions.

I used `deeply_resolve_via_unification_table` at the start of eager handling for each universe. That leaves only the current universe's placeholder to bind and lets the result match the actual assumption on the outer binder. Unknown vars stay unknown.

The test DSL needed a small equality operation, `'a2 = 'a`, to reach this state. The paired outlives constraints in the original example go straight into solver storage and don't populate the table on current main. I kept that example as an ambiguity control and added the version with real table equalities, plus a chained-var case. Both adjusted cases fail when the resolution call is removed and pass with it.

I think keeping this separate makes rust-lang#157984 easier to review. The broader equality and subtyping work stays there.
@JonathanBrouwer

Copy link
Copy Markdown
Member

💔 I suspect this PR failed tests as part of a rollup
@bors r-

After fixing the problem, consider running a try job for the failed job before re-approving.

Link to failure: #164212 (comment)

@rust-bors rust-bors Bot added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Oct 12, 2026
@rust-bors rust-bors Bot removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Oct 12, 2026
@rust-bors

rust-bors Bot commented Oct 12, 2026

Copy link
Copy Markdown
Contributor

This pull request was unapproved.

This PR was contained in a rollup (#164212), which was unapproved.

View changes since this unapproval

@Dnreikronos

Copy link
Copy Markdown
Contributor Author

@BoxyUwU @JonathanBrouwer I removed the ambiguity control and pushed a follow-up after checking the bors failure. It expected ambiguity from unresolved region vars, but #164045 now turns those vars into bound vars and produces concrete alias constraints, so that expectation no longer holds.

I originally kept the paired outlives example because those constraints don't populate the unification table, which helped explain why the DSL needed explicit equality. Looking at the failure, though, that control was also depending on the old handling of unresolved vars. I think removing it makes sense here and keeps the tests focused on resolving values already known in the table.

The compiler change stays as it is. I kept the equality and chained-variable tests, including their exact intermediate expectations, and both passed in the failed rollup.

This branch has not been deployed

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

Labels

S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants