-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Remove ResultsVisitable
#132134
Merged
Merged
Remove ResultsVisitable
#132134
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
labels
Oct 25, 2024
☔ The latest upstream changes (presumably #132349) made this pull request unmergeable. Please resolve the merge conflicts. |
nnethercote
force-pushed
the
rm-ResultsVisitable
branch
2 times, most recently
from
October 31, 2024 09:31
b6f5887
to
ad84311
Compare
Some changes occurred to MIR optimizations cc @rust-lang/wg-mir-opt |
☔ The latest upstream changes (presumably #132250) made this pull request unmergeable. Please resolve the merge conflicts. |
The results of most analyses end up in a `Results<'tcx, A>`, where `A` is the analysis. It's then possible to traverse the results via a `ResultsVisitor`, which relies on the `ResultsVisitable` trait. (That trait ends up using the same `apply_*` methods that were used when computing the analysis, albeit indirectly.) This pattern of "compute analysis results, then visit them" is common. But there is one exception. For borrow checking we compute three separate analyses (`Borrows`, `MaybeUninitializedPlaces`, and `EverInitializedPlaces`), combine them into a single `BorrowckResults`, and then do a single visit of that `BorrowckResults` with `MirBorrowckResults`. `BorrowckResults` is just different enough from `Results` that it requires the existence of `ResultsVisitable`, which abstracts over the traversal differences between `Results` and `BorrowckResults`. This commit changes things by introducing `Borrowck` and bundling the three borrowck analysis results into a standard `Results<Borrowck>` instead of the exceptional `BorrowckResults`. Once that's done, the results can be visited like any other analysis results. `BorrowckResults` is removed, as is `impl ResultsVisitable for BorrowckResults`. (It's instructive to see how similar the added `impl Analysis for Borrowck` is to the removed `impl ResultsVisitable for BorrowckResults`. They're both doing exactly the same things.) Overall this increases the number of lines of code and might not seem like a win. But it enables the removal of `ResultsVisitable` in the next commit, which results in many simplifications.
Now that `Results` is the only impl of `ResultsVisitable`, the trait can be removed. This simplifies things by removining unnecessary layers of indirection and abstraction. - `ResultsVisitor` is simpler. - Its type parameter changes from `R` (an analysis result) to the simpler `A` (an analysis). - It no longer needs the `Domain` associated type, because it can use `A::Domain`. - Occurrences of `R` become `Results<'tcx, A>`, because there is now only one kind of analysis results. - `save_as_intervals` also changes type parameter from `R` to `A`. - The `results.reconstruct_*` method calls are replaced with `results.analysis.apply_*` method calls, which are equivalent. - `Direction::visit_results_in_block` is simpler, with a single generic param (`A`) instead of two (`D` and `R`/`F`, with a bound connecting them). Likewise for `visit_results`. - The `ResultsVisitor` impls for `MirBorrowCtxt` and `StorageConflictVisitor` are now specific about the type of the analysis results they work with. They both used to have a type param `R` but they weren't genuinely generic. In both cases there was only a single results type that made sense to instantiate them with.
nnethercote
force-pushed
the
rm-ResultsVisitable
branch
from
November 4, 2024 23:29
ad84311
to
c904c6a
Compare
I rebased. |
@cjgillot: two week review ping! |
@bors r+ |
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
Nov 16, 2024
bors
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Nov 16, 2024
…iaskrgr Rollup of 7 pull requests Successful merges: - rust-lang#131717 (Stabilize `const_atomic_from_ptr`) - rust-lang#132134 (Remove `ResultsVisitable`) - rust-lang#132449 (mark is_val_statically_known intrinsic as stably const-callable) - rust-lang#132569 (rustdoc search: allow queries to end in an empty path segment) - rust-lang#132787 (Unify FnKind between AST visitors and make WalkItemKind more straight forward) - rust-lang#132832 (Deny capturing late-bound ty/const params in nested opaques) - rust-lang#133097 (Opt out TaKO8Ki from review rotation for now) r? `@ghost` `@rustbot` modify labels: rollup
bors
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Nov 17, 2024
…iaskrgr Rollup of 7 pull requests Successful merges: - rust-lang#131717 (Stabilize `const_atomic_from_ptr`) - rust-lang#132134 (Remove `ResultsVisitable`) - rust-lang#132449 (mark is_val_statically_known intrinsic as stably const-callable) - rust-lang#132569 (rustdoc search: allow queries to end in an empty path segment) - rust-lang#132787 (Unify FnKind between AST visitors and make WalkItemKind more straight forward) - rust-lang#132832 (Deny capturing late-bound ty/const params in nested opaques) - rust-lang#133097 (Opt out TaKO8Ki from review rotation for now) r? `@ghost` `@rustbot` modify labels: rollup
rust-timer
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Nov 17, 2024
Rollup merge of rust-lang#132134 - nnethercote:rm-ResultsVisitable, r=cjgillot Remove `ResultsVisitable` `ResultsVisitable` has annoyed me for a while. This PR removes it. Details in the individual commits. r? `@cjgillot.`
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
ResultsVisitable
has annoyed me for a while. This PR removes it. Details in the individual commits.r? @cjgillot.