Skip to content

Commit 8a59eed

Browse files
committed
test(smir): reproduce _projected_ty Subslice drop-glue pruning bug
Add unit test demonstrating that _projected_ty() returns the original array type for Subslice projections, causing call_edges to miss the drop_in_place::<[T; M]> edge and reduce_to() to incorrectly prune the required drop glue. Add integration test subslice-drop-partial-move.rs that generates Drop(arr.Subslice(1,3,false)) in the MIR — the exact pattern described in the Codex review comment.
1 parent 662427f commit 8a59eed

3 files changed

Lines changed: 3992 additions & 0 deletions

File tree

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Subslice projection in a Drop terminator's place.
2+
//
3+
// `let [first, ..] = arr` moves only `first`; the remaining elements
4+
// are dropped in place via Drop(arr.Subslice(1, 3, false)).
5+
// This exercises _projected_ty() resolving the Subslice to the correct
6+
// [Droppable; 2] type so reduce_to() preserves the drop glue.
7+
8+
struct Droppable(u8);
9+
10+
impl Drop for Droppable {
11+
fn drop(&mut self) {}
12+
}
13+
14+
fn consume(_: Droppable) {}
15+
16+
fn main() {
17+
let arr = [Droppable(1), Droppable(2), Droppable(3)];
18+
let [first, ..] = arr;
19+
consume(first);
20+
}

0 commit comments

Comments
 (0)