Skip to content

Commit 8c27c7e

Browse files
committed
test(prove-rs): add subslice-drop-unsupported-fail repro
Add integration test for Subslice projection on an owned array of Drop types. The `let [first, rest @ ..]` pattern generates a Subslice that changes the type from [Droppable; 3] to [Droppable; 2], exercising an unsupported code path in _projected_ty() and K semantics. Marked as expected-fail with show snapshot.
1 parent 60b5e5a commit 8c27c7e

3 files changed

Lines changed: 78 additions & 0 deletions

File tree

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
2+
┌─ 1 (root, init)
3+
│ #execTerminator ( terminator ( ... kind: terminatorKindCall ( ... func: operandC
4+
│ span: 0
5+
6+
│ (90 steps)
7+
├─ 3
8+
│ #setLocalValue ( place ( ... local: local ( 1 ) , projection: .ProjectionElems )
9+
│ function: main
10+
│ span: 64
11+
12+
│ (4 steps)
13+
├─ 4
14+
│ #execStmt ( statement ( ... kind: statementKindAssign ( ... place: place ( ... l
15+
│ function: main
16+
│ span: 64
17+
18+
┃ (1 step)
19+
┣━━┓
20+
┃ │
21+
┃ ├─ 5
22+
┃ │ #setLocalValue ( place ( ... local: local ( 7 ) , projection: .ProjectionElems )
23+
┃ │ function: main
24+
┃ │ span: 54
25+
┃ │
26+
┃ │ (2 steps)
27+
┃ └─ 8 (vacuous, leaf)
28+
┃ operandCopy ( place ( ... local: local ( 5 ) , projection: projectionElemField (
29+
┃ function: main
30+
┃ span: 54
31+
32+
┣━━┓
33+
┃ │
34+
┃ ├─ 6
35+
┃ │ #setLocalValue ( place ( ... local: local ( 7 ) , projection: .ProjectionElems )
36+
┃ │ function: main
37+
┃ │ span: 54
38+
┃ │
39+
┃ │ (1 step)
40+
┃ └─ 9 (vacuous, leaf)
41+
┃ #evalUnion ( rvalueUse ( operandCopy ( place ( ... local: local ( 5 ) , projecti
42+
┃ function: main
43+
┃ span: 54
44+
45+
┗━━┓
46+
47+
└─ 7 (stuck, leaf)
48+
#execStmt ( statement ( ... kind: statementKindAssign ( ... place: place ( ... l
49+
function: main
50+
span: 64
51+
52+
53+
┌─ 2 (root, leaf, target, terminal)
54+
│ #EndProgram ~> .K
55+
56+
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Reproducer: Subslice projection on an array of Drop types.
2+
//
3+
// `let [first, rest @ ..] = arr` generates a Subslice projection that
4+
// changes the type from [Droppable; 3] to [Droppable; 2]. The SMIR
5+
// linker's _projected_ty() currently returns the original array type
6+
// for Subslice, which could cause drop-glue mis-resolution when
7+
// Subslice projections appear in Drop terminator places.
8+
9+
struct Droppable(u8);
10+
11+
impl Drop for Droppable {
12+
fn drop(&mut self) {}
13+
}
14+
15+
fn main() {
16+
let arr = [Droppable(1), Droppable(2), Droppable(3)];
17+
let [first, rest @ ..] = arr;
18+
assert!(first.0 == 1);
19+
assert!(rest[0].0 == 2);
20+
assert!(rest[1].0 == 3);
21+
}

kmir/src/tests/integration/test_integration.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070
'ptr-cast-array-to-nested-wrapper-fail',
7171
'ptr-cast-array-to-singleton-wrapped-array-fail',
7272
'iterator-simple-fail',
73+
'subslice-drop-unsupported-fail',
7374
]
7475

7576

0 commit comments

Comments
 (0)