Skip to content

remove more trivial regions in evaluate_added_goals_and_make_canonical_response - #162032

Open
sjwang05 wants to merge 1 commit into
rust-lang:mainfrom
sjwang05:more-region-dedup
Open

remove more trivial regions in evaluate_added_goals_and_make_canonical_response#162032
sjwang05 wants to merge 1 commit into
rust-lang:mainfrom
sjwang05:more-region-dedup

Conversation

@sjwang05

@sjwang05 sjwang05 commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

cc #161575. I don't think it fixes the issue per se, since the most principled fix would be to just deny unconstrained lifetime args like we do for types and consts already. At the very least, though, it Makes Things Go Faster.

In the example from #161575 (comment), each 'unconstrained appears only once in the entire response: in the rhs of the 'a: 'unconstrained#N bound. Since they are mentioned nowhere else and are created only when proving our own nested goals, these outlives constraints are all satisfiable by setting 'unconstrained := 'empty, which tells us nothing about 'a. Therefore, (I think) that makes it safe to treat all of these constraints as trivial and drop them entirely, drop all of these requirements entirely, similar to what we already do with reflexive or duplicate region constraints. In other words, if a ReVar appears only once in the entire response, and that place is the rhs of an outlives constraint, then it is safe to drop that constraint.

I'm a little worried about the perf impact of the visitor on "normal" code, but fwiw even a 100-deep nested version of the reproducer compiles in about 0.05s on my machine.

r? lcnr

@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 30, 2026
@sjwang05

sjwang05 commented Aug 30, 2026

Copy link
Copy Markdown
Contributor Author

Fun fact: the number of outlives constraints grows exactly as fib(2 * depth) :D

@rust-log-analyzer

This comment has been minimized.

@ShoyuVanilla

Copy link
Copy Markdown
Member

@bors try @rust-timer queue

@rust-timer

Copy link
Copy Markdown
Collaborator

Awaiting bors try build completion.

@rustbot label: +S-waiting-on-perf

@rust-bors

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Aug 31, 2026
rust-bors Bot pushed a commit that referenced this pull request Aug 31, 2026
remove more trivial regions in evaluate_added_goals_and_make_canonical_response

// If we have a constraint like `'re: '?1`, and `?1` appears nowhere else in the response
// besides the constraint itself, then this kind of constraint is also trivial, since
// one can always pick `'?1 := 'empty`, and `'re: 'empty` is always true for any 're.

@ShoyuVanilla ShoyuVanilla Aug 31, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we consider the universes of region vars?

View changes since the review

@rust-bors

rust-bors Bot commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: 0be4976 (0be497690edf5f58dfd2a6cfff82660c9c75ffa6)
Base parent: 5321a4f (5321a4f40c957cf3587c055e77461febc2ebc865)

@rust-timer

Copy link
Copy Markdown
Collaborator

Queued 0be4976 with parent 5321a4f, future comparison URL.
There is currently 1 preceding artifact in the queue.
It will probably take at least ~2.0 hours until the benchmark run finishes.

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

Labels

S-waiting-on-perf Status: Waiting on a perf run to be completed. 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.

6 participants