Skip to content

Make region equality emits Eq constraints#155258

Merged
rust-bors[bot] merged 1 commit intorust-lang:mainfrom
ShoyuVanilla:eq-constraint
Apr 18, 2026
Merged

Make region equality emits Eq constraints#155258
rust-bors[bot] merged 1 commit intorust-lang:mainfrom
ShoyuVanilla:eq-constraint

Conversation

@ShoyuVanilla
Copy link
Copy Markdown
Member

@ShoyuVanilla ShoyuVanilla commented Apr 13, 2026

View all comments

For context, see..

@rustbot rustbot added 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. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver) labels Apr 13, 2026
@ShoyuVanilla
Copy link
Copy Markdown
Member Author

r? lcnr

@ShoyuVanilla ShoyuVanilla marked this pull request as ready for review April 13, 2026 20:52
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 13, 2026

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. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Apr 13, 2026
//~| ERROR mismatched `self` parameter type
//~| NOTE expected struct `Foo<'a, 'b>`
//~| NOTE found struct `Foo<'b, 'a>`
//~| NOTE lifetime mismatch
Copy link
Copy Markdown
Member Author

@ShoyuVanilla ShoyuVanilla Apr 13, 2026

Choose a reason for hiding this comment

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

View changes since the review

Other tests are untouched but this has been affected somehow (I guess this might be due to having some duplication with both 'a: 'b, 'b: 'a and 'a == 'b)
I think this might be okay as it's unchanged anyway modulo diagnostics deduplication

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

seems fine 🤷

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This somehow got returned back again while destructuring eq bounds 😂

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@ShoyuVanilla
Copy link
Copy Markdown
Member Author

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Apr 14, 2026
Make region equality emits Eq constraints
@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Apr 14, 2026
@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors Bot commented Apr 14, 2026

☀️ Try build successful (CI)
Build commit: 52727e5 (52727e55499277ba04069f2dfd8ca8cbbc4e76b6, parent: 338dff3e3a375cb4a3c68be825058c582262655a)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (52727e5): comparison URL.

Overall result: ❌✅ regressions and improvements - 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
@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
Regressions ❌
(secondary)
0.2% [0.0%, 0.3%] 6
Improvements ✅
(primary)
-0.3% [-0.5%, -0.2%] 23
Improvements ✅
(secondary)
-0.5% [-1.3%, -0.0%] 27
All ❌✅ (primary) -0.3% [-0.5%, -0.2%] 23

Max RSS (memory usage)

Results (secondary -0.9%)

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)
3.3% [0.9%, 5.7%] 2
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-3.1% [-3.6%, -2.8%] 4
All ❌✅ (primary) - - 0

Cycles

Results (primary -2.4%, secondary -5.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)
- - 0
Improvements ✅
(primary)
-2.4% [-2.4%, -2.4%] 1
Improvements ✅
(secondary)
-5.3% [-8.9%, -1.9%] 10
All ❌✅ (primary) -2.4% [-2.4%, -2.4%] 1

Binary size

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

Bootstrap: 489.33s -> 490.845s (0.31%)
Artifact size: 394.21 MiB -> 394.03 MiB (-0.04%)

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Apr 14, 2026
@ShoyuVanilla
Copy link
Copy Markdown
Member Author

Oh, looks like having less number of constraints by collapsing into Eq helps the perf a bit

Comment thread compiler/rustc_borrowck/src/type_check/constraint_conversion.rs Outdated
Comment thread compiler/rustc_infer/src/infer/canonical/query_response.rs Outdated
Copy link
Copy Markdown
Contributor

@lcnr lcnr left a comment

Choose a reason for hiding this comment

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

I would keep assumptions as bidirectional outlives and never have Eq in there

can you make sure we always exhaustively match on ConstraintKind 🤔 I do dislike constraint kind as a concept and feel like we should just match on the actual region instead of separately storing that in the ConstraintKind

View changes since this review

Comment thread compiler/rustc_middle/src/infer/canonical.rs Outdated
Comment thread compiler/rustc_infer/src/infer/outlives/mod.rs Outdated
Comment thread compiler/rustc_infer/src/infer/region_constraints/leak_check.rs Outdated
Comment thread compiler/rustc_type_ir/src/elaborate.rs
Comment thread compiler/rustc_type_ir/src/predicate.rs Outdated
Comment on lines +48 to +51
/// - We want to uplift bidirectional constraints to the caller instead of unifying them
/// when solving nested goals, otherwise we often lose implied bounds.
/// - But we still want to know they are equal from the caller. This is crucial when we
/// are proving other nested goals which are sensitive to region equalities.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this comment is slightly confusing/unhelpful to me right now. It is hard to express why exactly we need this, because really, it is a hack required by the better solution not being possible

"otherwise we often lose implied bounds", what do you mean, what is often, link to a relevant example

I think the framing here isn't quite right. For me the issue is that having existential regions which aren't actually existential is not something which we can support.

Also, "know they are equal" seems slightly odd to me. Know they are equal means "unify existential regions with regions they are equal to, to resolve them to the same thing" here I think? Maybe make that more clear

I also think our conversation on zulip has been useful here, so maybe just link to that 😁

@ShoyuVanilla
Copy link
Copy Markdown
Member Author

I would keep assumptions as bidirectional outlives and never have Eq in there

Okay, I'll keep them as they are.

can you make sure we always exhaustively match on ConstraintKind 🤔 I do dislike constraint kind as a concept and feel like we should just match on the actual region instead of separately storing that in the ConstraintKind

