|
| 1 | +//! Polonius analysis and support code: |
| 2 | +//! - dedicated constraints |
| 3 | +//! - conversion from NLL constraints |
| 4 | +//! - debugging utilities |
| 5 | +//! - etc. |
| 6 | +//! |
| 7 | +//! The current implementation models the flow-sensitive borrow-checking concerns as a graph |
| 8 | +//! containing both information about regions and information about the control flow. |
| 9 | +//! |
| 10 | +//! Loan propagation is seen as a reachability problem (with some subtleties) between where the loan |
| 11 | +//! is introduced and a given point. |
| 12 | +//! |
| 13 | +//! Constraints arising from type-checking allow loans to flow from region to region at the same CFG |
| 14 | +//! point. Constraints arising from liveness allow loans to flow within from point to point, between |
| 15 | +//! live regions at these points. |
| 16 | +//! |
| 17 | +//! Edges can be bidirectional to encode invariant relationships, and loans can flow "back in time" |
| 18 | +//! to traverse these constraints arising earlier in the CFG. |
| 19 | +//! |
| 20 | +//! When incorporating kills in the traversal, the loans reaching a given point are considered live. |
| 21 | +//! |
| 22 | +//! After this, the usual NLL process happens. These live loans are fed into a dataflow analysis |
| 23 | +//! combining them with the points where loans go out of NLL scope (the frontier where they stop |
| 24 | +//! propagating to a live region), to yield the "loans in scope" or "active loans", at a given |
| 25 | +//! point. |
| 26 | +//! |
| 27 | +//! Illegal accesses are still computed by checking whether one of these resulting loans is |
| 28 | +//! invalidated. |
| 29 | +//! |
| 30 | +//! More information on this simple approach can be found in the following links, and in the future |
| 31 | +//! in the rustc dev guide: |
| 32 | +//! - <https://smallcultfollowing.com/babysteps/blog/2023/09/22/polonius-part-1/> |
| 33 | +//! - <https://smallcultfollowing.com/babysteps/blog/2023/09/29/polonius-part-2/> |
| 34 | +//! |
| 35 | +
|
1 | 36 | mod constraints;
|
2 | 37 | pub(crate) use constraints::*;
|
3 | 38 |
|
|
0 commit comments