Tree Borrows

A new aliasing model for Rust

Neven Villani

Mar. 2023

This document has been updated on 2023-10-20 in favor of the newer version that includes the two recent PRs to Miri. You may still read here the original version, but a better idea would be to consult the updated writeup if you don’t know Tree Borrows yet, and the exact diff between the two versions if you are familiar with Tree Borrows and want to know only what changed and why.

Tree Borrows is a proposed alternative to Stacked Borrows that fulfills the same role: to analyse the execution of Rust code at runtime and define the precise requirements of the aliasing constraints. When these aliasing constraints are violated, the code is declared Undefined Behavior (UB). This enables optimizations that would otherwise be unsound in the presence of unsafe code.


The current version of Tree Borrows is implemented in the Miri interpreter. Compared to another description, this document is more example-oriented.

Table of contents

See also some References. Suggest modifications to this document by opening a pull request.