Skip to content

Commit 3bfd712

Browse files
authored
Rollup merge of rust-lang#147575 - beepster4096:movesubpath, r=oli-obk
Refactor move analysis subpath representation Follow up to rust-lang#147055 This PR does two things: 1. Document/validate move analysis's assumptions about `Subslice` projections 2. Decouple move paths from `ProjectionElem`, using a new enum `MoveSubPath` instead - This would be needed eventually when `ProjectionElem::Deref` is removed I wanted to do even more abstraction, making `MovePathLookup::find` return an iterator to remove the special handling of subslices in borrowck, but that regressed diagnostics and just wasn't worth the complexity.
2 parents 33cab8c + bce7f71 commit 3bfd712

File tree

5 files changed

+341
-195
lines changed

5 files changed

+341
-195
lines changed

compiler/rustc_middle/src/mir/syntax.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ pub enum RuntimePhase {
137137
/// And the following variants are allowed:
138138
/// * [`StatementKind::Retag`]
139139
/// * [`StatementKind::SetDiscriminant`]
140+
/// * [`PlaceElem::ConstantIndex`] / [`PlaceElem::Subslice`] after [`PlaceElem::Subslice`]
140141
///
141142
/// Furthermore, `Copy` operands are allowed for non-`Copy` types.
142143
Initial = 0,
@@ -1246,6 +1247,9 @@ pub enum ProjectionElem<V, T> {
12461247
///
12471248
/// If `from_end` is true `slice[from..slice.len() - to]`.
12481249
/// Otherwise `array[from..to]`.
1250+
///
1251+
/// This projection cannot have `ConstantIndex` or additional `Subslice` projections after it
1252+
/// before runtime MIR.
12491253
Subslice {
12501254
from: u64,
12511255
to: u64,

0 commit comments

Comments
 (0)