Skip to content

Commit 9e3b484

Browse files
committed
Auto merge of #147884 - matthiaskrgr:rollup-pjqcccz, r=matthiaskrgr
Rollup of 4 pull requests Successful merges: - rust-lang/rust#147575 (Refactor move analysis subpath representation) - rust-lang/rust#147864 (Parse `const unsafe trait` properly) - rust-lang/rust#147868 (MirPatch: Simplify new_local.) - rust-lang/rust#147873 (comments for deduce_param_attrs) r? `@ghost` `@rustbot` modify labels: rollup
2 parents ac94a0a + 16cf6e2 commit 9e3b484

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/borrow_check/moves_and_initialization/move_paths.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,6 @@ We don't actually create a move-path for **every** [`Place`] that gets
6767
used. In particular, if it is illegal to move from a [`Place`], then
6868
there is no need for a [`MovePathIndex`]. Some examples:
6969

70-
- You cannot move from a static variable, so we do not create a [`MovePathIndex`]
71-
for static variables.
7270
- You cannot move an individual element of an array, so if we have e.g. `foo: [String; 3]`,
7371
there would be no move-path for `foo[1]`.
7472
- You cannot move from inside of a borrowed reference, so if we have e.g. `foo: &String`,
@@ -82,6 +80,18 @@ initialized (which lowers overhead).
8280

8381
[`move_path_for`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_mir_dataflow/move_paths/builder/struct.MoveDataBuilder.html#method.move_path_for
8482

83+
## Projections
84+
85+
Instead of using [`PlaceElem`], projections in move paths are stored as [`MoveSubPath`]s.
86+
Projections that can't be moved out of and projections that can be skipped are not represented.
87+
88+
Subslice projections of arrays (produced by slice patterns) are special; they're turned into
89+
multiple [`ConstantIndex`] subpaths, one for each element in the subslice.
90+
91+
[`PlaceElem`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/mir/type.PlaceElem.html
92+
[`MoveSubPath`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_mir_dataflow/move_paths/enum.MoveSubPath.html
93+
[`ConstantIndex`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_mir_dataflow/move_paths/enum.MoveSubPath.html#variant.ConstantIndex
94+
8595
## Looking up a move-path
8696

8797
If you have a [`Place`] and you would like to convert it to a [`MovePathIndex`], you

0 commit comments

Comments
 (0)