Manuscript Offprint
arXiv:2611.06319Verified Implementation of the Next-gen Borrow Checking Algorithm for Rust via Abstract Interpretation
JINHUA WU, Shanghai Jiao Tong University, China
YUTING WANG*, Shanghai Jiao Tong University, China
ZHEMIN CHEN, Nanjing University, China
Borrow checking is a central mechanism for Rust to ensure temporal memory safety. Its correctness is based on the intuition that the Aliasing XOR Mutability discipline guarantees that programs without borrow errors inherently could not access invalid references (i.e., pointers). However, existing work on formalizing borrow checking treats it either as a component of type systems or as symbolic execution describing resource transfer. None provides a direct explanation of the correctness of borrow checking algorithms such as Non-Lexical Lifetimes (NLL) or Polonius in the official Rust compiler that function more like static pointer analysis.
We take a first step toward solving this problem by formalizing Polonius, the next-generation borrow-checking algorithm for the Rust compiler, on a core subset of Rust. We prove its correctness by showing that any program accepted by Polonius does not access invalid references at runtime. The key observation is that, when borrow checking is performed lazily, Polonius could be treated as a forward abstract interpretation on abstract domains recording pointer aliasing (borrowing) relations. By providing a concrete semantics that formally describes the Aliasing XOR Mutability discipline, we prove the soundness of this abstract interpretation, from which we derive memory safety of checked programs. This formulation of Polonius is implemented and formally verified in the abstract interpretation framework of CompCert. The correctness proofs are generated by an agentic AI under human guidance using paper proofs as proof outline. To the best of our knowledge, this is the first comprehensive formalization and verification of a borrow checking algorithm as manifested in the Rust compiler.
1 Introduction
Memory safety problems caused by accessing invalid pointers or references are the most common vulnerabilities in software [45, 48]. To mitigate those problems, memory safe languages are increasingly favored over unsafe ones (e.g., C/C++). Among them the most prominent is Rust [47]. Rust employs a strong type system and ownership semantics to ensure both temporal (e.g., no dereference of dangling pointers) and spatial memory safety (e.g., no out-of-bounds access). For the former, the central idea is to enforce the so-called Aliasing XOR Mutability discipline (i.e., there can be either only one mutable reference or multiple shared references to a value at any execution point) to rule out potentially unsafe uses of references. We shall abbreviate this discipline as AXM.
Borrow checking is the static analysis for Rust to ensure memory safety by enforcing AXM. Consider the following Rust code snippet which manipulates heap memory owned by Box structures:
1 let mut v = Box::new(1);
2 let mut r = &mut *v;
3 v = Box::new(2); // error: cannot assign to v because it is borrowed
4 println!("{}", *r); // borrow later used here
If the code is compiled and executed without any safety checking, a use-after-free error occurs at line 4 because the heap memory originally bound to v has been deallocated after line 3, making r a dangling reference. The Rust compiler rejects this program as its borrow checker detects a violation of AXM at line 3: *v is mutably borrowed by r until line 4 and therefore its prefixes (i.e., v and *v)
*Corresponding author
Authors' Contact Information: Jinhua Wu, John Hopcroft Center for Computer Science, School of Electronic Information and Electrical Engineering, Shanghai Jiao Tong University, China, jinhua.wu@sjtu.edu.cn; Yuting Wang, John Hopcroft Center for Computer Science, School of Electronic Information and Electrical Engineering, Shanghai Jiao Tong University, China, yuting.wang@sjtu.edu.cn; Zhemin Chen, Software Institute, Nanjing University, China, zheminchen@gmail.nju.edu.cn>.
Jinhua Wu, Yuting Wang, and Zhemin Chen
2
1 let mut v = Box::new(1); // NLL | Polonius
2 let mut x: &'x mut i32 = &mut *v; // *v live | 'x:{*v}
3 let mut y: &'y mut i32 = &mut *x; // *v,*x live | 'x:{*v}, 'y:{*v,*x}
4 *x = 2; // Error: cannot access *x because it is borrowed
5 *y = 3; // borrow later used here
Fig. 1. An example to illustrate NLL and Polonius
could not be mutated before line 4. In summary, borrow checking statically examines the possible violations of AXM, thereby preventing any potential access to invalid references at runtime.
In the official compiler of Rust, i.e., rustc, borrow checking is implemented as an algorithm that solves memory safety constraints and checks if the solution violates AXM [25, 44]. To deal with complicated programming language features in Rust such as storing references in data structures, reborrowing of existing references, passing and returning references for function calls, etc., borrow checking algorithms are highly sophisticated and continuously evolving. Two versions of borrow checkers are currently implemented in rustc: Non-Lexical Lifetimes (NLL) [44] and Polonius [25, 41]. The former has been the default borrow checker for a long time and the latter is an experimental one that employs a more accurate borrow analysis and will replace NLL in the near future.
In both NLL and Polonius, the key to ensuring that only valid references are accessed lies in analyzing which places (Rust's terminology for memory locations holding values, similar to *l-values in C/C++) may be borrowed at each program point, based on which violation of AXM is then detected. This is made possible by annotating types of references with generic variables called regions. Consider the example in Fig. 1 where 'x and 'y are regions in the types of references x and y, respectively. In NLL, a region is interpreted as lifetime, i.e., a span of code over which a reference and its borrowed places remain alive (i.e., they will be used later). For instance, the lifetime denoted by 'x spans over lines 2-4. At line 3, a reborrow of *v by y happens through dereferencing x. The lifetime of 'y spans over lines 3-5, making its borrowed place *x alive up to line 5. Because *x is still mutably borrowed at line 4, it cannot be assigned, resulting in a borrow checking error. By contrast, Polonius interprets a region r as an abstract pointer variable that stores a set s of borrowed places, which we shall write as r : s. At any point of execution, this set (over-)approximates all the possible places the reference variable could borrow. For example, at line 2, 'x : {*v} indicates that x may borrow *v as 'x is the abstract pointer representing x. At line 3, the places borrowed by y are additionally recorded in 'y : {*v, *x}. Using this borrowing information, Polonius checks if, at any point of execution, the instruction being executed violates AXM w.r.t. borrowed places contained in live regions. For example, because y (hence its region 'y) is alive up to line 5 and it borrows *x, assignment to *x at line 4 violates AXM. As we can see, Polonius captures the borrow relations for individual references at all points of execution, and is therefore more accurate than NLL which only records live places as a whole. This enables Polonius to accept a wider range of safe programs, a main reason that it is chosen as the next-gen borrow checking algorithm for rustc.¹
Considering the central role borrow checking algorithms play in the Rust compiler, it is highly desirable to formally verify their correctness. However, despite the impressive efforts the PL community puts into researching Rust, there is not yet successful attempt along this line. Instead, existing work formalizes borrow checking either as an ownership type system for Rust (e.g., RustBelt [14], Oxide [50], Pearce [31]), or as symbolic execution with resource transfers (e.g., Aeneas [10]), which deviates from the region-based static analysis adopted by NLL or Polonius. Verifying the correctness of borrow checking algorithms in the Rust compiler is still an open problem.
¹Fig. 1 also illustrates the conservative nature of borrow checkers. Although line 4 does not actually cause a memory error, the program is still rejected by rustc. Inaccuracy is the price we pay for the ability to statically check memory safety.
Verified Implementation of the Next-gen Borrow Checking Algorithm for Rust via Abstract Interpretation
3
In this paper, we investigate a solution to this open problem by developing a verified implementation of Polonius. Before delving into the solution, we first explain why the problem is difficult.
Challenge 1: Formalization of Borrow Checking Algorithms Amenable to Verification. To formally prove borrow checkers correct, we must first give them a formal description in theorem provers. However, this is difficult because of the ad-hoc and complex implementation of borrow checkers. In rustc, NLL and Polonius employ sophisticated constraint generation and solving techniques [25, 44, 46] which are entangled with other kinds of safety checking such as type checking, liveness checking, and module-level analysis. Although there is documentation like RFCs, blog posts, and even a rule-based formulation in Datalog (at least partially for Polonius [36]), it is not clear at all if there exists a formulation of NLL or Polonius amenable to verification.
Challenge 2: Semantics Suitable for Verifying Borrow Checking Algorithms. Borrow checkers work on MIR, an intermediate language represented as control-flow graphs (CFG). For verification, we need to give this IR a formal semantics that faithfully describes when memory errors occur at runtime, so that we can prove their absence under successful borrow checking. More importantly, we need to connect this low-level semantics with a more higher-level semantics that captures the essence of borrow checkers. For Polonius, this essence is its alias analysis nature. For example, the relation between borrowed places 'y : {*v, *x} in Fig. 1 actually implies that *v, *x and *y are aliases of each other. It is exactly by analyzing this alias information that Polonius is able to enforce AXM, hence to guarantee memory safety.
Challenge 3: Proving the Correctness of Borrow Checking Algorithms. Intuitively, borrow checkers in rustc are correct, i.e., if they could not detect any borrow error, then the program does not contain any uses of invalid references. However, to formally prove this intuition is a significant challenge. First and foremost, the actual form of AXM is more complicated because of pointer assignments, which is another term for reborrowing. For example, the reborrowing at line 3 in Fig. 1 is actually desugared from the following pointer assignment by rustc [42]:
1 let mut y: &'y mut i32 = x;
In real-world software, pointer assignments (hence reborrowing) are ubiquitous. They create multiple mutable references to values, which easily breaks AXM. Therefore, Rust actually allows multiple mutable references to coexist provided that their uses are well-nested like a stack. For example, if we switch lines 4 and 5 in Fig. 1, then the modified program passes borrow checking because x and y are used in a first-defined-last-used fashion. As a result, the more complex stacked AXM discipline, i.e., that only well-nested memory accesses according to the stack ordering are allowed, must be taken into account when proving correctness.
Second, pointer manipulations in real-world code further complicate the proof. For example, the assignment between nested references (i.e., pointers to pointers) causes aliases of locations to merge; reference arguments in functions and struct fields could be annotated with generic regions called lifetime parameters which extend the lifetime of references indefinitely. It is unclear how accesses to references could be proven safe in presence of these complications.
Finally, our ultimate goal is to derive memory safety from borrow checking. Although there is the folklore that AXM implies absence of accessing invalid references, it is not clear what exactly is a formal definition of this implication relation. Even if we know this formal definition, proving it holds for stacked AXM under complicated pointer manipulation is still a huge undertaking.
Jinhua Wu, Yuting Wang, and Zhemin Chen
of dataflow of pointer aliases when detection of borrow errors is done lazily. We adopt the traditional fixed-point solver (i.e., Kildall's algorithm) to implement this abstract interpretation as a formal algorithm in Rocq and prove its soundness with respect to a concrete semantics we call borrow-aware semantics. By further proving that, when there is no borrow checking error, borrow-aware semantics enforces stacked AXM discipline, we derive memory safety for checked programs.
To the best of our knowledge, this is the first time a borrow checking algorithm in the Rust compiler is formally implemented and verified. We summarize our contributions as follows.
-
Polonius as Abstract Interpretation. We begin with an understanding of the official Polonius as derivation rules that capture its constraint generation and solving mechanisms. We observe that, when borrow errors are detected lazily instead of eagerly, these rules function like a forward propagation of aliasing information for pointers. Based on this observation, for a core subset of MIR, we develop an abstract semantics for interpreting Polonius as a variant of pointer analysis [1, 8]. We propose a novel abstract domain to track aliasing information in presence of complex pointer manipulation like reborrowing. This formulation of Polonius as abstract interpretation is implemented as a formal algorithm and is naturally amenable to verification.
-
Borrow-Aware Semantics Capturing AXM and Memory Safety. We propose borrow-aware semantics for our Rust subset, which serves as the concrete semantics for our abstract interpretation. It turns the abstract domain and interpretation into dynamic counterparts that record precise aliasing (borrowing) information. We prove that borrow-aware semantics imposes a stack-like ordering among aliased places. The stacked AXM discipline is then formally defined as the absence of out-of-order memory accesses according to this stack ordering. We further show that if stacked AXM is respected, then invalid reference access could not happen, thereby providing a foundation for proving Polonius correct.
-
Correctness Proof for Polonius. We establish the soundness of abstract interpretation with respect to borrow-aware semantics. This soundness proof is based on a novel observation that the type-based pointer analysis used by Polonius can be concretized as precise aliasing information over a well-typed memory structure. This correspondence also supports modular analysis for function calls. By the soundness of abstract interpretation, we prove that any program admitted by Polonius respects stacked AXM in borrow-aware semantics, and is therefore memory safe.
-
Rocq Formalization. Using CompCert's abstract interpretation framework [4, 22], we formalize Polonius as an instance of Kildall's algorithm. We test this implementation extensively to evaluate its agreement with the official Polonius. We have also formalized the borrow-aware semantics and correctness proof which is generated by LLM based on around 100 pages of paper proofs. The complete Rocq formalization is found in the supplementary materials.
1.2 Scope of the Paper
Borrow checking is not the only compiler pass responsible for memory safety. Type checking ensures that values in memory are well-typed, so that references could not be invalidated by destructive type casting. Initialization analysis ensures no access to uninitialized variables. Furthermore, move checking prohibits access to moved in-memory values. For example, the following code is rejected:
1 let mut v = Box::new(1);
2 let mut w = v; // v no longer owns value
3 println!("{}", *v); // error: accessing moved memory
We assume that the above checks have already been performed. Borrow checking is only responsible for ensuring that memory errors could not happen because of accessing an invalid reference p. Since we assume only well-typed and initialized values are referenced, such an error could happen only if p is a dangling pointer to deallocated memory. Although this problem seems straightforward,
Verified Implementation of the Next-gen Borrow Checking Algorithm for Rust via Abstract Interpretation
solving it is highly non-trivial. Finally, we focus on safe Rust. Our work formalized AXM as an invariant which could also work with unsafe Rust; this is left for future work.
2 Overview

Fig. 2. Overview of our formalization and verification of Polonius
The workflow of this project is depicted in Fig. 2. We give a high-level introduction to its components in this section and defer their in-depth discussions to the remaining sections.
Rule-based Polonius. This project begins with an investigation of the design and implementation of NLL and Polonius, including the NLL RFC [44], the Datalog rules of Polonius [36, 43], and the implementation of Polonius in rustc [39]. Both NLL and Polonius consist of three steps: generation of borrow constraints, solving of these constraints and detection of borrow errors. Our first contribution is to reformulate the above algorithmic procedures for Polonius into a rule-based system. That is, the constraint generation, solving and borrow checking are all described as a set of derivation rules, thereby eliminating the ad-hocness of the current implementation of Polonius and making it more amenable to formalization. We shall discuss those in §3.
Abstract Interpreter for Polonius. Polonius relies on both forward and backward data-flow analysis, where the former propagates borrow constraints and the latter computes liveness information. This mixed interaction makes it difficult to formalize the derivation rules of Polonius in a theorem prover. By replacing the eager borrow checking with lazy checking rules, we obtain a rule-based Polonius without liveness analysis and with only forward data flows. Then, we formalize Polonius as an abstract interpreter in the form of a dataflow-based pointer analysis. Viewing it as a pointer analysis suggests an abstract domain that maps abstract pointer variables (i.e., regions) to a set of places being borrowed by the pointer (reference). To deal with complex language features of Rust, we need to design highly nontrivial abstract domains and transfer functions (i.e., small-step transitions of Rust expressions and statements on abstract domains). We discuss those in §4.
Borrow-aware Semantics. To make static checking of adherence to AXM possible, Polonius tracks approximated information for abstract pointers. To prove memory safety for concrete execution, we need to accurately capture AXM in the concrete semantics which must track a precise set of borrowed places for concrete pointers. This results in our borrow-aware semantics. To avoid reasoning about low-level memory operations, borrow-aware semantics adopts a value-based memory model (similar to Low-Level Borrow Calculus, or LLBC [10]). Memory values must be well-typed and memory locations are denoted by named places rather than low-level entities such as blocks of bytes [23]. Ownership transfer in Rust is modeled by movement of values. With those features, borrow-aware semantics effectively performs borrow checking dynamically using precise aliasing information in the borrow sets attached to concrete references. We discuss those in §5.
Correctness of Polonius. We first prove that the abstract interpreter for Polonius is sound w.r.t. borrow-aware semantics by establishing a backward simulation between them, as depicted in Fig. 3
Jinhua Wu, Yuting Wang, and Zhemin Chen

(a) Internal simulation

(b) Simulation of function call and return

(c) Borrow-error simulation
The top row denotes transitions over abstract states and via the transfer function of the abstract interpreter for Polonius. The bottom row denotes transitions over concrete states and in the borrow-aware semantics. An invariant is maintained by internal steps throughout the entire execution. For a function call, the entire concrete execution from call to return must be simulated by a single transfer step at the abstract interpreter, since Polonius performs modular analysis. When the borrow-aware semantics detects a borrow error, so does the abstract interpreter.
Fig. 3. Backward simulation between abstract interpreter and borrow-aware semantics
(see §6.1). By this simulation, successful borrow checking (no borrow error detected by the abstract interpreter) implies no borrow error in the borrow-aware semantics. We then prove that the stacked AXM discipline is enforced if there is no borrow error in the borrow-aware semantics (see §6.2). Roughly speaking, the following borrow chain is maintained by the borrow-aware semantics:
if first borrows , then reborrows through , and so on. We prove that, if there is no borrow error, then Stacked AXM is respected, i.e., that the places on this chain must be accessed from left to right (reverse of the borrowing order). Finally, we prove that the stacked AXM implies memory safety for reference accesses (see §6.3). The proof relies critically on an adequacy property for borrow-aware semantics: for any two aliased places and , if a prefix of could possibly deallocate the memory location that they both reach, then must be present in the borrow chain. Because stacked AXM does not allow to be used before the last use of and only modification through could invalidate (deallocate) , it is impossible to access dangling references through . Therefore, every dereferencing operation is memory safe for borrow checked programs.
3 Language and Rule-based Polonius
3.1 A Core language for Intermediate Representation of Rust
Our borrow checker operates on a core subset of Rust's Mid-level Intermediate Representation (MIR) [34], defined in Fig. 4, which we call Core MIR. We retain features central to our analysis, including references, Box pointers, composite data types (structs and enums), and function calls, while excluding slices, type polymorphism, traits, closures, and unsafe features such as raw pointers.
A program consists of three kinds of top-level definitions: functions, structs, and enums. Each definition declares a list of region parameters , corresponding to lifetime parameters in the NLL terminology. Regions appearing in types of function parameters or types of struct and enum fields must come from these parameters. Function signatures also declare a list of region relations , whose role in borrow checking is explained later. Each function declares all its local variables and their types at the entry of the function. A special variable holds the return value, which is returned by the instruction return( ). The function body g is a control-flow graph (CFG), consisting of an entry node and a partial map from node labels (denoted by n) to instructions. We shall write succ(n) for the set of successor nodes of n. In rustc, a control-flow block is a sequence of statements followed by a terminator. We instead place a single instruction at each CFG node.
Verified Implementation of the Next-gen Borrow Checking Algorithm for Rust via Abstract Interpretation
7
| x, id, fid, n ∈ N | identifiers | i ∈ I ::= | instructions |
|---|---|---|---|
| ρ, r ∈ R ::= N | regions | goto(n) | unconditional jumps |
| q ::= | projections | (p := e, n) | assignments |
| [.] | base cases | (p := id_f(, n)) | function calls |
| *bq | Box dereferences | (drop(p), n) | resource deallocations |
| *r q | reference dereferences | cond(op, n_1, n_2) | conditional jumps |
| q.fid | field selections | return(x ret) | function returns |
| p ∈ P ::= q[x] | places | g ∈ G ::= {entry : N, | |
| ω ∈ Ω ::= mut | shr | mutability | body : N → I} | control-flow graphs |
| op ::= | operand | τ ∈ T ::= | types |
| true | false | n_i32 ... | constants | bool | i32 | ... | base types |
| copy p | scalar copies | Box τ | heap pointers |
| move p | ownership transfers | &r ω τ | references |
| e ∈ E ::= | expressions (r-values) | struct id() | structs |
| op | operand | enum id() | enums |
| &r ω p | borrow expressions | fn ⟨p̄, ρ_1 : ρ_2⟩(τ) → τ | function types |
| uop op | op_1 bop op_2 | operators | d ∈ D ::= | top-level definitions |
| discr(p) | enum discriminants | fn id_f(, ρ_1 : ρ_2) | |
| Box(op) | heap-allocated values | (x_param : τ) → τ | |
| idenum :: fid(op) | enum constructors | = { (x_local : τ), x_ret : τ, g } | function definitions |
| struct id() (fid : τ) | struct definitions | ||
| prog ::= d | programs | enum id() (fid : τ) | enum definitions |
Fig. 4. Syntax of Core MIR
We follow MIR's design of expressions (i.e., r-values) and operands [34]. MIR does not contain nested expressions. Source-level nested expressions are lowered into assignments to temporary variables, followed by their uses in the operands. The expression Box(op) allocates heap memory to store the value of op.idenum :: fid(op) constructs an enum value using the fid constructor of the enum type named idenum. Operands explicitly distinguish whether a place is used by move or by copy, allowing the analysis to track their different effects on ownership. Places identify memory locations (i.e., l-values). A place p consists of a variable with a sequence of projections applied to it. A projection selects a field of a struct or enum, or dereferences a Box or reference, where the annotations b and r can be omitted when we do not need to distinguish them.
A borrow expression &r ω p creates a borrow of place p with mutability ω (mut for mutable or shr for shared, we also write them as m and s, respectively). Note that r is a temporary region alive only in this very expression. Despite that, it plays the critical role of collecting loans from borrows and reborrows in borrow checking, as we shall see later. Regions introduced for borrow expressions at different program points are distinct from one another and from the regions appearing in variable and parameter types. If a place has reference type, its type is also annotated with a region, e.g., &r ω τ. We use r as the default notation for regions (e.g., regions in the types of local variables). We use ρ specifically for region parameters declared by functions, structs, and enums, and for their occurrences in the types of function parameters.
3.2 A Rule-based Formulation of Polonius Borrow Checking
In the Rust compiler, borrow checking is implemented as a highly engineered and optimized system. Nevertheless, it roughly consists of three steps: generating region constraints to capture the borrowing information generated at each program point, solving these constraints to propagate this information across program points, and detecting errors, i.e., violations of the AXM discipline, based on the solution. Figure 6 illustrates the three steps of Polonius. Correspondingly, we present
Jinhua Wu, Yuting Wang, and Zhemin Chen
\begin{array}{r l}&{\mathrm{P O L-B O R-E X P R}}\\ &{p_{2}=\&r\omega p_{1}\mathrm{a t}n\quad C_{1}=\{p_{1}^{\omega}\}\subseteq r\quad r_{1}\subseteq r_{2}\in C_{1}\cup C_{2}}\\ &{\quad C_{2}=\{r^{\prime}\subseteq r\mid\forall(p^{\prime}:\&r^{\prime}__{}),\mathrm{p r e f i x}(*p^{\prime},p_{1})\}}\\ &{\quad r_{1}\subseteq r_{2}\mathrm{a t}n}\end{array}(a) The generation rules of subset constraints for assignment
(b) The inference rules for loan analysis
(c) The inference rules for error detection
Fig. 5. The core inference rules for the Polonius borrow checker

Fig. 6. Structure of the Polonius borrow checker
the core inference rules used in these three steps in Fig. 5. The presentation style is inspired by [5], but we give a more formal account that covers the whole process from constraint generation to error detection. Polonius mainly relies on two kinds of constraints: subset constraints and liveness constraints. Assignment is the most important case for understanding how subset constraints are generated, since creating a new borrow through borrow expressions can only appear on the right-hand side of assignments. We present the constraint-generation rules for assignments in Fig. 5a. They summarize the reborrow and subtyping rules introduced in the NLL RFC [44, 46], but are presented in the style of Polonius, using subset relations between regions rather than outlives relations between lifetimes as in NLL. The rules in Fig. 5b and Fig. 5c follow the Datalog rules of Polonius [36]. These rules rely on the subset constraints and liveness constraints generated from Fig. 5a, mirroring how the Datalog rules rely on "input facts" generated from rustc.
Reading the rules from bottom to top, POL-BORROW-CHECK reports a borrow-checking error when a loan is invalidated while it is still alive, i.e., AXM is violated. A loan takes the form , denoting that the place p is borrowed with mutability . That is, loans represent the borrowing information computed by the borrow checkers. Intuitively, a loan is alive means that a borrower of p is still alive, so p cannot be accessed in a way that conflicts with this borrow. The invalidated at judgment is defined by two cases. POL-WRITE-INVALID states that a loan on a place p is invalidated by a write to
Verified Implementation of the Next-gen Borrow Checking Algorithm for Rust via Abstract Interpretation
9
any place that overlaps with (denoted as p#p'). Here, and overlap if one is a prefix of the other. By definition, is a prefix of iff . . POL-READ-INVALID states that a mutable loan on a place is invalidated by a read of its overlapped place. A place is considered written if it is assigned, dropped, moved, or borrowed mutably. Otherwise, if is copied or borrowed shareedly, it is considered read. The judgment “ live at ” is derived by POL-LOAN-LIVE as the result of loan analysis. Loan analysis computes which loans are contained in each region at each program point, i.e., judgments of the form “ at ”. A loan is alive when it belongs to a live region, written as “ live at ”, meaning that is alive at the start of . Such constraints are computed by a standard liveness analysis of which we omit a discussion. In the following paragraphs, we discuss how the rules in Fig. 5 collaborate to perform borrow checking as realized in Polonius.
Borrows and reborrows. We begin with a discussion of how borrow checking is performed in presence of references and reborrowing of values through references. Consider the following example which would cause a memory error without borrow checking. We explain how Polonius rejects this program using the rules in Fig. 5. We present the example in Rust surface syntax for readability, with line numbers serving as CFG nodes. The comments show the subset constraints generated at this node (by Fig. 5a) and the computed live loans at the next node (by Fig. 5b).
1 let mut v = Box::new(1); // 'r1 and 'r2 are temporary regions and would be dead immediately
2 let mut x: &'x mut Box<i32> = &'r1 mut v; // {v^m}subseteq'r1 (by POL-BOR-EXPR)
// 'r1subseteq'x (by POL-SUB-MUT and POL-ASSIGN)
// Live loans at : {v^m}subseteq'x (by Fig. 5b); 'x is alive until
3 let mut y: &'y i32 = &'r2 **x; // {**x^5}subseteq'r2, 'xsubseteq'r2 (by POL-BOR-EXPR)
// 'r2subseteq'y (by POL-SUB-SHR and POL-ASSIGN)
// Live loans at : {v^m,**x^5}subseteq'y (by Fig. 5b); 'y is alive until
4 v = Box::new(2); // borrow-error by POL-WRITE-INVALID and POL-BORROW-CHECK
5 printIn!("{}", *y); // Without borrow checking, this would access freed memory.
In the example, the final use of keeps 'y alive across the reassignment of . Since 'y contains , this mutable loan is still alive when is written. The checker therefore rejects the reassignment using the rules in Fig. 5c. This prevents the later access through from reaching memory that would have been freed by replacing with a new Box value.
To understand why 'y contains , we examine the subset constraints. As in constraint-based pointer analysis [1], these constraints propagate points-to information between regions. A basic case is issuing a loan for a borrow assignment of the form . in POL-BOR-EXPR records the directly issued loan through . POL-ASSIGN then generates constraints through subtyping, including , to propagate the loan to the assignee . In the example, the assignments to and introduce into 'x and **x^5 into 'y, respectively.
The above constraints alone do not explain how flows into 'y. This propagation relies on the reborrow constraints in , the second part of POL-BOR-EXPR. Intuitively, if the borrowed place (i.e., ) already borrows from other places, collects the loans representing those places so that they are reborrowed by the assignee. This is realized by collecting subset constraints on prefixes of with reference types w.r.t. as described in . When is created, generates 'xsubseteq'r2. Together with 'r2subseteq'y from the assignment, this propagates from 'x through 'r2 to 'y. The loan is then carried to the next node by POL-LOAN-FLOW. Together with the liveness of 'y, this propagation allows the checker to detect the conflicting write to .
²After lowering to our Core MIR, the source-level assignment is expanded into drop(v); , so that the old value is first released before the new value is assigned. Dropping counts as a write and incurs the error. ³The NLL RFC [44] uses supporting prefixes. Starting from a place, their collection removes projections and stops at a dereference of a shared reference. We use ordinary prefixes in the main text to simplify the presentation. The appendix and our Rocq formalization use supporting prefixes.
Jinhua Wu, Yuting Wang, and Zhemin Chen
Stacked AXM discipline. POL-BOR-EXPR ensures that a newly created borrow not only creates a loan for its direct lender, but also inherits all the loans from that lender through reborrowing. This explains why mutable references to the same location should be used in a first-created-last-used order, i.e., following the stacked AXM discipline. Consider the following example from Fig. 1:
let mut v = Box::new(1); let mut x: &'x mut i32 = &mut *v; // {*v^} ⊆'x (by POL-ASSIGN) // Live loans at l₃: {*v^} ⊆'x (by Fig. 5b); 'x is alive until l₄ let mut y: &'y mut i32 = &mut *x; // {*x^} ⊆'y, 'x⊆'y (by POL-ASSIGN) // Live loans at l₄: {*v^} ⊆'x, {*v^, *x^} ⊆'y (by Fig. 5b); 'y is alive until l₅ *x = 2; // borrow-error by POL-WRITE-INVALID and POL-BORROW-CHECK *y = 3;
Here, *y, *x, and *v reach the same location and are all mutable, but their loan sets have a containment relation. Since y carries a loan on *x and x carries a loan on *v, this containment relation, together with POL-BORROW-CHECK, enforces the stack order of first using y, then x, and finally v.
Nested references. Like pointers-to-pointers in C/C++, Rust supports nested references. The main challenge is that nested references introduce indirect updates which require merging of regions. That is, through one reference, the program may modify another reference and thereby change the places it borrows. As a result, the loans associated with a region may change even when that region is not updated directly. Rust handles this case through the subtyping rules [46] for assignments, which can merge regions appearing at corresponding levels of nested reference types. Consider an example that may cause a memory error through an indirect update:
let mut v1 = 1; let mut v2 = Box::new(2); let mut x: &'x mut i32 = &'r1 mut v1; // {v1^} ⊆'r1 (by POL-BOR-EXPR) // 'r1⊆'x (by POL-SUB-MUT and POL-ASSIGN) // Live loans at l₃: {v1^} ⊆'x (by Fig. 5b); 'x is alive until l₆ let mut y: &'y1 mut &'y2 mut i32 = &'r2 mut x; // {x^} ⊆'r2 (by POL-BOR-EXPR) // 'r2⊆'y1, 'x⊆'y2, 'y2⊆'x (by POL-SUB-MUT and POL-ASSIGN) // Live loans at l₄: {x^} ⊆'y1, {v1^} ⊆'y2⊆'x (by Fig. 5b); 'y1 and 'y2 are alive until l₄ *y = &'r3 mut *v2; // {*v2^} ⊆'r3 (by POL-BOR-EXPR) // 'r3⊆'y2 (by POL-SUB-MUT and POL-ASSIGN); 'x⊆'y2, 'y2⊆'x (by POL-SUBSET-FLOW) // Live loans at l₅: {v1^, *v2^} ⊆'x (by Fig. 5b) v2 = Box::new(3); // borrow-error by POL-WRITE-INVALID and POL-BORROW-CHECK *x = 4; // Without borrow checking, this would access freed memory.
At line 3, creating y makes *y and x denote the same memory location. Polonius records this aliasing fact by generating the two subset constraints 'x ⊆ 'y2 and 'y2 ⊆ 'x via POL-SUB-MUT, i.e., 'y2 ≡ 'x. This equality is crucial at line 4. The assignment of *y also updates the reference value stored in x, so the loan *v2^m flows into 'y2 and hence also into 'x. As a result, the later write to v2 invalidates *v2^m that is still alive as it is contained in the live region 'x, which causes borrow-error.
References in composite data types. The preceding examples show how regions can be equated during analysis. Regions can also be equal by definition. In a struct/enum, different reference fields may share the same region parameter and thus the same loan set. Consider this example:
// struct Point<'a> {x: &'a mut i32, y: &'a mut Box<i32>} let mut v1 = 1; let mut v2 = Box::new(2); let mut p: Point<>'p>; p.x: &'p mut i32 = &'r1 mut v1; // {v1^} ⊆'r1, 'r1⊆'p p.y: &'p mut Box<i32> = &'r2 mut v2; // {v2^} ⊆'r2, 'r2⊆'p // Live loans at l₄: {v1^, v2^} ⊆'p; 'p is alive until l₄ let mut z: &'z mut i32 = &'r3 mut {(p.y)}; // {{(p.y)^} ⊆'r3, 'p⊆'r3, 'r3⊆'z // Live loans at l₅: {v1^, v2^, **{(p.y)^} ⊆'z; 'z is alive until l₆ v1 = 4; // borrow-error by POL-WRITE-INVALID and POL-BORROW-CHECK *z = 3;
Verified Implementation of the Next-gen Borrow Checking Algorithm for Rust via Abstract Interpretation
11
The assignments to p.x and p.y introduce loans v1^m and v2^m into 'p, respectively. When z is created, the reborrow constraint propagates both loans into 'z. As a result, borrow checking rejects the assignment to v1, even though the last two statements access disjoint memory locations. This imprecision arises because a single region merges borrowing information from multiple reference fields. Such imprecision is unavoidable when supporting references in composite data types, especially recursive types that may contain an unbounded number of references.
Kill loans. For the judgment “p^ω not killed at n” in POL-LOAN-FLOW, informally, if a loan has the form *r^p^ω and p is reassigned, then *r^p^ω is considered killed. Intuitively, p now refers to a new value, so the previous borrowing relation through p no longer holds.
1 let mut v1 = 1; let mut v2 = 2; 2 let mut x: &'x mut i32 = &'r1 mut v1; // {v1^m} ⊆'r1, 'r1⊆'x 3 let y: &'y mut i32 = &'r2 mut *x; // {*x^m} ⊆'r2, 'x⊆'r2, 'r2⊆'y // Live loans at l4: {v1^m, *x^m} ⊆'y; 'y is alive until l5 4 x = &'r3 mut v2; // {v2^m} ⊆'r3, 'r3⊆'x; *x^m is killed as x is reassigned // Live loans at l5: {v2^m} ⊆'x, {v1^m} ⊆'y; 'x is alive until l5 5 *x = 3; *y = 4; // Both accesses are OK
At line 4, x is reassigned to point to v2, while y still points to v1. The reassignment kills the loan *x^m created at line 3, so it is not propagated into 'y at line 5. 4 Thus, x and y can subsequently be used independently to modify v2 and v1, respectively. If *x^m were not killed, using x before y would be rejected. Loan killing is an important feature to allow the checker to accept such reassignment-then-use patterns, as discussed in the problem case #4 of the NLL RFC [44].
Control flow, function calls and function returns. The examples above illustrate the main concepts of borrow checking. We cover the remaining details when presenting Polonius as an abstract interpreter in the following sections. In particular, we define an abstract domain with join operations to merge states from different control-flow paths, along with transfer functions for function calls and returns. Polonius also detects illegal region relations [26, 36]. These errors are checked at function returns to ensure that loans passed in by the caller flow back consistently with the region relations declared in the function signature. We discuss these checks in the next section.
4 A Forward Abstract Interpreter for Polonius Borrow Checking
4.1 Overview of the Abstract Interpreter
POL-FWD-INVALID
POL-FWD-CHECK
Fig. 7. Inference rules of region invalidation and error detection for forward-only borrow checking
Although rule-based Polonius is more suitable for formalization than the original algorithm, it is still too complicated because it requires mixing forward propagation of loans and backward analysis of liveness. We observe that region liveness is used only to anticipate future uses and report errors eagerly. It does not affect loan analysis. Therefore, we could turn rule-based Polonius into forward-only analysis by reporting errors lazily. More specifically, when a loan is invalidated, we
⁴At line 4, applying only POL-WRITE-INVALID would invalidate the loan *x^m and report a borrow error because 'y is still alive. The actual borrow checker distinguishes shallow and deep accesses [44]. Reassigning x is a shallow access: it updates the reference stored in x without accessing *x. Therefore, it does not invalidate this loan. The appendix and our Rocq formalization include this distinction.
Jinhua Wu, Yuting Wang, and Zhemin Chen

Fig. 8. Architecture of the abstract interpreter for Polonius
mark the regions containing it as invalid (called region invalidation) as shown in POL-FWD-INVALID in Fig. 7. An error is reported only when a later operation accesses a place whose type contains an invalid region, as shown in POL-FWD-CHECK. In summary, the rules in Fig. 7 replace POL-LOAN-LIVE and POL-BORROW-CHECK. Borrow errors are now reported when accessing invalidated regions.
In the new rules, we use an abstract state to mark validity of regions and to store its set of loans. It indicates that the forward-only Polonius could be formalized as forward abstract interpretation on an abstract domain. This makes its verification manageable by adopting abstract interpretation techniques. It also gives a runnable algorithm using fixed-point solvers. The architecture of this abstract interpreter is shown in Fig. 8. It computes an abstract state at each execution point. maps each region to a region state . A region state can be uninitialized, valid with a loan set (same as that obtained by constraint solving in Polonius), or invalid. The transfer functions model transitions between abstract states and detect borrow errors.
The main challenge in designing this abstract interpreter is to faithfully implement the rules of Polonius in the transfer functions and abstract domain. As shown in §3.2, Polonius can be viewed as a constraint-based pointer analysis. Regions are abstract pointers storing loans that represent borrowed memory locations. This suggests the naive definition of an abstract state as a mapping from regions to loan sets, modeling constraints like as . For example, we replace in POL-LOAN-LIVE with in POL-FWD-INVALID. However, besides such consumption of subset constraints between regions, Polonius also generates new subset constraints, some of which even represent equality between regions and need to be maintained across program points. How should these constraints be translated into abstract interpretation?
Our key observation is that these subset constraints could be classified into transient and persistent constraints. The former is modeled as computation of data-flow in transfer functions, while the latter as a more sophisticated abstract domain that partitions regions into equivalence classes.
Transient constraints. These are constraints where at least one of and is a region of a borrow expression (i.e., a temporary region). Examples include the constraints involving the borrow expression's temporary region in POL-BOR-EXPR (e.g., ) and POL-ASSIGN. We call them transient because here only serves to propagate loans in into at a single program point, without requiring the subset relations to be maintained in subsequent execution. Thus, they can be modeled directly as dataflow operations in the transfer functions.
Persistent constraints. These are constraints where both regions appear in the types of places (i.e., not temporary regions). They arise from Rust's subtyping rules [46] and are important for operations such as indirect updates through nested references. Examples include region equality introduced by POL-SUB-MUT (invariance) and subset relations introduced by POL-SUB-SHR (covariance).⁵ Because these constraints do not involve temporary regions, they need to be maintained
⁵Rust also supports contravariance. Since our language excludes higher-order functions, we do not consider contravariance.
Verified Implementation of the Next-gen Borrow Checking Algorithm for Rust via Abstract Interpretation
13
during execution, hence should be persistently recorded in the abstract domain. A naive approach is to use a relational abstract domain that records both subset and equality relations. However, we observe that subset relations introduced by shared references need not be maintained persistently. Since values cannot be updated through shared references during execution (i.e., cannot perform indirect updates), they can be treated as propagation of loans like transient constraints. Consequently, we only need to maintain region equality introduced by POL-SUB-MUT in the abstract domain, which we model by dividing the domain of into equivalence classes of regions modulo this equality.
4.2 Formalization of the Abstract Interpreter
Algorithm 1 Borrow Checking
1: procedure BORROWCHECK(prog) 2: for all do 3: 4: for all do 5: if then 6: return Error 7: 8: return OK()
1: procedure INTERPRET() 2: 3: See Fig. 14 4: 5: return 6: procedure 7: match with 8: ... See Fig. 13
Algorithm 1 implements our borrow checker for a program . For each function , computes a map that assigns an abstract state to each CFG node. The checker then evaluates each instruction at node again to detect errors, written as . If no instruction raises an error, it returns OK(), collecting the analysis results. Otherwise, it returns Error.
The INTERPRET function invokes a dataflow solver to compute the abstract states of . The solver evaluates instructions in the CFG until a fixpoint is reached. It takes a semi-lattice , a transfer function , and an initial state at function entry. The solver must return a solution satisfying the dataflow constraints: for every CFG edge , if , then . Here, is the instruction at node . This means that must (over-)approximate the result of evaluating from . We use the classic Kildall's algorithm as the solver as it has already been formally verified in CompCert. Since may raise borrow errors, we use a logging monad as in [12], to prevent errors from interrupting the solver's fixpoint computation. Errors are recorded in a log while the analysis continues. After the analysis, errors can be detected by evaluating the instructions again and inspecting the log.
Abstract domain. Fig. 9 defines the abstract state and its operations. We introduce external loans to represent loans passed from the caller to the callee. Since the callee is analyzed without knowing the caller's specific loans, these loans are summarized by a region parameter . They are called "placeholder loans" in the Polonius implementation [26, 36]. External loans are essential for supporting modular analysis. We explain their role in function calls later. An abstract state is a pair , where is a union-find structure representing region equality, and maps regions to region states. The map stores only one state for each equivalence class in . We write for its representative, computed by . Looking up or updating a region accesses the state of . The union operation merges two equivalence classes and joins their region states.
Jinhua Wu, Yuting Wang, and Zhemin Chen
Abstract States
Operations
Fig. 9. Definitions of the abstract domain and its operations. The bottom part of Abstract State defines the lattice operators for region states (omit Rs subscript). The components of can be simply obtained by lifting those in the lattice structures of the union-find and Rs. In Operations, the first line shows the standard union-find operations. The bold operators define lookup, update, and union on the abstract state. We also write operations on directly on . For example, abbreviates when .
Transfer functions. We present the main cases of the transfer functions in Fig. 13, including assignments, drops, function calls, and returns. Table 1 shows how these functions correspond to the Polonius rules. Transfer functions model transient constraints by updating the region states and persistent constraints by updating the union find. We illustrate them using the examples from §3.2 and a new function call example. In these examples, reassignments to Box variables are expanded into a drop followed by an assignment, as in the actual Core MIR program. This makes clear which transfer functions are applied. The comments record the abstract state after each line. We write to mean that belong to the same equivalence class and share a valid region state containing the loan set .
Table 1. Design of transfer functions
| Transfer functions | Polonius rules | |
|---|---|---|
| I-ABS-ASSIGN | POL-ASSIGN | |
| E-ABS-BORROW | POL-BOR-EXPR | |
| P-ABS-OK | ||
| FLOW-LOAN-REF | ||
| Flow-Cov | POL-SUB-MUT/SHR | |
| Flow-INV | POL-SUB-MUT | |
| Invalidate | POL-FWD-INVALID | |
| Kill | not killed at n | |
| P-ABS-INVALID | POL-FWD-CHECK | |
1 let mut v = Box::new(1); // ['x']→⊥Rs, ['r1']→⊥Rs, ['r2']→⊥Rs (I-ABS-ASSIGN)
2 let mut x: &'x mut Box<132> = &'r1 mut v; //['x']→{v}, ['y']→⊥Rs, ['r1']→{v}, ... (I-ABS-ASSIGN)
3 let mut y: &'y i32 = &'r2 **x; //['x']→{v}, ['y']→{v,***s}, ['r2']→{v,***s}, ... (I-ABS-ASSIGN)
4 drop(v); // ['x']→Invalid, ['y']→Invalid, ... (I-ABS-DROP);
5 v = Box::new(2); // ['x']→Invalid, ['y']→Invalid, ... (I-ABS-ASSIGN)
6 println("({)", *y); // borrow-error: the accessed region 'y' is invalid (P-ABS-INVALID)
The results of this example agree with those of the rule-based Polonius in §3.2. Rule I-ABS-ASSIGN models POL-ASSIGN, while E-ABS-BORROW models POL-BOR-EXPR. The latter invokes to collect the directly issued loan and loans from the prefix regions. For example, at line 3, computes . Finally, FlowLoans propagates loans from the regions
Verified Implementation of the Next-gen Borrow Checking Algorithm for Rust via Abstract Interpretation
15
Fig. 10. Auxiliary functions, region invalidation, loan killing and evaluation of places
Fig. 11. Evaluation of move and borrow expressions; operand expressions are expanded directly.
FLOW-LOAN-REF
Fig. 12. Operations of flowing loans between reference types, where
I-ABS-ASSIGN
I-ABS-CALL
I-ABS-DROP
CHECK-RET-REGION-ERR
Fig. 13. Evaluation of assignments, drops, function calls and function returns (f is the current function)
Fig. 14. Operations of analyzing a function call and function initialization
Jinhua Wu, Yuting Wang, and Zhemin Chen
of the expression type to those of the assignee type, modeling POL-SUB-MUT and POL-SUB-SHR. At line 3, Flow-Cov propagates the loan set from 'r2 to 'y through a join operation.
At line 4, Invalidate# in I-ABS-DROP invalidates 'x and 'y, which contain loans conflicting with v. Errors are detected when a place p is later accessed, through validity checks over RefRegs(p) and AllRegs(p). Intuitively, RefRegs(p) contains the regions of reference prefixes used to reach p, while AllRegs(p) also includes the regions in the type of the value stored at p. The former checks whether locating p encounters an invalid region, as in I-ABS-ASSIGN and I-ABS-DROP. The latter also checks the validity of the value stored at p and the references it contains. A failed validity check raises borrowErr#, as in P-ABS-INVALID. We omit the error cases of and for brevity.
We use the example of nested references to illustrate how region equality is established:
// For brevity, we omit the region states for temporary regions, e.g., 'r1 and 'r2. 1 let mut v1 = 1; let mut v2 = Box::new(2); // ['x']→⊥Rs, ['y1']→⊥Rs, ['y2']→⊥Rs (I-ABS-ASSIGN) 2 let mut x: &'x mut i32 = &'r1 mut v1; // ['x']→{v1^m}, ['y1']→⊥Rs, ['y2']→⊥Rs (I-ABS-ASSIGN) 3 let mut y: &'y1 mut &'y2 mut i32 = &'r2 mut x; // ['y1']→{x^m}, ['y2', 'x']→{v1^m} (I-ABS-ASSIGN) 4 *y = &'r3 mut *v2; // ['y1']→{x^m}, ['y2', 'x']→{v1^m, *v2^m} (I-ABS-ASSIGN) 5 drop(v2); // ['y1']→{x^m}, ['y2', 'x']→Invalid (I-ABS-DROP) 6 v2 = Box::new(3); // ['y1']→{x^m}, ['y2', 'x']→Invalid (I-ABS-ASSIGN) 7 *x = 4; // borrow-error: the accessed region 'x is invalid (P-ABS-INVALID)
At line 3, FlowLoans invokes FLOW-INV to merge 'x and 'y2 into the same equivalence class. Thus, updating 'y2 at line 4 also (indirectly) updates 'x. Note that this update joins the new loan into the existing loan set rather than overwriting it. Overwriting occurs only when a variable is reassigned, similar to killing a variable in liveness analysis. We leave this detail to the technical report.
We use the following function call example to illustrate how to support modular analysis:
// fn choose<a, 'b, 'c>(a: &'a mut i32, b: &'b mut i32, d: bool) -> &'c mut i32 // where 'b: 'c { if d { return a; } else { return b; } } // If checker accepts this function 1 let mut x = Box::new(1); let mut y = Box::new(2); // ['z']→⊥Rs (I-ABS-ASSIGN) 2 let z: &'z mut i32 = choose(&'x mut *x, &'y mut *y, true); // ['z']→{*y^m} (I-ABS-CALL) 3 drop(x); // ['z']→{*y^m} (I-ABS-DROP); z now points to freed memory, but it is not invalidated. 4 x = Box::new(2); // ['z']→{*y^m} (I-ABS-ASSIGN) 5 println!("()","*z"); // No borrow-error: 'z is valid, but this read accesses freed memory.
At line 2, the choose function (its definition shown in the comments) may return a reference to either *x or *y. For this call, I-ABS-CALL evaluates the arguments, and TRANSFER-CALL-OK propagates their loans to the parameter regions. It then applies the region relations in the signature of choose to simulate how the loans return from callee. Since the signature contains only 'b: 'c, only *y^m flows to 'c and then to 'z. However, the concrete execution returns a reference to *x. Dropping x therefore frees the memory referenced by z without invalidating 'z. The subsequent access through z would access freed memory without raising a borrow error. To prevent this, the borrow checker must reject the incomplete signature of choose, which lacks the region relation 'a: 'c. This relation tells the caller that the loan *x^m may flow into 'z. With this relation, 'z would contain the loan after the call. Dropping x would then invalidate 'z, causing the subsequent access to raise error.
We now explain how our borrow checker rejects this choose function by CHECK-RET-REGION-ERR:
fn choose<a, 'b, 'c> ...{// ['a] → {E('a)}, ['b] → {E('b)}, ['c] → {E('c)}} (INIT-FUNCTION) if d { return a; } // ['c] → {E('c), E('a)}, ['a] → {E('a)}, ['b] → {E('b)} else { return b; } // ['c] → {E('c), E('b)}, ['a] → {E('a)}, ['b] → {E('b)} // Joined state: ['c] → {E('c), E('a), E('b)}, ['a] → {E('a)}, ['b] → {E('b)} } // By CHECK-RET-REGION-ERR: 'a: 'c and 'b: 'c must both exist in the function signature.
Recall that an external loan summarizes the loans supplied by the caller through region parameter , which are unknown to the callee. During the callee's analysis, these external loans are propagated like ordinary loans. In the example, the two return branches propagate and into 'c, respectively. Thus, the joined state of 'c contains both external loans. At function
Verified Implementation of the Next-gen Borrow Checking Algorithm for Rust via Abstract Interpretation
17
return, CheckReturn requires whenever has flowed into . CHECK-RET-REGION-ERR reports regionErr# for this function as 'a:' c is missing. This ensures that the caller can soundly simulate the callee's loan flow using only the region relations in the function signature.
5 Borrow-Aware Semantics
To verify memory safety, we need a concrete semantics that accurately describes when memory errors could happen. Traditional small-step operational semantics suffice for this purpose. However, it alone is not enough for connecting with the abstract interpreter (i.e., proving its soundness) whose conservative nature means the interpretation could terminate way earlier before the actual memory errors happen because of violation of stacked AXM. Therefore, the main challenge is to instrument the concrete semantics with a notion of stacked AXM discipline that excludes ill-behaved interleaved accesses through pointers to the same location. The instrumentation does not change the faithfulness of concrete semantics; it only adds the minimum information to enforce stacked AXM.
We observe that our forward-only abstract interpreter for Polonius is already close to concrete program execution. We therefore design a concrete semantics by concretizing its abstractions. In particular, regions as abstract pointers storing loans are concretized as reference values carrying borrow sets, which record the precise places borrowed by each reference. Dynamic borrow checking uses reference invalidation and checks for invalid references, corresponding to region invalidation and checks for invalid regions, respectively. We use a structured, value-based memory model based on Rust's ownership discipline. This allows us to represent borrowed locations using named places rather than low-level memory addresses, while supporting reasoning about memory safety.
5.1 Memory Model
| Concrete States | |||
|---|---|---|---|
| ( ) | move paths | memory model (store) | |
| borrow sets | call stacks | ||
| values | instruction signals | ||
| true | false | | constants | next(n) | continue at node n |
| Ref bs | reference values | call(f, ) | call f with |
| Ref | invalid references | return(v) | return v |
| Box v | heap-allocated values | program states | |
| uninitialized values | state(f, n, ) | regular states | |
| Struct(id, ) | struct values | borrow-error | borrow-error states |
| Enum(id, fid, v) | enum values | ||
| Memory Read and Write | |||
| V-READ | VR-BOX | VR-STRUCTFIELD | |
| V-WRITE | VW-BOX | VW-STRUCTFIELD | |
| VW-BASE | |||
Fig. 15. Program states and memory read and write operations.
Fig. 15 presents our structured memory model. Its design is standard for operational semantics except that information about structured memory addresses and borrowing is instrumented into
Jinhua Wu, Yuting Wang, and Zhemin Chen
reference values. A reference value Ref bs stores a move path identifying its target and a borrow set bs recording the places it borrows from. Move paths come from Rust's move checking [35] and serve as memory addresses. This representation relies on the absence of pointer arithmetic and Rust's ownership discipline. We can identify locations using syntactic places, and each owned value has a unique move path. Updating a value through its move path corresponds to updating the value at its memory address. To avoid name conflicts across stack frames, the root variable of each move path or place is paired with a unique frame identifier, which we omit from the notation. Memory is therefore represented as a map from uniquely identified variables to structured values. Program states are used in small-step transitions guided by signals produced by instruction evaluation.
Read and write operations accept only move paths as their targets. We write to mean that reading location from produces value . Similar to traversing a tree, V-READ first reads the value stored at the root variable of , and then uses the auxiliary judgment to follow the projection , viewed as a path in the value tree rooted at , and obtain the value . For the write operation, we write to mean that writing value to location in produces the updated memory . V-WRITE first extracts the old value stored at the root variable of . It then uses the auxiliary judgment to follow the projection and replace the corresponding subtree of with the new value , producing an updated root value . Finally, is written back to the root variable in memory. The rules for enum values are similar and are omitted for brevity.
5.2 Operational Semantics
Each abstract operator in the abstract interpreter has a concrete counterpart in our borrow-aware semantics. Fig. 16 presents place and expression evaluation, Fig. 17 defines reference invalidation, and Fig. 18 presents instruction evaluation and the small-step semantics. We use the same three examples from the previous section to explain these rules and compare the concrete results with those of the abstract interpreter to illustrate the approximations made by the analysis.
1 let mut v = Box::new(1); // vmap Box 1, xmap ⊥, ymap ⊥ (I-ASSIGN) 2 let mut x: &'x mut Box<i32> = &'r1 mut v; // vmap Box 1, xmap Ref^m v {v}, ymap ⊥ (I-ASSIGN) 3 let mut y: &'y i32 = &'r2 x; // vmap Box 1, xmap Ref^s v {v}, ymap Ref^s v {, v} (I-ASSIGN) 4 drop(v); // vmap ⊥, xmap Ref †, ymap Ref † (I-DROP) 5 v = Box::new(2); // vmap Box 2, xmap Ref †, ymap Ref † (I-ASSIGN) 6 println!("("), *y); // borrow-error: y stores an invalid reference (P-INVALID)
The comments show the concrete memory state after each line. At line 3, I-ASSIGN evaluates the borrow expression using E-BORROW and stores the result in a fresh temporary variable before assigning it to y. The temporary variable allows Invalidate and Kill to handle the evaluated value like other values in memory. To compute the target move path and borrow set for y, E-BORROW invokes . This applies P-VAR, P-MUTREF, and P-BOX in sequence, producing . The resulting reference therefore shareedly borrows **x and *v. This computation corresponds to abstract place evaluation . Applying projections during place evaluation ensures that every place in the resulting borrow set reaches the reference's target, so borrow sets record precise aliasing information. To keep the instrumentation minimal, borrow sets record only mutable places. Thus, P-SHRREF does not apply * to places in (which also reach ), since dereferencing them would produce shared (i.e., immutable) places. At line 4, I-DROP invokes Invalidate to invalidate references borrowing v by setting them to Ref †. This corresponds to Invalidate in the abstract interpreter. However, since borrow sets are precise, only references whose borrows actually conflict with the access are invalidated. Invalidation prevents out-of-order accesses, where a borrowing reference is used after a conflicting access to a place in its borrow set. In our semantics, such a use results in a borrow error. At line 6, dereferencing y encounters an invalid reference, so P-INVALID raises a borrow error, which eventually causes STEP-BOR-ERR to transition to borrow-error.
Verified Implementation of the Next-gen Borrow Checking Algorithm for Rust via Abstract Interpretation
19
Fig. 16. Evaluation of places and expressions
Fig. 17. Reference invalidation and killing borrow sets
Fig. 18. Evaluation of instructions, initialization and removal of stack frames, and small-step semantics
In this example, y's type carries region 'y, whose loan set approximates y's borrow set. Recall that at line 3, this region contains . The loan **x^s directly corresponds to **x in the borrow set, whereas only approximates the borrow of *v. This imprecision arises because , propagates loans unchanged, whereas applies projections to borrowed places. In general, for a reference place , if , then the borrow set of the reference stored at must be approximated by the region state . For soundness, every borrowed place must be covered by a loan on that place or one of its prefixes, with at least the same access restrictions (i.e., mutability). This ensures that abstract error detection covers concrete borrow errors. This example shows how loan sets approximate borrow sets. We now explain what region equality approximates:
1 let mut v1 = 1; let mut v2 = Box::new(2); // v1 1, v2 Box 2, x , y (I-ASSIGN)
2 let mut x: &'x mut i32 = &'r1 mut v1; // v1 1, v2 Box 2, x Ref v1 {v1}, y (I-ASSIGN)
3 let mut y: &'y1 mut &'y2 mut i32 = &'r2 mut x;
Jinhua Wu, Yuting Wang, and Zhemin Chen
// v1 ↔ 1, v2 ↔ Box 2, x ↔ Refᵐ v1 {v1}, y ↔ Refᵐ x {x} (I-ASSIGN)
- y = &'r3 mut *v2; // v1 ↔ 1, v2 ↔ Box 2, x ↔ Refᵐ *v2 {*v2}, y ↔ Refᵐ x {x} (I-ASSIGN) drop(v2); // v1 ↔ 1, v2 ↔ ⊥, x ↔ Ref †, y ↔ Refᵐ x {x} (I-DROP) v2 = Box::new(3); // v1 ↔ 1, v2 ↔ Box 3, x ↔ Ref †, y ↔ Refᵐ x {x} (I-ASSIGN) *x = 4; // borrow-error: x stores an invalid reference (P-INVALID)
At line 3, creating y makes *y and x reach the same location. At line 4, assigning through *y overwrites the reference stored in x, replacing its borrow set with {*v2}. Correspondingly, at line 3, the abstract interpreter equates 'y2 and 'x, giving ['y2, 'x] ↔ {v1ᵐ}. At line 4, updating 'y2 also updates 'x, giving ['y2, 'x] ↔ {v1ᵐ, *v2ᵐ}. As in the previous example, the loan set approximates the concrete borrow set. Moreover, region equality approximates concrete aliasing. If two reference places reach the same location, their regions must belong to the same equivalence class. This allows indirect updates to be reflected in all regions representing that location.
Finally, we introduce function calls and the approximation introduced by modular analysis:
// fn choose<a, 'b, 'c>(a: &'a mut i32, b: &'b mut i32, d: bool) -> &'c mut i32 // where 'a:'c, 'b:'c { if d { return a; } else { return b; } } // Correct region relations let mut x = Box::new(1); let mut y = Box::new(2); // x ↔ Box 1, y ↔ Box 2, z ↔ ⊥ (I-ASSIGN) let z: &'z mut i32 = choose(&'x mut *x, &'y mut *y, true); // x ↔ Box 1, y ↔ Box 2, z ↔ Refᵐ *x {**x} (STEP-CALL, STEP-RETURN); ['z]↔ {*xᵐ, *yᵐ} (I-ABS-CALL) drop(x); // x ↔ ⊥, y ↔ Box 2, z ↔ Ref † (I-DROP); x = Box::new(2); // x ↔ Box 2, y ↔ Box 2, z ↔ Ref † (I-ASSIGN) printIn! ("{}", *z); // borrow-error: z stores an invalid reference (P-INVALID)
STEP-CALL enters the callee upon receiving a function call signal from instruction evaluation. We omit the execution of choose. Since the argument d is true, choose returns Refᵐ *x {**x}. STEP-RETURN then assigns this reference to z. In contrast, the abstract interpreter uses TransferCall to apply the region relations in choose's signature, propagating the loans on both *x and *y to 'z, i.e., 'z ↔ {**xᵐ, *yᵐ}. Thus, the loan set of 'z approximates the concrete borrow set of z. This approximation is produced by imprecision of the region relations in the function signature.
6 Correctness of Our Borrow Checking Algorithm

Fig. 19. Structure of the correctness proof for our borrow checking algorithm
We follow Fig. 19 to introduce our correctness proof. It summarizes how the soundness proof connects borrow checking to the stacked AXM discipline, and ultimately to memory safety.
6.1 Soundness of the Abstract Interpreter
The soundness is formalized as a backward simulation between the abstract interpreter (§4) and the borrow-aware semantics (§5). We define a simulation relation, i.e., a concretization relation, between abstract and concrete states that characterizes how Polonius abstracts precise aliasing information in the concrete semantics. We then show that it is preserved by each step of the concrete semantics. We write the concretization relation as . As illustrated by the preceding examples, we organize it into two components. The first relates region equality, represented by
Verified Implementation of the Next-gen Borrow Checking Algorithm for Rust via Abstract Interpretation
21
union-find, to concrete aliasing relations. The second relates the map of region states to concrete memory states. The latter involves three levels of correspondence: between abstract states and concrete memory states, between region states and concrete reference values, and between loan sets and borrow sets. Modular analysis further requires relating external loans to concrete borrow sets from other function contexts. We leave the full formal definition of to the technical report.
THEOREM 6.1 (SOUNDNESS). Let prog be a Core MIR program that passes borrow checking, i.e., . Let state be a reachable state of prog, be the current instruction and be the abstract state computed at . If , then the following simulation properties hold, corresponding to the simulation diagrams in Fig. 3:
-
Internal simulation. .
-
Function call and return. state . Here, ... denotes the concrete execution inside the callee. In the actual proof, this execution is simulated by the abstract states computed for the callee.
-
Borrow-error simulation. state .
By preserving the concretization relation during execution, we show that the abstract semantics soundly approximates the concrete semantics. Borrow-error simulation then ensures that abstract error detection covers every concrete borrow error. Thus, programs that pass borrow checking cannot reach a borrow-error state in the borrow-aware semantics. Establishing this simulation is highly nontrivial. For Internal simulation, a representative difficulty is assignment. The abstract interpreter propagates loans in a type-directed manner through FlowLoans, whereas the concrete semantics performs ordinary value assignment. Relating these operations requires reasoning about changes to the entire concrete memory structure and showing that the concretization relation is preserved. Function call and return is the most challenging case. As illustrated by the earlier example, the abstract interpreter performs modular analysis and treats a call as a big-step operation through TransferCall. The concrete semantics instead enters the callee and executes its body in small steps. The key is to connect the callee's analysis with the caller's abstract call operation. We show that CheckReturn ensures the signature's region relations (e.g., 'a:' c and 'b:' c in choose) cover the callee's possible loan flows. Combined with simulation within the callee, this allows the caller to use TransferCall to soundly approximate the entire concrete execution from call to return.
6.2 Enforcement of the Stacked AXM Discipline in the Borrow-Aware Semantics
Based on soundness, we formally prove the enforcement of Stacked AXM discipline in the borrow-aware semantics. The basis of this proof is a borrow relation between aliased places:
Here, Mutability() determines whether a place is mutable or shared. For example, a variable storing a shared reference may itself be mutable, whereas its dereference is a shared place. The property of ensures that all places in reach the same location as . So implies that and are aliased. We can view as an order over aliased places. It is often the case that is a dereference , and in this case the reference borrows (or points to) .
Borrow orders and reference invalidation (Fig. 17) characterize out-of-order accesses. Before accessing a place, our semantics invalidates references whose borrow sets conflict with the access (see I-DROP and I-ASSIGN). That is, given , accessing invalidates , making later evaluation of raise borrow errors. We formalize this property as follows:
Jinhua Wu, Yuting Wang, and Zhemin Chen
THEOREM 6.2 (OUT-OF-ORDER ACCESS IMPLIES BORROW ERROR). Let state be a reachable state of a Core MIR program prog. Suppose and (meaning that is accessed with acc). If acc = write, or acc = read and , then .
This theorem follows directly from the definitions of the borrow relation and reference invalidation. By this theorem, if borrow-aware semantics is free of borrow errors, then out-of-order access is not possible for a single layer of borrowing. By extending it to multiple layers of borrowing, stacked AXM is enforced. We observe from Thm. 6.2 that creating a new borrow can only extend the existing borrow order among valid places, without splitting it. By transitivity of the borrow order, we can prove that any two aliased places are ordered whenever at least one of them is mutable:
THEOREM 6.3 (ALIASED PLACES ARE ORDERED BY BORROW RELATION). Let prog be a Core MIR program and state be a reachable state of prog. For any two distinct places and , if and for some , then:
(1) If both places are mutable, then either or holds.
(2) If is shared and is mutable, then holds.
A key step in proving this theorem is proving that creating a new reference preserves the total order among mutable places. As shown in Fig. 20, a new reference may create a branch that makes two mutable places incomparable. However, Thm. 6.2 ensures that places on the old branch are invalidated. Since Thm. 6.3 only concerns valid places (whose evaluations do not raise borrow errors), all valid mutable places are still ordered.
Thm. 6.3 ensures that all mutable aliased places are ordered like

Fig. 20. A new mutable borrow of invalidates , , and .
a stack (i.e., the borrow chain as discussed in §2), while shared places form tree-like branches above it, with no required ordering among them. Because borrow orders are transitive, any two distinct mutable and aliased places are ordered. When borrow errors are absent in borrow-aware semantics, applying the contrapositive of Thm. 6.2 to this ordering guarantees stacked AXM discipline, i.e., no out-of-order accesses to places on the stack (and tree branches for shared places) are possible.
6.3 From Stacked AXM Discipline to Temporal Memory Safety
In type checked safe Rust, temporal memory errors could only be caused by accessing dangling pointers to deallocated memory. To prove that the stacked AXM discipline implies absence of such memory errors, we prove that accessing dangling pointers could only happen for out-of-order accesses to the above borrow stack (tree), hence conflicting with stacked AXM. The following adequacy property connects the borrow order to operations that may deallocate a reference's target.
THEOREM 6.4 (ADEQUACY OF THE BORROW ORDER). Let state be a reachable state of a program prog. Consider distinct places and , where and . If and bs (i.e., must be a move path), then , i.e., .
This property states that the borrow order captures all borrow relations that could potentially cause temporal memory errors. Here, contains only field projections and Box dereferences. Dropping (freeing) releases the value at and its owned subvalues, including the value at , which is pointed to by the reference stored in . This could and is the only way to leave a dangling reference and cause a memory error by accessing (as shown by examples in §5). In this case, the adequacy property requires . The stacked AXM discipline then ensures that dropping (prefix of ) could not happen before accessing because this is an out-of-order access.
Verified Implementation of the Next-gen Borrow Checking Algorithm for Rust via Abstract Interpretation
23
To prove memory safety, we extend the borrow-aware semantics with basic memory allocation and deallocation for modeling errors caused by accessing freed memory. Each reference records its target memory block when created, and the memory state tracks which blocks are allocated or freed. A reference is dangling if the block in its recorded address has been freed.
THEOREM 6.5 (BORROW CHECKING ENSURES TEMPORAL MEMORY SAFETY). Let prog be a Core MIR program that passes borrow checking, i.e., . For any reachable state of prog, its next step cannot access a reference whose recorded memory block has been freed.
The proof establishes a backward simulation from the extended semantics to the original borrow-aware semantics. The adequacy property and reference invalidation ensure that references are invalidated before their target blocks are freed, so any temporal memory error implies a borrow error. Soundness excludes such borrow (memory) errors in programs that pass borrow checking.
7 Rocq Formalization and Evaluation
Table 2 reports the lines of code of our Rocq development. We manually implemented the abstract interpreter and defined the borrow-aware semantics using CompCert's dataflow analysis [4, 21, 22]. The dataflow framework provides lattice libraries and a solver based on Kildall's algorithm [18], which we use to implement the abstract domains and the solver in Algorithm 1. For the correctness proof, we first developed a complete paper proof spanning roughly 100 pages, which is included in the technical report. We manually wrote all definitions, theorem statements, and proof outlines, and then used AI tools to refine the proofs by explicitly stating the goals to be proved, listing the assumptions, and detailing each derivation step following the proof outlines. This required substantial conceptual work, including the proof structure shown in Fig. 19. We then used Codex [30] with GPT-6 Astra to generate the Rocq proofs. This took about two weeks and went relatively smoothly, as most conceptual difficulties had already been resolved on paper. Our experience shows that LLMs can support large-scale verification
when guided by a clear proof structure. The paper proof allows us to focus on key arguments and establish a workable proof strategy without getting involved in tedious proof details. It also helps reduce errors during proof generation.
To evaluate whether our formalized borrow checker agrees with rustc's borrow checker, we implement a frontend that translates Rust source programs into our core MIR. We then test the borrow checker on 510 Rust programs drawn primarily from the borrowck and n11 suites of rustc [40] and the Polonius test suite [36]. We exclude tests that depend on unsupported features such as traits, closures, and unsafe code. We compare our results with those of rustc1.101.0 – nightly using -Zpolonius=next to enable the Polonius checker [11]. Our checker agrees with rustc's Polonius checker on 499 of the 510 programs (97.8%). Among the remaining 11 programs, four are accepted by Polonius but rejected by our checker, mainly due to unsupported features such as two-phase borrow [24] and smarter checking for dropping a Box [32]. The other seven are accepted by our checker but rejected by Polonius, mostly because rustc imposes stricter checks on region parameters in function signatures. Further details of the experiments are available in the submitted code.
Table 2. Size of the development
| Component | Lines |
|---|---|
| Abstract interpreter | 4,369 |
| Borrow-aware semantics | 1,454 |
| Correctness proof (generated) | |
| Soundness | 16,965 |
| Stacked AXM and adequacy | 38,740 |
| Memory safety | 5,232 |
| Total Rocq | 66,760 |
Jinhua Wu, Yuting Wang, and Zhemin Chen
Table 3. Description and comparison of existing work on static and dynamic borrow checking for Rust.
| Work on Borrow Checking | Model rustc's Algorithms | Interpretation of Borrowing | Techniques of Program Analysis | Program Property to Check/Prove |
|---|---|---|---|---|
| RustBelt [14] | ✗ | Resource Transfer | Type System | Semantic Type Safety |
| Aeneas [9, 10] | ✗ | Resource Transfer | Symbolic Execution | Safe Dynamic Borrowing |
| Oxide [50] | ✗ | Aliasing | Type System | Syntactic Type Safety |
| Stacked / Tree Borrows [13, 49] | ✗ | Aliasing | Dynamic Testing | Stacked/Tree AXM Discipline |
| This Work | ✓ | Aliasing | Abstract Interpretation | Stacked AXM Discipline |
8 Related Work and Conclusion
The success of Rust has stimulated growing research interest in borrow checking (see Table 3). Many works study the underlying principles of borrowing independently of the algorithms in rustc, often through type systems or symbolic execution. We discuss them below.
RustBelt. RustBelt [14] formalizes borrow checking as an ownership-based type system. It provides a semantic interpretation of the type system using the Iris framework [16, 17], interpreting the typing rules as rules in separation logic. Borrowing is modeled through a custom logic called lifetime logic, which defines a dynamic mechanism for transferring resources and specifying when they must be returned. We refer to this approach as modeling borrowing through resource transfer. RustBelt targets a language called that is different from MIR, and the type checking on still relies on explicit lifetime annotations provided by rustc's borrow checking.
Aeneas. Aeneas [9, 10] also adopts a resource transfer view of borrowing. It defines a semantics called LLBC to describe how values are temporarily moved and later returned through borrowing. From this semantics, Aeneas develops a borrow checker based on symbolic execution. LLBC uses loan identifiers to track the transfer and return of values. For example, the loan identifier below records that p borrows the value of v and allows the value to be returned when the borrow ends:
1 let mut v = 1; // LLBC: v ↔ 1; Ours: v ↔ 1
2 let mut p = &mut v; // LLBC: v ↔ loan^ℓ, p ↔ borrow^ℓ 1; Ours: v ↔ 1, p ↔ Ref^m v {v}
3 v = 2; // Borrow ends; LLBC: v ↔ 2, p ↔ ⊥; Ours: v ↔ 2, p ↔ Ref †
Our borrow-aware semantics uses a structured memory model similar to that of LLBC, but uses borrow sets instead of loan identifiers in references to track borrowing. We show that this change is key to providing a semantic interpretation of Polonius, as recovering borrow sets from loan identifiers is difficult. The work on LLBC's soundness [9] further presents a paper proof of a simulation between LLBC and a low-level semantics with a CompCert-based memory model. There is also ongoing work [33] on formalizing LLBC and its simulation proofs in Rocq.
Oxide. Oxide [50] proposes an alias-based type system for borrow checking, adopting a view similar to Polonius. Unlike our work, Oxide aims to provide a rich type system for surface Rust rather than directly modeling Polonius's analysis. For example, Oxide does not model Polonius's region equality for nested references, region parameters in composite data types, or heap allocation through Box. However, it supports higher-order functions, polymorphism, and move checking, which we do not cover. For soundness, Oxide proves type safety through preservation and progress over a conventional operational semantics that does not model the stacked AXM discipline.
Stacked/Tree Borrows. Stacked Borrows [13] defines a low-level semantics that uses pointer provenance to distinguish aliased pointers and maintains a borrow stack at each memory location to enforce the stacked AXM discipline. Tree Borrows [49] relaxes several restrictions of Stacked
Verified Implementation of the Next-gen Borrow Checking Algorithm for Rust via Abstract Interpretation
25
Borrows by replacing borrow stacks with trees, accepting more borrowing patterns. These works primarily focus on detecting undefined behavior arising from unsafe code [15], which is orthogonal to our goal of verifying borrow checking. We show that our borrow-aware semantics enforces a similar stacked AXM discipline, with the stack represented implicitly by the borrow order. This representation may also extend to tree structures. Establishing a simulation between our borrow-aware semantics and Stacked Borrows or Tree Borrows is a direction for future work.
Formalization of Polonius. Polonius was originally implemented in Datalog [36, 43], using constraints generated by rustc's NLL analysis. The Polonius developers also explored a forward-only formulation without liveness analysis [37]. Unlike their Datalog formulation, we implement forward-only Polonius as an abstract interpreter with a nontrivial abstract domain and transfer functions. The a-mir-formality project [38] formalizes MIR and models NLL and Polonius through inference rules written in Rust, aiming to provide a specification of borrow checking in rustc.
Other work on borrow checking. Featherweight Rust [31] is an early formalization of Rust's type system. It uses lexical lifetimes rather than the non-lexical lifetimes of NLL and Polonius. Its language excludes features such as function calls and enums. The Move borrow checker [28] uses regular expressions to track reference reachability in the Move language [3]. Move excludes features such as nested references and references stored in structs or enums. Under these restrictions, its memory-safety guarantee does not require the region-based analysis used by Polonius.
Work on Rust verification. Many Rust verification tools, including Verus [19], Prusti [2, 7], Creusot [6], RustHorn [27], Flux [20], and Thrust [29], use the guarantees provided by borrow checking to simplify memory reasoning and focus on functional correctness. We believe that our verified borrow checker can provide a formal foundation for this approach.
Conclusion. We have presented the first comprehensive verified implementation of the Polonius borrow checking algorithm for Rust. We observe that the essence of Polonius could be described via abstract interpretation, hence make its verification feasible. In the future, we plan to integrate this borrow checker into CompCert to build a fully verified compiler for a subset of Rust.
Data-Availability Statement
The technical report and Rocq formalization are available in the supplementary material. The technical report includes the full paper formalization and proofs. The Rocq formalization includes the borrow checker's source code and build scripts, the machine-checked correctness proof, and conformance tests. This paper is under submission and we will open source the code and technical reports after the submission.
References
[1] Lars Ole Andersen. 1994. Program analysis and specialization for the C programming language. Ph. D. Dissertation. University of Copenhagen. https://www.cs.cornell.edu/courses/cs711/2005fa/papers/andersen-thesis94.pdf [2] Vytautas Astrauskas, Peter Müller, Federico Poli, and Alexander J. Summers. 2019. Leveraging rust types for modular specification and verification. Proc. ACM Program. Lang. 3, OOPSLA, Article 147 (Oct. 2019), 30 pages. doi:10.1145/3360573 [3] Sam Blackshear, Evan Cheng, David L Dill, Victor Gao, Ben Maurer, Todd Nowacki, Alistair Pott, Shaz Qadeer, Dario Russi Rain, Stephane Sezer, et al. 2019. Move: A language with programmable resources. Libra Assoc 1 (2019). https://developers.diem.com/papers/diem-move-a-language-with-programmable-resources/2019-09-26.pdf [4] Sandrine Blazy, Vincent Laporte, André Maroneze, and David Pichardie. 2013. Formal Verification of a C Value Analysis Based on Abstract Interpretation. In Static Analysis, Francesco Logozzo and Manuel Fähndrich (Eds.). Springer Berlin Heidelberg, Berlin, Heidelberg, 324–344. [5] Will Crichton, Gavin Gray, and Shriram Krishnamurthi. 2023. A Grounded Conceptual Model for Ownership Types in Rust. Proc. ACM Program. Lang. 7, OOPSLA2, Article 265 (Oct. 2023), 29 pages. doi:10.1145/3622841
Jinhua Wu, Yuting Wang, and Zhemin Chen
[6] Xavier Denis, Jacques-Henri Jourdan, and Claude Marché. 2022. Creusot: A Foundry for the Deductive Verification of Rust Programs. In Formal Methods and Software Engineering: 23rd International Conference on Formal Engineering Methods, ICFEM 2022, Madrid, Spain, October 24–27, 2022, Proceedings (Madrid, Spain). Springer-Verlag, Berlin, Heidelberg, 90–105. doi:10.1007/978-3-031-17244-1_6
[7] Zachary Grannan, Aurel Bilý, Jonát Fiala, Jasper Geer, Markus de Medeiros, Peter Müller, and Alexander J. Summers. 2025. Place Capability Graphs: A General-Purpose Model of Rust's Ownership and Borrowing Guarantees. Proc. ACM Program. Lang. 9, OOPSLA2, Article 344 (Oct. 2025), 28 pages. doi:10.1145/3763122
[8] Michael Hind. 2001. Pointer analysis: haven't we solved this problem yet?. In Proceedings of the 2001 ACM SIGPLAN-SIGSOFT Workshop on Program Analysis for Software Tools and Engineering (Snowbird, Utah, USA) (PASTE '01). Association for Computing Machinery, New York, NY, USA, 54–61. doi:10.1145/379605.379665
[9] Son Ho, Aymeric Fromherz, and Jonathan Protzenko. 2024. Sound Borrow-Checking for Rust via Symbolic Semantics. Proc. ACM Program. Lang. 8, ICFP, Article 251 (Aug. 2024), 29 pages. doi:10.1145/3674640
[10] Son Ho and Jonathan Protzenko. 2022. Aeneas: Rust verification by functional translation. Proc. ACM Program. Lang. 6, ICFP, Article 116 (Aug. 2022), 31 pages. doi:10.1145/3547647
[11] Jack Huey. 2026. Enabling the Next Iteration of the Borrow Checker on Nightly. https://blog.rust-lang.org/2026/08/04/enabling-polonius-alpha-on-nightly/
[12] Jacques-Henri Jourdan, Vincent Laporte, Sandrine Blazy, Xavier Leroy, and David Pichardie. 2015. A Formally-Verified C Static Analyzer. In Proceedings of the 42nd Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (Mumbai, India) (POPL '15). Association for Computing Machinery, New York, NY, USA, 247–259. doi:10.1145/2676726.2676966
[13] Ralf Jung, Hoang-Hai Dang, Jeehoon Kang, and Derek Dreyer. 2019. Stacked borrows: an aliasing model for Rust. Proc. ACM Program. Lang. 4, POPL, Article 41 (Dec. 2019), 32 pages. doi:10.1145/3371109
[14] Ralf Jung, Jacques-Henri Jourdan, Robert Krebbers, and Derek Dreyer. 2017. RustBelt: securing the foundations of the Rust programming language. Proc. ACM Program. Lang. 2, POPL, Article 66 (Dec. 2017), 34 pages. doi:10.1145/3158154
[15] Ralf Jung, Benjamin Kimock, Christian Poveda, Eduardo Sánchez Muñoz, Oli Scherer, and Qian Wang. 2026. Miri: Practical Undefined Behavior Detection for Rust. Proc. ACM Program. Lang. 10, POPL, Article 48 (Jan. 2026), 29 pages. doi:10.1145/3776690
[16] RALF JUNG, ROBERT KREBBERS, JACQUES-HENRI JOURDAN, ALES BIZJAK, LARS BIRKEDAL, and DEREK DREYER. 2018. Iris from the ground up: A modular foundation for higher-order concurrent separation logic. Journal of Functional Programming 28 (2018), e20. doi:10.1017/S0956796818000151
[17] Ralf Jung, David Swasey, Filip Sieczkowski, Kesper Svendsen, Aaron Turon, Lars Birkedal, and Derek Dreyer. 2015. Iris: Monoids and Invariants as an Orthogonal Basis for Concurrent Reasoning. In Proc. 42nd ACM Symposium on Principles of Programming Languages (POPL '15). 637–650.
[18] Gary A. Kildall. 1973. A unified approach to global program optimization. In Proceedings of the 1st Annual ACM SIGACT-SIGPLAN Symposium on Principles of Programming Languages (Boston, Massachusetts) (POPL '73). Association for Computing Machinery, New York, NY, USA, 194–206. doi:10.1145/512927.512945
[19] Andrea Lattuada, Travis Hance, Chanhee Cho, Matthias Brun, Isitha Subasinghe, Yi Zhou, Jon Howell, Bryan Parno, and Chris Hawblitzel. 2023. Verus: Verifying Rust Programs using Linear Ghost Types. Proc. ACM Program. Lang. 7, OPSLA1, Article 85 (April 2023), 30 pages. doi:10.1145/3586037
[20] Nico Lehmann, Adam T. Geller, Niki Vazou, and Ranjit Jhala. 2023. Flux: Liquid Types for Rust. Proc. ACM Program. Lang. 7, PLDI, Article 169 (June 2023), 25 pages. doi:10.1145/3591283
[21] Xavier Leroy. 2009. Formal Verification of a Realistic Compiler. Commun. ACM 52, 7 (2009), 107–115. doi:10.1145/1538788.1538814
[22] Xavier Leroy. 2009. A Formally Verified Compiler Back-end. Journal of Automated Reasoning 43, 4 (2009), 363–446. doi:10.1007/s10817-009-9155-4
[23] Xavier Leroy, Andrew W. Appel, Sandrine Blazy, and Gordon Stewart. 2012. The CompCert Memory Model, Version 2. Research Report RR-7987. INRIA. 26 pages. https://hal.inria.fr/hal-00703441
[24] Niko Matsakis. 2017. RFC 2025: Enable Nested Method Calls. The Rust RFC Book. https://rust-lang.github.io/rfc5/2025-nested-method-calls.html
[25] Niko Matsakis. 2018. An alias-based formulation of the borrow checker. https://smallcultfollowing.com/babysteps/blog/2018/04/27/an-alias-based-formulation-of-the-borrow-checker/
[26] Niko Matsakis. 2019. Polonius and region errors. https://smallcultfollowing.com/babysteps/blog/2019/01/17/polonius-and-region-errors/
[27] Yusuke Matsushita, Takeshi Tsukada, and Naoki Kobayashi. 2021. RustHorn: CHC-based Verification for Rust Programs. ACM Trans. Program. Lang. Syst. 43, 4, Article 15 (Oct. 2021), 54 pages. doi:10.1145/3462205
[28] Todd Nowacki, Sam Blackshear, John Mitchell, Shaz Qadeer, and Ilya Sergey. 2026. Tracking Borrows with Regular Expressions. Proc. ACM Program. Lang. 10, OOPSLA2, Article 389 (Oct. 2026), 27 pages. doi:10.1145/3839521
Verified Implementation of the Next-gen Borrow Checking Algorithm for Rust via Abstract Interpretation
27
[29] Hiromi Ogawa, Taro Sekiyama, and Hiroshi Unno. 2025. Thrust: A Prophecy-Based Refinement Type System for Rust. Proc. ACM Program. Lang. 9, PLDI, Article 230 (June 2025), 25 pages. doi:10.1145/3729333
[30] OpenAI. 2026. Codex: A Lightweight Coding Agent That Runs in Your Terminal. https://github.com/openai/codex.
[31] David J. Pearce. 2021. A Lightweight Formalism for Reference Lifetimes and Borrowing in Rust. ACM Trans. Program. Lang. Syst. 43, 1, Article 3 (April 2021), 73 pages. doi:10.1145/3443420
[32] pnkfelix. 2018. [NLL] Dangly paths for box #52782. https://github.com/rust-lang/rust/pull/52782
[33] Alban Reynaud Michez. 2026. Formal Verification of Borrow-Checking by Local Commutation Diagrams. In JFLA 2026 – 37es Journées Francophones des Langages Applicatifs, Marie Kerjean and Yannick Zakowski (Eds.). Oberbronn, Alsace, France. https://hal.science/hal-05428143 hal-05428143v2.
[34] Rust Compiler Team. 2015. The Rust RFC Book: 1211-mir. https://rust-lang.github.io/rfcs/1211-mir.html
[35] Rust Compiler Team. 2026. Move paths. https://rustc-dev-guide.rust-lang.org/borrow-check/moves-and-initialization/move-paths.html
[36] Rust contributors. 2019. Defines the Rust borrow checker. https://github.com/rust-lang/polonius
[37] Rust contributors. 2021. polonius.next: experimental datalog rules for a next gen polonius. https://github.com/nikomatsakis/polonius.next/tree/reintroduce-leases
[38] Rust contributors. 2026. a-mir-formality: a model of MIR and the Rust type/trait system. https://github.com/rust-lang/a-mir-formality
[39] Rust contributors. 2026. Implementation of Polonius in Rust compiler. https://github.com/rust-lang/rust/tree/main/compiler/rustc_borrowck/src/polonius
[40] Rust contributors. 2026. The Rust compiler test suites. https://github.com/rust-lang/rust/tree/main/tests/ui
[41] Rémy Rakic and Niko Matsakis on behalf of The Polonius Working Group. 2023. Polonius Update. https://blog.rust-lang.org/inside-rust/2023/10/06/polonius-update.html
[42] soulwa. 2020. Better documentation of reborrowing. GitHub issue #788, rust-lang/reference. https://github.com/rust-lang/reference/issues/788
[43] Amanda Stjerna. 2020. Modelling Rust's Reference Ownership Analysis Declaratively in Datalog. Master's thesis. Uppsala University, Department of Information Technology.
[44] The Rust Team. 2017. Non-Lexical Lifetimes. https://rust-lang.github.io/rfcs/2094-nll.html
[45] The Chromium Projects. [n.d.]. Memory Safety. Chromium Security. https://www.chromium.org/Home/chromium-security/memory-safety/
[46] The Rust Team. 2025. Subtyping and Variance. https://doc.rust-lang.org/nomicon/subtyping.html
[47] The Rust Team. 2026. The Rust Programming Language. https://rust-lang.org/
[48] Gavin Thomas. 2019. A Proactive Approach to More Secure Code. Microsoft Security Response Center Blog. https://www.microsoft.com/en-us/msrc/blog/2019/07/a-proactive-approach-to-more-secure-code
[49] Neven Villani, Johannes Hostert, Derek Dreyer, and Ralf Jung. 2025. Tree Borrows. Proc. ACM Program. Lang. 9, PLDI, Article 188 (June 2025), 24 pages. doi:10.1145/3735592
[50] Aaron Weiss, Olek Gierczak, Daniel Patterson, and Amal Ahmed. 2019. Oxide: The essence of rust. arXiv preprint arXiv:1903.00982 (2019).