|
1 | 1 | # Move paths
|
2 | 2 |
|
3 | 3 | In reality, it's not enough to track initialization at the granularity
|
4 |
| -of local variables. Sometimes we need to track, e.g., individual fields: |
| 4 | +of local variables. Rust also allows us to do moves and initialization |
| 5 | +at the field granularity: |
5 | 6 |
|
6 | 7 | ```rust
|
7 | 8 | fn foo() {
|
@@ -63,9 +64,9 @@ later section.
|
63 | 64 |
|
64 | 65 | ### Illegal move paths
|
65 | 66 |
|
66 |
| -We don't actually move-paths for **every** [`Place`] that gets used. |
67 |
| -In particular, if it is illegal to move from a [`Place`], then there |
68 |
| -is no need for a [`MovePathIndex`]. Some examples: |
| 67 | +We don't actually create a move-path for **every** [`Place`] that gets |
| 68 | +used. In particular, if it is illegal to move from a [`Place`], then |
| 69 | +there is no need for a [`MovePathIndex`]. Some examples: |
69 | 70 |
|
70 | 71 | - You cannot move from a static variable, so we do not create a [`MovePathIndex`]
|
71 | 72 | for static variables.
|
@@ -115,11 +116,12 @@ they are also structured into a tree. So for example if you have the
|
115 | 116 | [`MovePathIndex`] for `a.b.c`, you can go to its parent move-path
|
116 | 117 | `a.b`. You can also iterate over all children paths: so, from `a.b`,
|
117 | 118 | you might iterate to find the path `a.b.c` (here you are iterating
|
118 |
| -just over the paths that the user **actually referenced**, not all |
119 |
| -**possible** paths the user could have done). These references are |
120 |
| -used for example in the [`has_any_child_of`] function, which checks |
121 |
| -whether the dataflow results contain a value for the given move-path |
122 |
| -(e.g., `a.b`) or any child of that move-path (e.g., `a.b.c`). |
| 119 | +just over the paths that are **actually referenced** in the source, |
| 120 | +not all **possible** paths that could have been referenced). These |
| 121 | +references are used for example in the [`has_any_child_of`] function, |
| 122 | +which checks whether the dataflow results contain a value for the |
| 123 | +given move-path (e.g., `a.b`) or any child of that move-path (e.g., |
| 124 | +`a.b.c`). |
123 | 125 |
|
124 | 126 | [`Place`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc/mir/enum.Place.html
|
125 | 127 | [`has_any_child_of`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_mir/dataflow/at_location/struct.FlowAtLocation.html#method.has_any_child_of
|
|
0 commit comments