File tree Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change 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{{.*}}(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
25+ // CHECK: ret ptr [[ARC]]
26+ Arc :: default ( )
27+ }
You can’t perform that action at this time.
0 commit comments