AK/Wri/Rust With Receipts

Rust with receipts

2 min read

RUST
fn main() {
    let mut v = vec![1, 2, 3];
    let r = &v;
    v.push(4); // error[E0502]: cannot borrow `v` as mutable because it is also borrowed as immutable
    println!("{r:?}");
}

rustc rejects this before your binary exists. most of us treat that as the end of the story.

RustCompCert asks a louder question: can the compiler itself carry a proof that its transformations never introduce behaviors your source program did not already allow — and that borrow checking really means what we think it means?

not "we tested release builds for a year." a theorem in Rocq that links source semantics to assembly.

descending the stack

your .rs file
    ↓  parser (unverified today)
Rustlight  — sequential Rust subset, formalized in Rocq
    ↓  Drop elaboration
    ↓  Borrow checking  ← proof obligation lives here
Clight
    ↓  CompCert backend (already verified for C)
assembly

Each arrow is a compilation pass. Most compilers hope passes preserve meaning. RustCompCert wants refinement proofs between steps: every behavior the assembly can produce was already possible in Rustlight, modulo the stated subset.

The borrow checker is not a lint pass in this story. it is a verifying compiler phase. if it accepts your program, you get a machine-checked link between high-level ownership rules and the low-level memory model CompCert reasons about.

two guarantees, named separately

guaranteeplain english
semantics preservationverified properties on source code still hold after optimization
verifying compilationmemory safety enforced by borrow check is sound relative to the formal memory model

Second row is what lets tools like Creusot, Prusti, Aeneas, and Verus spend their energy on functional correctness. they do not re-prove "no use-after-free" from scratch on every project if the compiler pipeline is already wired for it.

what is in scope (for now)

honest limits keep the project credible:

  • sequential subset of Rust, not full async + atomics soup
  • parser still unverified — trust starts at Rustlight
  • ongoing work to connect the Rocq frontend to CompCertO for compositional linking

That is still enormous. CompCert took years to earn trust for C. Rust adds move semantics, drops, lifetimes, and the borrow graph on top.

why bother when rustc ships weekly?

because the industry keeps compiling safety-critical Rust without a end-to-end proof chain. kernels, crypto runtimes, embedded controllers. we already write the careful code. we still deploy through a black box of LLVM passes and hope -C opt-level=3 did not smuggle in a surprise.

a verified path does not replace rustc for apps. it gives a parallel track where "cargo build" is not the last word — a proof artifact is.

one line to keep

trust the borrow checker? fine. trust the compiler that enforces it? that is the next upgrade.