Skip to content

Commit e1a727e

Browse files
committed
Add a mir-opt test for drop shims of arrays
1 parent b57d93d commit e1a727e

File tree

2 files changed

+57
-0
lines changed

2 files changed

+57
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
// MIR for `std::ptr::drop_in_place` before AddMovesForPackedDrops
2+
3+
fn std::ptr::drop_in_place(_1: *mut [String; 42]) -> () {
4+
let mut _0: ();
5+
let mut _2: usize;
6+
let mut _3: usize;
7+
let mut _4: *mut std::string::String;
8+
let mut _5: bool;
9+
let mut _6: *mut std::string::String;
10+
let mut _7: bool;
11+
12+
bb0: {
13+
goto -> bb8;
14+
}
15+
16+
bb1: {
17+
return;
18+
}
19+
20+
bb2 (cleanup): {
21+
resume;
22+
}
23+
24+
bb3 (cleanup): {
25+
_4 = &raw mut (*_1)[_3];
26+
_3 = Add(move _3, const 1_usize);
27+
drop((*_4)) -> [return: bb4, unwind terminate(cleanup)];
28+
}
29+
30+
bb4 (cleanup): {
31+
_5 = Eq(copy _3, copy _2);
32+
switchInt(move _5) -> [0: bb3, otherwise: bb2];
33+
}
34+
35+
bb5: {
36+
_6 = &raw mut (*_1)[_3];
37+
_3 = Add(move _3, const 1_usize);
38+
drop((*_6)) -> [return: bb6, unwind: bb4];
39+
}
40+
41+
bb6: {
42+
_7 = Eq(copy _3, copy _2);
43+
switchInt(move _7) -> [0: bb5, otherwise: bb1];
44+
}
45+
46+
bb7: {
47+
_2 = Len((*_1));
48+
_3 = const 0_usize;
49+
goto -> bb6;
50+
}
51+
52+
bb8: {
53+
goto -> bb7;
54+
}
55+
}

tests/mir-opt/slice_drop_shim.rs

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
// if we use -Clink-dead-code.
66

77
// EMIT_MIR core.ptr-drop_in_place.[String].AddMovesForPackedDrops.before.mir
8+
// EMIT_MIR core.ptr-drop_in_place.[String;42].AddMovesForPackedDrops.before.mir
89
fn main() {
910
let _fn = std::ptr::drop_in_place::<[String]> as unsafe fn(_);
11+
let _fn = std::ptr::drop_in_place::<[String; 42]> as unsafe fn(_);
1012
}

0 commit comments

Comments
 (0)