Add mir_borrowck_with_facts to retrieve borrow-checking results and Polonius facts in a single pass#152175
Open
stellanomia wants to merge 1 commit intorust-lang:mainfrom
Open
Add mir_borrowck_with_facts to retrieve borrow-checking results and Polonius facts in a single pass#152175stellanomia wants to merge 1 commit intorust-lang:mainfrom
mir_borrowck_with_facts to retrieve borrow-checking results and Polonius facts in a single pass#152175stellanomia wants to merge 1 commit intorust-lang:mainfrom
Conversation
Collaborator
|
r? @davidtwco rustbot has assigned @davidtwco. Use |
Member
|
r? @lqd |
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.
This PR introduces a new API
mir_borrowck_with_factstorustc_borrowck::consumers. This allows compiler consumers to extract both the standardmir_borrowckquery results and Polonius facts in a single borrow-checking pass.Currently, external consumers (like custom drivers or analyzers) have no efficient way to retrieve both the standard
mir_borrowckresult and Polonius facts. Usingget_bodies_with_borrowck_factsdiscards the borrow check result, and the standard query is not capable of retrieving Polonius facts.Furthermore, consumers cannot reimplement
mir_borrowcklocally to capture facts becauseBorrowCheckRootCtxtis private. While this encapsulation of unstable borrow-checker internals makes sense, it currently forces a redundant second pass when a tool needs both facts and query results to continue the compilation.This PR adds
mir_borrowck_with_factsto let consumers get both in a single pass. This is particularly useful for tools that override themir_borrowckquery to perform analysis but still need to continue the compilation.I also updated
tests/ui-fulldeps/obtain-borrowck.rsto use the new API. This avoids the need to manually instantiate a default provider just to call the originalmir_borrowcka second time.Changes:
BorrowckResultWithFactsto bundle results.mir_borrowck_with_factsto theconsumersmodule.obtain-borrowck.rstest to use the new API.