Skip to content

Skip next-solver fulfillment when no type var was instantiated - #161480

Closed
anonrig wants to merge 1 commit into
rust-lang:mainfrom
anonrig:next-solver-skip-fulfill-without-instantiate
Closed

Skip next-solver fulfillment when no type var was instantiated#161480
anonrig wants to merge 1 commit into
rust-lang:mainfrom
anonrig:next-solver-skip-fulfill-without-instantiate

Conversation

@anonrig

@anonrig anonrig commented Aug 21, 2026

Copy link
Copy Markdown

Refs #159933

r? lcnr

Next-solver fulfillment walks the pending queue on every try_evaluate_obligations. On #159933 (v.push(Default::default()) then v.push(0u8)), each push equates a fresh infer vid with the vec element vid. Those equates are unknown-unknown: ty_or_const_infer_var_changed stays false until a vid is instantiated, but sub_roots go stale and force a full rescan.

This records instantiations in the infer undo log and skips the retain_mut walk when:

  • every pending goal is type-var-only
  • every pending goal is stalled on at most one type var
  • opaque storage is unchanged
  • no type vid was instantiated

Two-var goals (for example Mirror with distinct self and parameter infer vars that later unify) still take the existing path.

-Zdisable-fast-paths disables the skip.

@rustbot

rustbot commented Aug 21, 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. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver) labels Aug 21, 2026
@rustbot

rustbot commented Aug 21, 2026

Copy link
Copy Markdown
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 for more information.

Unknown-unknown equate and sub-unify do not make single-var stalled
goals progress. Track instantiations in the infer undo log and skip
the pending-queue walk when every pending goal is type-var-only with
at most one stalled vid.

This removes the remaining quadratic rescan on rustc#159933: each
`push(Default::default())` equates a fresh vid with the vec element
vid, so goals stay stalled until a later instantiate. Two-var goals
still take the existing path.
@anonrig
anonrig force-pushed the next-solver-skip-fulfill-without-instantiate branch from 30aaa49 to 6b7c35a Compare August 21, 2026 18:26
@anonrig anonrig closed this Aug 21, 2026
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

T-compiler Relevant to the compiler 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.

4 participants