Skip to content
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

obligations_for_self_ty: use ProofTreeVisitor for nested goals #122385

Merged
merged 5 commits into from
Apr 26, 2024

Conversation

lcnr
Copy link
Contributor

@lcnr lcnr commented Mar 12, 2024

As always, dealing with proof trees continues to be a hacked together mess. After this PR and #124380 the only remaining blocker for core is rust-lang/trait-system-refactor-initiative#90. There is also a ProofTreeVisitor issue causing an ICE when compiling alloc which I will handle in a separate PR. This issue likely affects coherence diagnostics more generally.

The core idea is to extend the proof tree visitor to support visiting nested candidates without using a probe. We then simply recurse into nested candidates if they are the only potentially applicable candidate for a given goal and check whether the self type matches the expected one.

For that to work, we need to improve CanonicalState to also handle unconstrained inference variables created inside of the trait solver. This is done by extending the var_values of CanoncalState with each fresh inference variables. Furthermore, we also store the state of all inference variables at the end of each probe. When recursing into InspectCandidates we then unify the values of all these states.

r? @compiler-errors

@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 labels Mar 12, 2024
@rustbot
Copy link
Collaborator

rustbot commented Mar 12, 2024

Some changes occurred to the core trait solver

cc @rust-lang/initiative-trait-system-refactor

@lcnr lcnr marked this pull request as draft March 12, 2024 16:57
@compiler-errors
Copy link
Member

@rustbot author since i think ur still working on this

@rustbot rustbot 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 Mar 12, 2024
@rust-cloud-vms rust-cloud-vms bot force-pushed the analyze-obligations-for-infer branch 2 times, most recently from 7754ca8 to a5f7f1e Compare April 24, 2024 15:24
@rust-log-analyzer

This comment has been minimized.

`super::super` of `rustc_hir_typeck::fn_ctxt::_impl`
is just `rustc_hir_typeck`.
@rust-cloud-vms rust-cloud-vms bot force-pushed the analyze-obligations-for-infer branch from 97c9abd to 6a17037 Compare April 25, 2024 15:22
@rustbot rustbot added A-testsuite Area: The testsuite used to check the correctness of rustc T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) labels Apr 25, 2024
@rust-cloud-vms rust-cloud-vms bot force-pushed the analyze-obligations-for-infer branch from c09ae21 to 7cf4574 Compare April 25, 2024 19:43
uses a `ProofTreeVisitor` to look into nested
goals when looking at the pending obligations
during hir typeck. Used by closure signature
inference, coercion, and for async functions.
@rust-cloud-vms rust-cloud-vms bot force-pushed the analyze-obligations-for-infer branch from 7cf4574 to 03878c6 Compare April 25, 2024 19:44
@lcnr lcnr marked this pull request as ready for review April 25, 2024 19:52
@compiler-errors
Copy link
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 Apr 25, 2024
bors added a commit to rust-lang-ci/rust that referenced this pull request Apr 25, 2024
…r=<try>

`obligations_for_self_ty`: use `ProofTreeVisitor` for nested goals

As always, dealing with proof trees continues to be a hacked together mess. After this PR and rust-lang#124380 the only remaining blocker for core is rust-lang/trait-system-refactor-initiative#90. There is also a `ProofTreeVisitor` issue causing an ICE when compiling `alloc` which I will handle in a separate PR. This issue likely affects coherence diagnostics more generally.

The core idea is to extend the proof tree visitor to support visiting nested candidates without using a `probe`. We then simply recurse into nested candidates if they are the only potentially applicable candidate for a given goal and check whether the self type matches the expected one.

For that to work, we need to improve `CanonicalState` to also handle unconstrained inference variables created inside of the trait solver. This is done by extending the `var_values` of `CanoncalState` with each fresh inference variables. Furthermore, we also store the state of all inference variables at the end of each probe. When recursing into `InspectCandidates` we then unify the values of all these states.

r? `@compiler-errors`
@bors
Copy link
Contributor

bors commented Apr 25, 2024

⌛ Trying commit 03878c6 with merge 5cd2d13...

Copy link
Member

@compiler-errors compiler-errors left a comment

Choose a reason for hiding this comment

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

thanks! this is great. r=me after perf is ready.

