Skip to content

Commit 9af70c1

Browse files
committed
add initial tests for placement new changes
1 parent a1eceec commit 9af70c1

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

Diff for: tests/codegen/placement-new.rs

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
//@ compile-flags: -O
2+
#![crate_type = "lib"]
3+
4+
// Test to check that types with "complex" destructors, but trivial `Default` impls
5+
// are constructed directly into the allocation in `Box::default` and `Arc::default`.
6+
7+
use std::sync::Arc;
8+
9+
// CHECK-LABEL: @box_default_inplace
10+
#[no_mangle]
11+
pub fn box_default_inplace() -> Box<(String, String)> {
12+
// CHECK: [[ALLOCA:%.*]] = alloca
13+
// CHECK: [[BOX:%.*]] = {{.*}}call {{.*}}__rust_alloc(
14+
// CHECK: call void @llvm.memcpy.p0.p0.i64(ptr {{.*}}[[BOX]], ptr {{.*}}[[ALLOCA]]
15+
// CHECK: ret ptr [[BOX]]
16+
Box::default()
17+
}
18+
19+
// CHECK-LABEL: @arc_default_inplace
20+
#[no_mangle]
21+
pub fn arc_default_inplace() -> Arc<(String, String)> {
22+
// CHECK: [[ALLOCA:%.*]] = alloca
23+
// CHECK: [[ARC:%.*]] = {{.*}}call {{.*}}__rust_alloc(
24+
// CHECK: call void @llvm.memcpy.p0.p0.i64(
25+
// CHECK: ret ptr [[ARC]]
26+
Arc::default()
27+
}

0 commit comments

Comments
 (0)