Skip to content

expand WF obligations when checking method calls #144704

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

compiler-errors
Copy link
Member

@compiler-errors compiler-errors commented Jul 30, 2025

Don't wrap a bunch of signatures in FnPtr then check their WF; instead, check the WFness of each input/output separately.

This is useful for the new trait solver, since because we stall on root obligations we end up needing to repeatedly recompute the WFness of possibly very large function signature types if it ends up bottoming out in ambiguity.

This may also give us more chances to hit the WF fast path for certain types like built-ins.

Finally, this just seems conceptually correct to do. There's nothing conceptually that suggests that wrapping the function signature in an fn pointer makes sense at all to do; I'm guessing that it was just convenient so that we didn't have to register WF obligations in a loop, but it doesn't affect the readability of this code at all.

@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. labels Jul 30, 2025
@compiler-errors
Copy link
Member Author

@bors2 try @rust-timer queue

@rust-timer

This comment has been minimized.

rust-bors bot added a commit that referenced this pull request Jul 30, 2025
expand WF obligations when checking method calls
@rust-bors
Copy link

rust-bors bot commented Jul 30, 2025

⌛ Trying commit 170ccbf with merge 732256d

To cancel the try build, run the command @bors try cancel.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jul 30, 2025
@rust-bors
Copy link

rust-bors bot commented Jul 30, 2025

☀️ Try build successful (CI)
Build commit: 732256d (732256d64d426bee934865a624326e817fab77ca, parent: e5e79f8bd428d0b8d26e8240d718b134ef297459)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (732256d): comparison URL.

Overall result: ❌✅ regressions and improvements - please read the text below

Benchmarking this pull request means it may be perf-sensitive – we'll automatically label it not fit for rolling up. You can override this, but we strongly advise not to, due to possible changes in compiler perf.

Next Steps: If you can justify the regressions found in this try perf run, please do so in sufficient writing along with @rustbot label: +perf-regression-triaged. If not, please fix the regressions and do another perf run. If its results are neutral or positive, the label will be automatically removed.

@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.3% [0.2%, 0.3%] 2
Regressions ❌
(secondary)
0.7% [0.1%, 1.1%] 10
Improvements ✅
(primary)
-0.2% [-0.4%, -0.2%] 19
Improvements ✅
(secondary)
-1.2% [-8.3%, -0.2%] 31
All ❌✅ (primary) -0.2% [-0.4%, 0.3%] 21

Max RSS (memory usage)

Results (primary -1.9%, secondary -2.2%)

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)
-1.9% [-2.8%, -0.9%] 2
Improvements ✅
(secondary)
-2.2% [-2.8%, -1.1%] 7
All ❌✅ (primary) -1.9% [-2.8%, -0.9%] 2

Cycles

Results (secondary -3.0%)

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.4% [4.4%, 4.4%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-4.3% [-7.0%, -2.2%] 6
All ❌✅ (primary) - - 0

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 469.342s -> 468.025s (-0.28%)
Artifact size: 376.86 MiB -> 376.85 MiB (-0.00%)

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Jul 31, 2025
@compiler-errors
Copy link
Member Author

r? lcnr

@compiler-errors compiler-errors marked this pull request as ready for review July 31, 2025 13:19
@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 Jul 31, 2025
@compiler-errors
Copy link
Member Author

The only major perf regression here is match-stress which seems somewhat unrelated and might just be noise (#144699 (comment)).

@lcnr
Copy link
Contributor

lcnr commented Jul 31, 2025

While these changes here are neutral to positive and I agree using an FnPtr type to represent arbitrary signatures is kinda iffy, it does make me a bit sad.

It seems to indicate that we're leaving a lot of perf on the table by not returning the stalled WellFormed(?leaf_infer) from the trait solver in general. I think that now that the root actually tracks recursion_limit per obligation anyway, it's not that hard to return nested goals. My only other concern is cycle handling/detection 🤔 I do believe that as long as we only ever return nested <infer-ty>: Trait or WellFormed(<infer-ty>) goals we're still gonna properly detect the cycles once that <infer-ty> is resolved, just with a potentially different root

edit: and diagnostics :3

@bors r+

@bors
Copy link
Collaborator

bors commented Jul 31, 2025

📌 Commit 170ccbf has been approved by lcnr

It is now in the queue for this repository.

@bors bors 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-review Status: Awaiting review from the assignee but also interested parties. labels Jul 31, 2025
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-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. 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