Skip to content

Commit 52581f5

Browse files
committed
add codegen test
1 parent 5b12d90 commit 52581f5

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

tests/codegen/placement-new.rs

+11
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
// Test to check that types with "complex" destructors, but trivial `Default` impls
55
// are constructed directly into the allocation in `Box::default` and `Arc::default`.
66

7+
use std::rc::Rc;
78
use std::sync::Arc;
89

910
// CHECK-LABEL: @box_default_inplace
@@ -16,6 +17,16 @@ pub fn box_default_inplace() -> Box<(String, String)> {
1617
Box::default()
1718
}
1819

20+
// CHECK-LABEL: @rc_default_inplace
21+
#[no_mangle]
22+
pub fn rc_default_inplace() -> Rc<(String, String)> {
23+
// CHECK-NOT: alloca
24+
// CHECK: [[RC:%.*]] = {{.*}}call {{.*}}__rust_alloc(
25+
// CHECK-NOT: call void @llvm.memcpy
26+
// CHECK: ret ptr [[RC]]
27+
Rc::default()
28+
}
29+
1930
// CHECK-LABEL: @arc_default_inplace
2031
#[no_mangle]
2132
pub fn arc_default_inplace() -> Arc<(String, String)> {

0 commit comments

Comments
 (0)