Skip to content

Disallow accesses through an Index projection when a sibling ConstantIndex projection has been moved out of - #160780

Open
beepster4096 wants to merge 1 commit into
rust-lang:mainfrom
beepster4096:overlapping_move_paths
Open

Disallow accesses through an Index projection when a sibling ConstantIndex projection has been moved out of#160780
beepster4096 wants to merge 1 commit into
rust-lang:mainfrom
beepster4096:overlapping_move_paths

Conversation

@beepster4096

@beepster4096 beepster4096 commented Aug 8, 2026

Copy link
Copy Markdown
Contributor
  • I did not use an LLM to create a change in this PR.
  • I used an LLM to create a change in this PR, and I have explained below how it was used.

Fixes #160525

  • Refactored the LookupResult enum returned by MovePathLookup::find:
    • The LookupResult::Parent(None) case is now a separate variant, LookupResult::None
    • LookupResult::Parent has an additional field containing the variant immediately following the parent move path.
  • Borrowck's check_if_full_path_is_moved now checks that new field and if it is PlaceElem::Index, it makes sure there are no uninit descendants of the indexed array's move path (which can only be ConstantIndex and descendants of those.)
    • move_path_closest_to is removed and inlined into check_if_full_path_is_moved.

@rustbot

rustbot commented Aug 8, 2026

Copy link
Copy Markdown
Collaborator

Some changes occurred to MIR optimizations

cc @rust-lang/wg-mir-opt

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Aug 8, 2026
@rustbot

rustbot commented Aug 8, 2026

Copy link
Copy Markdown
Collaborator

r? @oli-obk

rustbot has assigned @oli-obk.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: borrowck, compiler
  • borrowck, compiler expanded to 75 candidates
  • Random selection from 19 candidates

mpi: MovePathIndex,

/// The PlaceElem in the place immediately projecting from the parent move path.
next_elem: PlaceElem<'tcx>,

@cjgillot cjgillot Aug 9, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be a ProjectionKind?

View changes since the review

// Subslice and ConstantIndex projections of slices also overlap siblings,
// but the parent slice will never have a move path
// Subslice projections of arrays are specifically checked in `check_if_subslice_element_is_moved`
LookupResult::Parent { mpi, next_elem: PlaceElem::Index(..) } => self

@cjgillot cjgillot Aug 9, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we match exhaustively on next_elem?

View changes since the review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ConstantIndex and Index not flagged as potential aliases

4 participants