summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElichai Turkel <elichai.turkel@gmail.com>2019-11-04 17:42:14 +0200
committerEmilio Cobos Álvarez <emilio@crisal.io>2019-11-08 13:46:40 +0100
commit3609bd6ecbf229bcab7967b974708cf8974d9f93 (patch)
tree629e223ecb3d72e26270038898b0893f4fa7f1aa
parent99aff6e254faf5ff3e0ed7350f890ec57d41e0ec (diff)
Update and add tests for MaybeUninit
-rw-r--r--tests/expectations/tests/constructor-tp.rs6
-rw-r--r--tests/expectations/tests/constructors.rs18
-rw-r--r--tests/expectations/tests/constructors_1_33.rs84
-rw-r--r--tests/expectations/tests/gen-constructors.rs6
-rw-r--r--tests/expectations/tests/issue-447.rs9
-rw-r--r--tests/expectations/tests/issue-807-opaque-types-methods-being-generated.rs6
-rw-r--r--tests/expectations/tests/libclang-3.8/partial-specialization-and-inheritance.rs6
-rw-r--r--tests/expectations/tests/var-tracing.rs6
-rw-r--r--tests/headers/constructors_1_33.hpp16
9 files changed, 130 insertions, 27 deletions
diff --git a/tests/expectations/tests/constructor-tp.rs b/tests/expectations/tests/constructor-tp.rs
index c547206b..75ff2a17 100644
--- a/tests/expectations/tests/constructor-tp.rs
+++ b/tests/expectations/tests/constructor-tp.rs
@@ -37,8 +37,8 @@ extern "C" {
impl Bar {
#[inline]
pub unsafe fn new() -> Self {
- let mut __bindgen_tmp = ::std::mem::uninitialized();
- Bar_Bar(&mut __bindgen_tmp);
- __bindgen_tmp
+ let mut __bindgen_tmp = ::std::mem::MaybeUninit::uninit();
+ Bar_Bar(__bindgen_tmp.as_mut_ptr());
+ __bindgen_tmp.assume_init()
}
}
diff --git a/tests/expectations/tests/constructors.rs b/tests/expectations/tests/constructors.rs
index d8099db5..f334b91d 100644
--- a/tests/expectations/tests/constructors.rs
+++ b/tests/expectations/tests/constructors.rs
@@ -39,15 +39,15 @@ extern "C" {
impl TestOverload {
#[inline]
pub unsafe fn new(arg1: ::std::os::raw::c_int) -> Self {
- let mut __bindgen_tmp = ::std::mem::uninitialized();
- TestOverload_TestOverload(&mut __bindgen_tmp, arg1);
- __bindgen_tmp
+ let mut __bindgen_tmp = ::std::mem::MaybeUninit::uninit();
+ TestOverload_TestOverload(__bindgen_tmp.as_mut_ptr(), arg1);
+ __bindgen_tmp.assume_init()
}
#[inline]
pub unsafe fn new1(arg1: f64) -> Self {
- let mut __bindgen_tmp = ::std::mem::uninitialized();
- TestOverload_TestOverload1(&mut __bindgen_tmp, arg1);
- __bindgen_tmp
+ let mut __bindgen_tmp = ::std::mem::MaybeUninit::uninit();
+ TestOverload_TestOverload1(__bindgen_tmp.as_mut_ptr(), arg1);
+ __bindgen_tmp.assume_init()
}
}
#[repr(C)]
@@ -75,8 +75,8 @@ extern "C" {
impl TestPublicNoArgs {
#[inline]
pub unsafe fn new() -> Self {
- let mut __bindgen_tmp = ::std::mem::uninitialized();
- TestPublicNoArgs_TestPublicNoArgs(&mut __bindgen_tmp);
- __bindgen_tmp
+ let mut __bindgen_tmp = ::std::mem::MaybeUninit::uninit();
+ TestPublicNoArgs_TestPublicNoArgs(__bindgen_tmp.as_mut_ptr());
+ __bindgen_tmp.assume_init()
}
}
diff --git a/tests/expectations/tests/constructors_1_33.rs b/tests/expectations/tests/constructors_1_33.rs
new file mode 100644
index 00000000..7de6c27b
--- /dev/null
+++ b/tests/expectations/tests/constructors_1_33.rs
@@ -0,0 +1,84 @@
+/* automatically generated by rust-bindgen */
+
+#![allow(
+ dead_code,
+ non_snake_case,
+ non_camel_case_types,
+ non_upper_case_globals
+)]
+
+#[repr(C)]
+#[derive(Debug, Default, Copy, Clone)]
+pub struct TestOverload {
+ pub _address: u8,
+}
+#[test]
+fn bindgen_test_layout_TestOverload() {
+ assert_eq!(
+ ::std::mem::size_of::<TestOverload>(),
+ 1usize,
+ concat!("Size of: ", stringify!(TestOverload))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<TestOverload>(),
+ 1usize,
+ concat!("Alignment of ", stringify!(TestOverload))
+ );
+}
+extern "C" {
+ /// Calling this should use `mem::unintialized()` and not `MaybeUninit()` as only rust 1.36 includes that.
+ #[link_name = "\u{1}_ZN12TestOverloadC1Ei"]
+ pub fn TestOverload_TestOverload(
+ this: *mut TestOverload,
+ arg1: ::std::os::raw::c_int,
+ );
+}
+extern "C" {
+ /// Calling this should use `mem::unintialized()` and not `MaybeUninit()` as only rust 1.36 includes that.
+ #[link_name = "\u{1}_ZN12TestOverloadC1Ed"]
+ pub fn TestOverload_TestOverload1(this: *mut TestOverload, arg1: f64);
+}
+impl TestOverload {
+ #[inline]
+ pub unsafe fn new(arg1: ::std::os::raw::c_int) -> Self {
+ let mut __bindgen_tmp = ::std::mem::uninitialized();
+ TestOverload_TestOverload(&mut __bindgen_tmp, arg1);
+ __bindgen_tmp
+ }
+ #[inline]
+ pub unsafe fn new1(arg1: f64) -> Self {
+ let mut __bindgen_tmp = ::std::mem::uninitialized();
+ TestOverload_TestOverload1(&mut __bindgen_tmp, arg1);
+ __bindgen_tmp
+ }
+}
+#[repr(C)]
+#[derive(Debug, Default, Copy, Clone)]
+pub struct TestPublicNoArgs {
+ pub _address: u8,
+}
+#[test]
+fn bindgen_test_layout_TestPublicNoArgs() {
+ assert_eq!(
+ ::std::mem::size_of::<TestPublicNoArgs>(),
+ 1usize,
+ concat!("Size of: ", stringify!(TestPublicNoArgs))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<TestPublicNoArgs>(),
+ 1usize,
+ concat!("Alignment of ", stringify!(TestPublicNoArgs))
+ );
+}
+extern "C" {
+ #[link_name = "\u{1}_ZN16TestPublicNoArgsC1Ev"]
+ pub fn TestPublicNoArgs_TestPublicNoArgs(this: *mut TestPublicNoArgs);
+}
+impl TestPublicNoArgs {
+ #[inline]
+ pub unsafe fn new() -> Self {
+ let mut __bindgen_tmp = ::std::mem::uninitialized();
+ TestPublicNoArgs_TestPublicNoArgs(&mut __bindgen_tmp);
+ __bindgen_tmp
+ }
+}
diff --git a/tests/expectations/tests/gen-constructors.rs b/tests/expectations/tests/gen-constructors.rs
index 4f948450..878a664d 100644
--- a/tests/expectations/tests/gen-constructors.rs
+++ b/tests/expectations/tests/gen-constructors.rs
@@ -32,8 +32,8 @@ extern "C" {
impl Foo {
#[inline]
pub unsafe fn new(a: ::std::os::raw::c_int) -> Self {
- let mut __bindgen_tmp = ::std::mem::uninitialized();
- Foo_Foo(&mut __bindgen_tmp, a);
- __bindgen_tmp
+ let mut __bindgen_tmp = ::std::mem::MaybeUninit::uninit();
+ Foo_Foo(__bindgen_tmp.as_mut_ptr(), a);
+ __bindgen_tmp.assume_init()
}
}
diff --git a/tests/expectations/tests/issue-447.rs b/tests/expectations/tests/issue-447.rs
index 0d9eac80..8103a69f 100644
--- a/tests/expectations/tests/issue-447.rs
+++ b/tests/expectations/tests/issue-447.rs
@@ -67,9 +67,12 @@ pub mod root {
pub unsafe fn new(
arg1: root::mozilla::detail::GuardObjectNotifier,
) -> Self {
- let mut __bindgen_tmp = ::std::mem::uninitialized();
- JSAutoCompartment_JSAutoCompartment(&mut __bindgen_tmp, arg1);
- __bindgen_tmp
+ let mut __bindgen_tmp = ::std::mem::MaybeUninit::uninit();
+ JSAutoCompartment_JSAutoCompartment(
+ __bindgen_tmp.as_mut_ptr(),
+ arg1,
+ );
+ __bindgen_tmp.assume_init()
}
}
}
diff --git a/tests/expectations/tests/issue-807-opaque-types-methods-being-generated.rs b/tests/expectations/tests/issue-807-opaque-types-methods-being-generated.rs
index 1dee1aa1..824fccba 100644
--- a/tests/expectations/tests/issue-807-opaque-types-methods-being-generated.rs
+++ b/tests/expectations/tests/issue-807-opaque-types-methods-being-generated.rs
@@ -95,9 +95,9 @@ impl Opaque {
}
#[inline]
pub unsafe fn new(pup: Pupper) -> Self {
- let mut __bindgen_tmp = ::std::mem::uninitialized();
- Opaque_Opaque(&mut __bindgen_tmp, pup);
- __bindgen_tmp
+ let mut __bindgen_tmp = ::std::mem::MaybeUninit::uninit();
+ Opaque_Opaque(__bindgen_tmp.as_mut_ptr(), pup);
+ __bindgen_tmp.assume_init()
}
}
extern "C" {
diff --git a/tests/expectations/tests/libclang-3.8/partial-specialization-and-inheritance.rs b/tests/expectations/tests/libclang-3.8/partial-specialization-and-inheritance.rs
index 797d5f45..3e3eb9c5 100644
--- a/tests/expectations/tests/libclang-3.8/partial-specialization-and-inheritance.rs
+++ b/tests/expectations/tests/libclang-3.8/partial-specialization-and-inheritance.rs
@@ -43,8 +43,8 @@ extern "C" {
impl Usage {
#[inline]
pub unsafe fn new() -> Self {
- let mut __bindgen_tmp = ::std::mem::uninitialized();
- Usage_Usage(&mut __bindgen_tmp);
- __bindgen_tmp
+ let mut __bindgen_tmp = ::std::mem::MaybeUninit::uninit();
+ Usage_Usage(__bindgen_tmp.as_mut_ptr());
+ __bindgen_tmp.assume_init()
}
}
diff --git a/tests/expectations/tests/var-tracing.rs b/tests/expectations/tests/var-tracing.rs
index 214f10f8..9a7d70e0 100644
--- a/tests/expectations/tests/var-tracing.rs
+++ b/tests/expectations/tests/var-tracing.rs
@@ -42,9 +42,9 @@ extern "C" {
impl Bar {
#[inline]
pub unsafe fn new(baz: ::std::os::raw::c_int) -> Self {
- let mut __bindgen_tmp = ::std::mem::uninitialized();
- Bar_Bar(&mut __bindgen_tmp, baz);
- __bindgen_tmp
+ let mut __bindgen_tmp = ::std::mem::MaybeUninit::uninit();
+ Bar_Bar(__bindgen_tmp.as_mut_ptr(), baz);
+ __bindgen_tmp.assume_init()
}
}
#[repr(C)]
diff --git a/tests/headers/constructors_1_33.hpp b/tests/headers/constructors_1_33.hpp
new file mode 100644
index 00000000..7c6262d4
--- /dev/null
+++ b/tests/headers/constructors_1_33.hpp
@@ -0,0 +1,16 @@
+// bindgen-flags: --rust-target 1.33
+
+class TestOverload {
+ // This one shouldnt' be generated.
+ TestOverload();
+public:
+ /// Calling this should use `mem::unintialized()` and not `MaybeUninit()` as only rust 1.36 includes that.
+ TestOverload(int);
+ /// Calling this should use `mem::unintialized()` and not `MaybeUninit()` as only rust 1.36 includes that.
+ TestOverload(double);
+};
+
+class TestPublicNoArgs {
+public:
+ TestPublicNoArgs();
+};