Tree Borrows
Tree Borrows



 This document replaces the pre-2023-10-20
version that did not yet include the updates from the two latest PRs in Miri For
completeness you can still find the unedited version here. If you don’t
know Tree Borrows yet, you’re in the right place. If you are familiar
with Tree Borrows and want to know only what changed and why, you may
consult the diff. 

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

Part 1: Core Model (mutable references and
accesses)
Part 2: Sharing Data (shared
references)
Part 3: Introducing Protectors
(function calls and the noalias attribute)
Part 4: Dealing with Cells (interior
mutability)
Part 5: Ranges (extern type
and pointer offsets)

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