@compiler-errors
Copy link
Member

the try build in question: https://github.com/rust-lang-ci/rust/actions/runs/8838574745

@rustbot rustbot added the A-meta Area: Issues & PRs about the rust-lang/rust repository itself label Apr 25, 2024
@rustbot
Copy link
Collaborator

rustbot commented Apr 25, 2024

triagebot.toml has been modified, there may have been changes to the review queue.

cc @davidtwco, @wesleywiser

@lcnr
Copy link
Contributor Author

lcnr commented Apr 26, 2024

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@bors
Copy link
Contributor

bors commented Apr 26, 2024

⌛ Trying commit 146f637 with merge 9dcd6e5...

bors added a commit to rust-lang-ci/rust that referenced this pull request Apr 26, 2024
…r=<try>

`obligations_for_self_ty`: use `ProofTreeVisitor` for nested goals

As always, dealing with proof trees continues to be a hacked together mess. After this PR and rust-lang#124380 the only remaining blocker for core is rust-lang/trait-system-refactor-initiative#90. There is also a `ProofTreeVisitor` issue causing an ICE when compiling `alloc` which I will handle in a separate PR. This issue likely affects coherence diagnostics more generally.

The core idea is to extend the proof tree visitor to support visiting nested candidates without using a `probe`. We then simply recurse into nested candidates if they are the only potentially applicable candidate for a given goal and check whether the self type matches the expected one.

For that to work, we need to improve `CanonicalState` to also handle unconstrained inference variables created inside of the trait solver. This is done by extending the `var_values` of `CanoncalState` with each fresh inference variables. Furthermore, we also store the state of all inference variables at the end of each probe. When recursing into `InspectCandidates` we then unify the values of all these states.

r? `@compiler-errors`
@bors
Copy link
Contributor

bors commented Apr 26, 2024

☀️ Try build successful - checks-actions
Build commit: 9dcd6e5 (9dcd6e521c16a2266f48f4b06d2d04f466f18ff6)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (9dcd6e5): comparison URL.

Overall result: ✅ improvements - no action needed

Benchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. While you can manually mark this PR as fit for rollup, we strongly recommend not doing so since this PR may lead to changes in compiler perf.

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

Instruction count

This is a highly reliable metric that was used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-1.0% [-1.8%, -0.3%] 2
All ❌✅ (primary) - - 0

Max RSS (memory usage)

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
1.8% [1.8%, 1.8%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-1.4% [-1.4%, -1.4%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.2% [-1.4%, 1.8%] 2

Cycles

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

Binary size

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

Bootstrap: 671.645s -> 672.204s (0.08%)
Artifact size: 315.99 MiB -> 315.88 MiB (-0.03%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Apr 26, 2024
@compiler-errors
Copy link
Member

@bors r+

@bors
Copy link
Contributor

bors commented Apr 26, 2024

📌 Commit 146f637 has been approved by compiler-errors

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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Apr 26, 2024
@bors
Copy link
Contributor

bors commented Apr 26, 2024

⌛ Testing commit 146f637 with merge 1b3a329...

@bors
Copy link
Contributor

bors commented Apr 26, 2024

☀️ Test successful - checks-actions
Approved by: compiler-errors
Pushing 1b3a329 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Apr 26, 2024
@bors bors merged commit 1b3a329 into rust-lang:master Apr 26, 2024
11 checks passed
@rustbot rustbot added this to the 1.79.0 milestone Apr 26, 2024
@lcnr lcnr deleted the analyze-obligations-for-infer branch April 26, 2024 17:41
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (1b3a329): comparison URL.

Overall result: ✅ improvements - no action needed

@rustbot label: -perf-regression

Instruction count

This is a highly reliable metric that was used to determine the overall result at the top of this comment.

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

Max RSS (memory usage)

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

Cycles

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-1.0% [-1.2%, -0.8%] 2
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -1.0% [-1.2%, -0.8%] 2

Binary size

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

Bootstrap: 671.528s -> 671.828s (0.04%)
Artifact size: 316.01 MiB -> 315.91 MiB (-0.03%)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-meta Area: Issues & PRs about the rust-lang/rust repository itself A-testsuite Area: The testsuite used to check the correctness of rustc merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) 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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants