Compute type fragments left over from moves#17439
Closed
pnkfelix wants to merge 12 commits intorust-lang:masterfrom
Closed
Compute type fragments left over from moves#17439pnkfelix wants to merge 12 commits intorust-lang:masterfrom
pnkfelix wants to merge 12 commits intorust-lang:masterfrom
Conversation
…varId`. (This refactoring looks like a wash in this commit, in terms of overall code-cleanliness; but it makes things nicer in a future commit for static drop semantics.)
…ef and by-value captures. This is necessary to be able to properly backtrack in a loan-path to the definition site of the original variable (which I found necessary in later commits).
`LpDowncast` carries the `DefId` of the variant itself. To support this, added the enum variant `DefId` to the `cat_downcast` variant in `mem_categorization::categorization`.
To make this clean, refactored old `LoanPath` enum into a `LoanPath` struct with a `ty::t` and a newly-added `LoanPathVariant` enum. This enabled me to get rid of the ugly and fragile `LoanPath::to_type` method, and I can probably also get rid of other stuff that was supporting it, maybe.
This is accomplished by: 1. Add `MatchMode` enum to `expr_use_visitor`. 2. Computing the match mode for each pattern via a pre-pass, and then passing the mode along when visiting the pattern in expr_use_visitor. 3. Adding a `fn matched_pat` callback to expr_use_visitor, which is called on all nodes of the pattern (as opposed to `fn consume_pat`, which is only invoked for identifiers at the leaves of the pattern), and invoking it accordingly. Of particular interest are the `cat_downcast` instances established when matching enum variants.
Note that due to PR rust-lang#16053, we only actually deal with `a @ Var(_)` here, (as opposed to a hypothetical `a @ Var(ref b)`, which cannot currenty arise, and maybe will never be supported for non-copy data).
… a span. This will be utilized by the rustc_drop_obligations code-annotation-via-errors hack to print out the drop obligations that are removed at the end of scopes.
When you add `rustc_drop_obligations` as an annotation on a function, it will print all of the drop-obligation manipulations as individual compiler errors associated with the expressions that caused the effect on the drop obligation state. Surround drop-obligations in output with `` quotes to help unintended prefix matches Prints scope-end messages at end of their scope.
Contributor
Author
Contributor
Author
|
r? @nick29581 |
Member
There was a problem hiding this comment.
Could you add a comment here - not obvious what this fn does from the name
Member
|
I started to review this, but it quickly because apparent that I don't know the borrow checker well enough to do it justice, so going to hand off the review, sorry. r? @nikomatsakis or @pcwalton |
Contributor
There was a problem hiding this comment.
can you clarify whether BOTH matched_pat and consume_pat are called on leaves, or just one of them?
Contributor
Author
|
(temporarily closing pull request; I'm going to cut it down a little to remove more of the dataflow artifacts that can be left for a later PR.) |
lnicola
pushed a commit
to lnicola/rust
that referenced
this pull request
Jun 23, 2024
…ykril Properly prime all crate def maps in parallel_prime_caches
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Compute type fragments left over from moves.
This is part 1 of a pair of PRs that prepare for planned revisions to our drop implementation; this foundation is required for either "static drop semantics" (RFC PR 210) or for the improved dynamic drop semantics that uses an out-of-band bitfield on the stack to track which loan-paths still need to be dropped.
This PR deliberately leaves out the control-flow analysis changes that are actually necessary for the drop changes, which are in part 2. This is more fundamental stuff here.
(The commits are deliberately split up in an effort to ease reading these revisions; I do not plan to squash them.)