Hello everyone,
I am currently working on a Rust verifier and am trying to insert runtime checks for specifications into the MIR. For one particular feature of this verifier (called pledges), I have the goal of inserting checks for certain conditions once a specific borrow expires.
We are using the rust compiler interface, and for verification we can identify the locations in mir_promoted
where borrows expire and do static analysis, however to check these conditions at runtime I ran into some problems.
In particular, to insert these runtime checks I need to override one of the compiler queries such that modifications reach the generated executable, but all the available options I see are problematic.
- I can not modify mir_promoted since modifications rely on the results of the borrow checker, which requires mir_promoted to be constructed already.
- I can modify
mir_drops_elaborated_and_const_checked
, however the locations of expiring borrows identified inmir_promoted
are no longer accurate.
Are there any solutions to these problems that do not require forking the rust compiler?
- for example, if I could invalidate the
mir_promoted
query at some point after our analysis and cause it to return a modified version that would certainly be a solution but so far I didn't find a way to achieve this - Is there maybe some other way of tracking the locations of statements between
mir_promoted
andmir_drops_elaborated_and_const_checked
? Looking at the mir passes that are performed between those two representations I think this is probably not feasible, or only heuristically, but maybe I am missing something?
I would appreciate any insights on this problem enormously!