Skip to content

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
stellanomia:borrowck-facts-api
Open

Add mir_borrowck_with_facts to retrieve borrow-checking results and Polonius facts in a single pass#152175
stellanomia wants to merge 1 commit intorust-lang:mainfrom
stellanomia:borrowck-facts-api

Conversation

@stellanomia
Copy link

This PR introduces a new API mir_borrowck_with_facts to rustc_borrowck::consumers. This allows compiler consumers to extract both the standard mir_borrowck query 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_borrowck result and Polonius facts. Using get_bodies_with_borrowck_facts discards the borrow check result, and the standard query is not capable of retrieving Polonius facts.

Furthermore, consumers cannot reimplement mir_borrowck locally to capture facts because BorrowCheckRootCtxt is 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_facts to let consumers get both in a single pass. This is particularly useful for tools that override the mir_borrowck query to perform analysis but still need to continue the compilation.

I also updated tests/ui-fulldeps/obtain-borrowck.rs to use the new API. This avoids the need to manually instantiate a default provider just to call the original mir_borrowck a second time.

Changes:

  • Add BorrowckResultWithFacts to bundle results.
  • Add mir_borrowck_with_facts to the consumers module.
  • Update obtain-borrowck.rs test to use the new API.

@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. labels Feb 5, 2026
@rustbot
Copy link
Collaborator

rustbot commented Feb 5, 2026

r? @davidtwco

rustbot has assigned @davidtwco.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@davidtwco
Copy link
Member

r? @lqd

@rustbot rustbot assigned lqd and unassigned davidtwco Feb 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants