Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Rules for the Creation of Borrows

Mutable Borrows

Consider the stmt p = &mut q, at a program point , where has type , and has type , and is a type containing lifetimes .

At the end of the PreOperands phase, the PCG is guaranteed to be in a state where, for each the lifetime projection is in the graph. During the Operands phase, each lifetime projection is labelled with the current program point to become . At the end of the PreMain phase, for each , the lifetime projection is guaranteed not to be in the graph. During the Main phase, these projections are added.

Subsequently, the labelled lifetime projections under are connected with BorrowFlow edges to the new lifetime projections under . Namely, for each if outlives , then a BorrowFlow edge is added.

Subsequently, we introduce Future nodes and edges to account for nested references as follows. For each :

  1. Insert the node into the graph
  2. If any Future edges originate from the labelled projection , redirect them such that they originate from .
  3. Insert a Future edge
  4. Insert a Future edge