Yeah, I also thought ConstraintKind is very iffy while working on this 😅 Maybe it would be great to clean them up as a follow up. For now, I'll make sure they are exhaustively matched

@rust-bors rust-bors Bot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Apr 18, 2026
@JonathanBrouwer
Copy link
Copy Markdown
Contributor

@bors p=6
Scheduling this before the next rollup

@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Apr 18, 2026
Make region equality emits Eq constraints



For context, see..

- The box named *coroutine witness Send lifetime requirements now considered by leakcheck* from [this roadmap](https://raw.githubusercontent.com/hexcatnl/roadmap/6f23e638f65249ef02af86a5454275103a71552d/next-solver.svg)
- [#t-types/trait-system-refactor > A question on #251 @ 💬](https://rust-lang.zulipchat.com/#narrow/channel/364551-t-types.2Ftrait-system-refactor/topic/A.20question.20on.20.23251/near/584166935)
- Comments on `rustc_type_ir::predicate::RegionEqPredicate`
@rust-log-analyzer

This comment has been minimized.

@rust-bors rust-bors Bot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Apr 18, 2026
@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors Bot commented Apr 18, 2026

💔 Test for e297e30 failed: CI. Failed job:

@ShoyuVanilla
Copy link
Copy Markdown
Member Author

I'm so cursed 🙃

@rust-bors rust-bors Bot 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 Apr 18, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 18, 2026

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@ShoyuVanilla
Copy link
Copy Markdown
Member Author

@bors retry

@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors Bot commented Apr 18, 2026

❗ You can only retry pull requests that are approved and have a previously failed auto build.

@ShoyuVanilla
Copy link
Copy Markdown
Member Author

@bors r=lcnr

@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors Bot commented Apr 18, 2026

📌 Commit ace3aa3 has been approved by lcnr

It is now in the queue for this repository.

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

This comment has been minimized.

@rust-bors rust-bors Bot added merged-by-bors This PR was explicitly merged by bors. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Apr 18, 2026
@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors Bot commented Apr 18, 2026

☀️ Test successful - CI
Approved by: lcnr
Duration: 3h 11m 24s
Pushing b2f1ccf to main...

@rust-bors rust-bors Bot merged commit b2f1ccf into rust-lang:main Apr 18, 2026
12 checks passed
@rustbot rustbot added this to the 1.97.0 milestone Apr 18, 2026
@github-actions
Copy link
Copy Markdown
Contributor

What is this? This is an experimental post-merge analysis report that shows differences in test outcomes between the merged PR and its parent PR.

Comparing 3142bea (parent) -> b2f1ccf (this PR)

Test differences

Show 24 test diffs

24 doctest diffs were found. These are ignored, as they are noisy.

Test dashboard

Run

cargo run --manifest-path src/ci/citool/Cargo.toml -- \
    test-dashboard b2f1ccf524a3a4cf9c34545167cc23b659cf1cbd --output-dir test-dashboard

And then open test-dashboard/index.html in your browser to see an overview of all executed tests.

Job duration changes

  1. x86_64-gnu-llvm-21-3: 1h 25m -> 2h 2m (+44.5%)
  2. dist-x86_64-llvm-mingw: 1h 29m -> 2h 5m (+40.0%)
  3. x86_64-msvc-ext2: 1h 22m -> 1h 48m (+31.3%)
  4. x86_64-gnu-debug: 1h 36m -> 2h 5m (+30.2%)
  5. dist-powerpc-linux: 1h 12m -> 1h 30m (+25.5%)
  6. x86_64-gnu-distcheck: 1h 54m -> 2h 20m (+23.4%)
  7. dist-various-1: 1h 13m -> 56m 56s (-22.7%)
  8. dist-ohos-armv7: 1h 12m -> 57m 27s (-20.9%)
  9. dist-armv7-linux: 1h 30m -> 1h 12m (-20.2%)
  10. i686-msvc-1: 2h 54m -> 2h 21m (-18.8%)
How to interpret the job duration changes?

Job durations can vary a lot, based on the actual runner instance
that executed the job, system noise, invalidated caches, etc. The table above is provided
mostly for t-infra members, for simpler debugging of potential CI slow-downs.

@rust-timer
Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (b2f1ccf): comparison URL.

Overall result: ✅ improvements - no action needed

@rustbot label: -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
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.3% [-0.4%, -0.2%] 21
Improvements ✅
(secondary)
-0.5% [-1.2%, -0.1%] 26
All ❌✅ (primary) -0.3% [-0.4%, -0.2%] 21

Max RSS (memory usage)

Results (primary -6.3%, secondary 1.7%)

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)
1.7% [0.6%, 5.1%] 4
Improvements ✅
(primary)
-6.3% [-7.0%, -5.6%] 2
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -6.3% [-7.0%, -5.6%] 2

Cycles

Results (secondary -7.7%)

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)
3.5% [3.5%, 3.5%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-11.5% [-17.6%, -3.2%] 3
All ❌✅ (primary) - - 0

Binary size

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

Bootstrap: 492.552s -> 492.524s (-0.01%)
Artifact size: 394.41 MiB -> 394.41 MiB (0.00%)

@rustbot rustbot removed the perf-regression Performance regression. label Apr 18, 2026
@ShoyuVanilla ShoyuVanilla deleted the eq-constraint branch April 18, 2026 23:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merged-by-bors This PR was explicitly merged by bors. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc 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