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

Make a minimal amount of region APIs public #124893

Merged
merged 1 commit into from
May 9, 2024

Conversation

xldenis
Copy link
Contributor

@xldenis xldenis commented May 8, 2024

Tools like Creusot, Prusti or Gillian-Rust need to access information about the loans and regions that exist in MIR programs. While rustc provides information about loans, there is currently no public way to reason about the regions present in a MIR program. In particular, we to know which regions are actually equal to each other and which ones outlive each other. Currently, rustc provides access to RegionInferenceContext but the public api hides that last portion of the information.

This PR proposes to make a few apis public, allowing verifiers to reason about the lifetimes present in Rust programs:

The first two functions would allow us to compare regions and from this we can construct the set of RegionVid which are actually equal to each other, and then recover the inclusions between those regions, while the second allows for more direct, but low level access to that information.

@rustbot
Copy link
Collaborator

rustbot commented May 8, 2024

r? @lcnr

rustbot has assigned @lcnr.
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

@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 May 8, 2024
@compiler-errors
Copy link
Member

Please leave a brief comment on each of these functions, since if they're public API it would be nice if they're documented. And also leave a regular (internal) comment like // public so that downstream tools can use these functions

@xldenis
Copy link
Contributor Author

xldenis commented May 8, 2024

I've promoted the existing comments to doc comments and added internal comments documenting why the apis are public.

@lcnr
Copy link
Contributor

lcnr commented May 9, 2024

@bors r+ rollup

@bors
Copy link
Contributor

bors commented May 9, 2024

📌 Commit d4c6c77 has been approved by lcnr

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-review Status: Awaiting review from the assignee but also interested parties. labels May 9, 2024
bors added a commit to rust-lang-ci/rust that referenced this pull request May 9, 2024
…iaskrgr

Rollup of 5 pull requests

Successful merges:

 - rust-lang#124893 (Make a minimal amount of region APIs public)
 - rust-lang#124919 (Add `ErrorGuaranteed` to `Recovered::Yes` and use it more.)
 - rust-lang#124923 (interpret/miri: better errors on failing offset_from)
 - rust-lang#124924 (chore: remove repetitive words)
 - rust-lang#124926 (Make `#![feature]` suggestion MaybeIncorrect)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit ebeedf0 into rust-lang:master May 9, 2024
6 checks passed
@rustbot rustbot added this to the 1.80.0 milestone May 9, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request May 9, 2024
Rollup merge of rust-lang#124893 - xldenis:public-region-apis, r=lcnr

Make a minimal amount of region APIs public

Tools like Creusot, Prusti or Gillian-Rust need to access information about the loans and regions that exist in MIR programs. While `rustc` provides information about loans, there is currently no public way to reason about the regions present in a MIR program. In particular, we to know which regions are actually equal to each other and which ones outlive each other. Currently, `rustc` provides access to `RegionInferenceContext` but the public api hides that last portion of the information.

This PR proposes to make a few apis public, allowing verifiers to reason about the lifetimes present in Rust programs:
- [eval_equal](https://doc.rust-lang.org/beta/nightly-rustc/rustc_borrowck/region_infer/struct.RegionInferenceContext.html#method.eval_equal)
- [eval_outlives](https://doc.rust-lang.org/beta/nightly-rustc/rustc_borrowck/region_infer/struct.RegionInferenceContext.html#method.eval_outlives)
- (Optional) [constraint_sccs](https://doc.rust-lang.org/beta/nightly-rustc/rustc_borrowck/region_infer/struct.RegionInferenceContext.html#method.constraint_sccs)

The first two functions would allow us to compare regions and from this we can construct the set of `RegionVid` which are actually equal to each other, and then recover the inclusions between those regions, while the second allows for more direct, but _low level_ access to that information.
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants