-
Notifications
You must be signed in to change notification settings - Fork 115
Implement lifetime-checking by forking rustc_mir_build #1792
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
Conversation
98fb249
to
2f9e205
Compare
770396a
to
c269862
Compare
17915c7
to
c90aec5
Compare
c269862
to
7a0d096
Compare
c11e8d6
to
c02af9f
Compare
@Chris-Hawblitzel do you think you could help me figure out what's going on with the |
4a2b9fc
to
b749672
Compare
7a0d096
to
1108ad1
Compare
There are two minor failing tests:
The first one fails because it relies on The second fails, I think, because the use of an opaque type causes rustc_mir_build to run early, before we get a chance to do mode-checking. I'm not sure what to do about this one, either. It's not a huge deal now, since we don't support opaque types, but there's work-in-progress to support it so we should have a plan. In addition to this, there's the issue with trait spec extensions. Right now, I got these passing through a hack that should be fixed. Basically, the problem is that we create ResolvedCall info during the rust_to_vir pass, but then later (in traits.rs) we do a bunch of renaming. Thus the name in the ResolvedCall is not the same as the name we use in VIR. My current solution isn't very robust (see the FIXME in erase.rs). |
265cca3
to
4cdb259
Compare
1108ad1
to
11fb27c
Compare
This is ready for review as there are only minor outstanding issues.
|
By the way, the issue I mentioned last week — about having to find-and-replace a bunch of identifiers throughout the fork — I was able to workaround it so we no longer have to do that. That should simplify the forking process a lot. |
26bb1fd
to
4ff55ac
Compare
I added a script to apply rustc changes. I tried to do it with subtrees. However, this turned out to be really annoying because we aren't forking the entire rustc repository, just a single directory and a few isolated files. And the rustc repository is massive with a massive history, so doing 'subtree-split' took hours. Instead, I added a handrolled script that basically does the same thing as subtree, but it's really quick, it just makes 2 commits with all the relevant files, diffs 'em, and imports it as a commit into your local repository. Then you can cherry-pick it and resolve any conflicts. I also included instructions in our It's kind of jank, but it's easy to use and I think it should do the job. |
@dschoepe let me know if you have any comments on the fork-updating process |
f462ff0
to
7f537ce
Compare
I'll try out the instructions for the upgrade to 1.89, hopefully next week. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As long as the tests pass and everyone is ok with the rust version upgrade process, this looks good to me.
Co-authored-by: Chris Hawblitzel (Microsoft) <[email protected]> - fixes #834 - fixes #835 - fixes #959 - fixes #1296
d553a45
to
d64aee5
Compare
Co-authored-by: Chris Hawblitzel <[email protected]> - fixes #834 - fixes #835 - fixes #959 - fixes #1296
d64aee5
to
7d7927b
Compare
- fixes #834 - fixes #835 - fixes #959 - fixes #1296 Co-authored-by: Chris Hawblitzel <[email protected]>
7d7927b
to
446be12
Compare
Sorry for not getting back to you here. I tried the instructions and everything works, though I haven't finished the 1.89 upgrade yet. |
This pull request will OBSOLETE lifetime_generate.
This PR contains a fork of the
rustc_mir_build
crate, which contains the lowering HIR -> THIR. We modify the lowering to remove all spec code, leaving only exec+proof code.It currently passes most tests in
rust_verify_test/tests/lifetime.rs
.Benefits:
Snags:
For the most part, erasing calls and variables is pretty easy. There is one exception: closure captures. Consider something like:
Rustc infers that
x
will be captured, but since the assert is erased, onlyx.a
is captured. Computing the correct capture-set is more involved than the other erasure-related activities, and may require forking some additional code. I've been experimenting with a strategy that seems to work, but it needs to be documented and made robust.Implementation notes:
After running our
modes.rs
pass, Verus creates an object calledVerusErasureCtxt
which contains information about which HIR nodes need to be erased. We then make this information available to therustc_mir_build
fork.We modify
rustc_mir_build/src/thir/cx/expr.rs
to check this context object to decide when to erase stuff. I attempted to make the changes torustc_mir_build/src/thir/cx/expr.rs
as minimal as possible. Almost all nontrivial logic is delegated to therustc_mir_build_additional_files/verus.rs
Most important files:
source/rustc_mir_build_additional_files/verus.rs
source/rustc_mir_build/src/thir/cx/expr.rs
source/rust_verify/src/erase.rs
The
upvar.rs
andexpr_use_visitor.rs
files are also forks of rustc files, related to closure captures.To make this easier to review, I have made the base of the PR a commit that already contains the
rustc_mir_build
crate as-is from rustc 1.88.0. Therefore, the PR's diff should only show the Verus-relevant changes.TODO:
lifetime
tests passing