We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents f4335a4 + 0c56ccf commit c505d76Copy full SHA for c505d76
tests/codegen/maybeuninit-rvo.rs
@@ -0,0 +1,33 @@
1
+// compile-flags: -O
2
+#![feature(c_unwind)]
3
+#![crate_type = "lib"]
4
+
5
+pub struct Foo([u8; 1000]);
6
7
+extern "C" {
8
+ fn init(p: *mut Foo);
9
+}
10
11
+pub fn new_from_uninit() -> Foo {
12
+ // CHECK-LABEL: new_from_uninit
13
+ // CHECK-NOT: call void @llvm.memcpy.
14
+ let mut x = std::mem::MaybeUninit::uninit();
15
+ unsafe {
16
+ init(x.as_mut_ptr());
17
+ x.assume_init()
18
+ }
19
20
21
+extern "C-unwind" {
22
+ fn init_unwind(p: *mut Foo);
23
24
25
+pub fn new_from_uninit_unwind() -> Foo {
26
27
+ // CHECK: call void @llvm.memcpy.
28
29
30
+ init_unwind(x.as_mut_ptr());
31
32
33
0 commit comments