Disallow accesses through an Index projection when a sibling ConstantIndex projection has been moved out of - #160780
Disallow accesses through an Index projection when a sibling ConstantIndex projection has been moved out of#160780beepster4096 wants to merge 2 commits into
Conversation
…ons to be overlapping in some cases
|
Some changes occurred to MIR optimizations cc @rust-lang/wg-mir-opt |
|
r? @oli-obk rustbot has assigned @oli-obk. Use Why was this reviewer chosen?The reviewer was selected based on:
|
| mpi: MovePathIndex, | ||
|
|
||
| /// The PlaceElem in the place immediately projecting from the parent move path. | ||
| next_elem: PlaceElem<'tcx>, |
There was a problem hiding this comment.
Should this be a ProjectionKind?
There was a problem hiding this comment.
Yeah, makes more sense considering the variant is the only info used right now
| // 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 |
There was a problem hiding this comment.
Could we match exhaustively on next_elem?
|
While this is a soundness fix where we're def landing it, let's still crater it and inform any potentially broken crates. @bors try |
This comment has been minimized.
This comment has been minimized.
Disallow accesses through an Index projection when a sibling ConstantIndex projection has been moved out of
|
@craterbot check |
|
👌 Experiment ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more |
Fixes #160525
LookupResultenum returned byMovePathLookup::find:LookupResult::Parent(None)case is now a separate variant,LookupResult::NoneLookupResult::Parenthas an additional field containing the variant immediately following the parent move path.check_if_full_path_is_movednow checks that new field and if it isPlaceElem::Index, it makes sure there are no uninit descendants of the indexed array's move path (which can only beConstantIndexand descendants of those.)move_path_closest_tois removed and inlined intocheck_if_full_path_is_moved.