Skip to content

Commit 341e0f7

Browse files
committed
Fortify codegen test.
1 parent 05b82e5 commit 341e0f7

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

tests/codegen/slice-init.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ pub fn zero_sized_elem() {
88
// CHECK-NOT: br label %repeat_loop_header{{.*}}
99
// CHECK-NOT: call void @llvm.memset.p0
1010
let x = [(); 4];
11-
drop(&x);
11+
opaque(&x);
1212
}
1313

1414
// CHECK-LABEL: @zero_len_array
@@ -17,7 +17,7 @@ pub fn zero_len_array() {
1717
// CHECK-NOT: br label %repeat_loop_header{{.*}}
1818
// CHECK-NOT: call void @llvm.memset.p0
1919
let x = [4; 0];
20-
drop(&x);
20+
opaque(&x);
2121
}
2222

2323
// CHECK-LABEL: @byte_array
@@ -26,7 +26,7 @@ pub fn byte_array() {
2626
// CHECK: call void @llvm.memset.{{.+}}({{i8\*|ptr}} {{.*}}, i8 7, i{{[0-9]+}} 4
2727
// CHECK-NOT: br label %repeat_loop_header{{.*}}
2828
let x = [7u8; 4];
29-
drop(&x);
29+
opaque(&x);
3030
}
3131

3232
#[allow(dead_code)]
@@ -42,7 +42,7 @@ pub fn byte_enum_array() {
4242
// CHECK: call void @llvm.memset.{{.+}}({{i8\*|ptr}} {{.*}}, i8 {{.*}}, i{{[0-9]+}} 4
4343
// CHECK-NOT: br label %repeat_loop_header{{.*}}
4444
let x = [Init::Memset; 4];
45-
drop(&x);
45+
opaque(&x);
4646
}
4747

4848
// CHECK-LABEL: @zeroed_integer_array
@@ -51,7 +51,7 @@ pub fn zeroed_integer_array() {
5151
// CHECK: call void @llvm.memset.{{.+}}({{i8\*|ptr}} {{.*}}, i8 0, i{{[0-9]+}} 16
5252
// CHECK-NOT: br label %repeat_loop_header{{.*}}
5353
let x = [0u32; 4];
54-
drop(&x);
54+
opaque(&x);
5555
}
5656

5757
// CHECK-LABEL: @nonzero_integer_array
@@ -60,5 +60,9 @@ pub fn nonzero_integer_array() {
6060
// CHECK: br label %repeat_loop_header{{.*}}
6161
// CHECK-NOT: call void @llvm.memset.p0
6262
let x = [0x1a_2b_3c_4d_u32; 4];
63-
drop(&x);
63+
opaque(&x);
6464
}
65+
66+
// Use an opaque function to prevent rustc from removing useless drops.
67+
#[inline(never)]
68+
pub fn opaque(_: impl Sized) {}

0 commit comments

Comments
 (0)