Skip to content

trait_selection: Restore type-op solver constraints - #163936

Open
Dnreikronos wants to merge 1 commit into
rust-lang:mainfrom
Dnreikronos:trait_selection/restore_type_op_constraints
Open

Dnreikronos wants to merge 1 commit into
rust-lang:mainfrom
Dnreikronos:trait_selection/restore_type_op_constraints

Conversation

@Dnreikronos

@Dnreikronos Dnreikronos commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Bringing back #161423 after @BoxyUwU suggested checking perf again now that Khy's lazy constraint storage from #162531 has landed. The original fix was reverted because of the performance regression.

With assumptions on binders enabled, proving a predicate or normalizing a type can produce solver region constraints inside a canonical query. Those constraints weren't included in the response, so they disappeared when the query's inference context went away. Borrowck could then accept a body with a missing lifetime bound, as in borrowck_env_fail.

The solver constraints now travel in QueryRegionConstraints and get instantiated along with the rest of the response. scrape_region_constraints also drains constraints from completed operations into that same result. Borrowck collects them and lowers them once the body's bounds are available. Constraints from normalizing implied bounds also reach lexical regionck. The cached constraints have no spans, so each caller supplies its own.

I think keeping the constraints in the query response is the right place for this. It keeps the existing query cache and fast paths working, and gives the constraints the same route back to the caller as the other query results. The payload stays optional, so we don't allocate an empty solver constraint tree when AoB is off. I still want a fresh perf run before landing it, since avoiding those allocations alone doesn't tell us what the overall cost is.

The compiler check passed locally, along with the alias-outlives regression, the pass test in default, next-solver and AoB modes, and the three solver-constraint unit tests. Tidy and formatting checks passed too.

r? @BoxyUwU

@rustbot

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

BoxyUwU commented Oct 7, 2026

Copy link
Copy Markdown
Member

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Oct 7, 2026
@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Oct 7, 2026
…onstraints, r=<try>

trait_selection: Restore type-op solver constraints
@rust-bors

rust-bors Bot commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: 081f5df (081f5df2a6df38b659cfe0e213131198dda25b5e)
Base parent: 8d1a764 (8d1a76430406c877b35d0b627e7f796dcf0dfeca)

@rust-timer

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (081f5df): comparison URL.

Overall result: ❌ regressions - please read:

Benchmarking means the PR may be perf-sensitive. It's automatically marked not fit for rolling up. Overriding is possible but disadvised: it risks changing compiler perf.

Next, please: If you can, justify the regressions found in this try perf run in writing along with @rustbot label: +perf-regression-triaged. If not, fix the regressions and do another perf run. Neutral or positive results will clear the label automatically.

@bors rollup=never rustc-perf
@rustbot label: -S-waiting-on-perf +perf-regression

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

mean range count
Regressions ❌
(primary)
0.2% [0.1%, 0.3%] 40
Regressions ❌
(secondary)
0.2% [0.0%, 0.3%] 22
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.2% [0.1%, 0.3%] 40

Max RSS (memory usage)

Results (primary 2.1%, secondary 2.6%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
2.1% [2.1%, 2.1%] 1
Regressions ❌
(secondary)
2.6% [2.6%, 2.6%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 2.1% [2.1%, 2.1%] 1

Cycles

Results (secondary 4.3%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
4.3% [4.3%, 4.3%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Binary size

This perf run didn't have relevant results for this metric.

Bootstrap: 489.893s -> 488.402s (-0.30%)
Artifact size: 408.60 MiB -> 408.71 MiB (0.03%)

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Oct 7, 2026
@BoxyUwU

BoxyUwU commented Oct 7, 2026

Copy link
Copy Markdown
Member

that is significantly better than last time :3 though still subopties

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

perf-regression Performance regression. 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)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants