summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZhiting Zhu <zzhu@mozilla.com>2017-08-04 10:49:56 -0700
committerZhiting Zhu <zzhu@mozilla.com>2017-08-09 15:19:00 -0700
commit8fa9cd9e613c1231a16e54e1d9a26b62b47c7819 (patch)
tree482973e33b22db1510215c99dc410a0bc4c4ccc4
parenta529e92870c8710d10f870dd09c824091d91f856 (diff)
Opaque related tests for derive Hash
-rw-r--r--tests/expectations/tests/issue-801-opaque-sloppiness.rs4
-rw-r--r--tests/expectations/tests/issue-807-opaque-types-methods-being-generated.rs10
-rw-r--r--tests/expectations/tests/jsval_layout_opaque.rs13
-rw-r--r--tests/expectations/tests/opaque-template-inst-member-2.rs10
-rw-r--r--tests/expectations/tests/opaque-template-inst-member.rs6
-rw-r--r--tests/expectations/tests/opaque-template-instantiation-namespaced.rs10
-rw-r--r--tests/expectations/tests/opaque-template-instantiation.rs6
-rw-r--r--tests/expectations/tests/opaque-tracing.rs2
-rw-r--r--tests/expectations/tests/opaque_in_struct.rs4
-rw-r--r--tests/expectations/tests/opaque_pointer.rs6
-rw-r--r--tests/expectations/tests/opaque_typedef.rs2
-rw-r--r--tests/headers/issue-801-opaque-sloppiness.hpp2
-rw-r--r--tests/headers/issue-807-opaque-types-methods-being-generated.hpp2
-rw-r--r--tests/headers/jsval_layout_opaque.hpp1
-rw-r--r--tests/headers/opaque-template-inst-member-2.hpp10
-rw-r--r--tests/headers/opaque-template-inst-member.hpp10
-rw-r--r--tests/headers/opaque-template-instantiation-namespaced.hpp2
-rw-r--r--tests/headers/opaque-template-instantiation.hpp2
-rw-r--r--tests/headers/opaque-tracing.hpp2
-rw-r--r--tests/headers/opaque_in_struct.hpp1
-rw-r--r--tests/headers/opaque_pointer.hpp1
-rw-r--r--tests/headers/opaque_typedef.hpp2
22 files changed, 61 insertions, 47 deletions
diff --git a/tests/expectations/tests/issue-801-opaque-sloppiness.rs b/tests/expectations/tests/issue-801-opaque-sloppiness.rs
index 7a7afb86..cd2c4fac 100644
--- a/tests/expectations/tests/issue-801-opaque-sloppiness.rs
+++ b/tests/expectations/tests/issue-801-opaque-sloppiness.rs
@@ -10,7 +10,7 @@ pub struct A {
_unused: [u8; 0],
}
#[repr(C)]
-#[derive(Debug, Default, Copy)]
+#[derive(Debug, Default, Copy, Hash)]
pub struct B {
pub _bindgen_opaque_blob: u8,
}
@@ -29,7 +29,7 @@ extern "C" {
pub static mut B_a: A;
}
#[repr(C)]
-#[derive(Debug, Default, Copy)]
+#[derive(Debug, Default, Copy, Hash)]
pub struct C {
pub b: B,
}
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 f22a9612..2826ec5d 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
@@ -5,7 +5,7 @@
#[repr(C)]
-#[derive(Debug, Default, Copy)]
+#[derive(Debug, Default, Copy, Hash)]
pub struct Pupper {
pub _address: u8,
}
@@ -20,7 +20,7 @@ impl Clone for Pupper {
fn clone(&self) -> Self { *self }
}
#[repr(C)]
-#[derive(Debug, Default, Copy)]
+#[derive(Debug, Default, Copy, Hash)]
pub struct Doggo {
pub _address: u8,
}
@@ -35,7 +35,7 @@ impl Clone for Doggo {
fn clone(&self) -> Self { *self }
}
#[repr(C)]
-#[derive(Debug, Default, Copy)]
+#[derive(Debug, Default, Copy, Hash)]
pub struct SuchWow {
pub _address: u8,
}
@@ -50,7 +50,7 @@ impl Clone for SuchWow {
fn clone(&self) -> Self { *self }
}
#[repr(C)]
-#[derive(Debug, Default, Copy)]
+#[derive(Debug, Default, Copy, Hash)]
pub struct Opaque {
pub _bindgen_opaque_blob: u8,
}
@@ -89,7 +89,7 @@ extern "C" {
pub static mut Opaque_MAJESTIC_AF: Doggo;
}
#[repr(C)]
-#[derive(Debug, Default, Copy)]
+#[derive(Debug, Default, Copy, Hash)]
pub struct Whitelisted {
pub some_member: Opaque,
}
diff --git a/tests/expectations/tests/jsval_layout_opaque.rs b/tests/expectations/tests/jsval_layout_opaque.rs
index 980adbcf..536d8c59 100644
--- a/tests/expectations/tests/jsval_layout_opaque.rs
+++ b/tests/expectations/tests/jsval_layout_opaque.rs
@@ -28,6 +28,9 @@ impl <T> ::std::fmt::Debug for __BindgenUnionField<T> {
fmt.write_str("__BindgenUnionField")
}
}
+impl <T> ::std::hash::Hash for __BindgenUnionField<T> {
+ fn hash<H: ::std::hash::Hasher>(&self, _state: &mut H) { }
+}
pub const JSVAL_TAG_SHIFT: ::std::os::raw::c_uint = 47;
pub const JSVAL_PAYLOAD_MASK: ::std::os::raw::c_ulonglong = 140737488355327;
pub const JSVAL_TAG_MASK: ::std::os::raw::c_longlong = -140737488355328;
@@ -96,7 +99,7 @@ pub enum JSWhyMagic {
JS_WHY_MAGIC_COUNT = 18,
}
#[repr(C)]
-#[derive(Debug, Default, Copy)]
+#[derive(Debug, Default, Copy, Hash)]
pub struct jsval_layout {
pub asBits: __BindgenUnionField<u64>,
pub debugView: __BindgenUnionField<jsval_layout__bindgen_ty_1>,
@@ -108,7 +111,7 @@ pub struct jsval_layout {
pub bindgen_union_field: u64,
}
#[repr(C)]
-#[derive(Debug, Copy)]
+#[derive(Debug, Copy, Hash)]
pub struct jsval_layout__bindgen_ty_1 {
pub _bitfield_1: u64,
pub __bindgen_align: [u64; 0usize],
@@ -214,12 +217,12 @@ impl jsval_layout__bindgen_ty_1 {
}
}
#[repr(C)]
-#[derive(Debug, Default, Copy)]
+#[derive(Debug, Default, Copy, Hash)]
pub struct jsval_layout__bindgen_ty_2 {
pub payload: jsval_layout__bindgen_ty_2__bindgen_ty_1,
}
#[repr(C)]
-#[derive(Debug, Default, Copy)]
+#[derive(Debug, Default, Copy, Hash)]
pub struct jsval_layout__bindgen_ty_2__bindgen_ty_1 {
pub i32: __BindgenUnionField<i32>,
pub u32: __BindgenUnionField<u32>,
@@ -326,7 +329,7 @@ impl Clone for jsval_layout {
fn clone(&self) -> Self { *self }
}
#[repr(C)]
-#[derive(Debug, Default, Copy)]
+#[derive(Debug, Default, Copy, Hash)]
pub struct Value {
pub data: jsval_layout,
}
diff --git a/tests/expectations/tests/opaque-template-inst-member-2.rs b/tests/expectations/tests/opaque-template-inst-member-2.rs
index 65efefb2..8c098c8f 100644
--- a/tests/expectations/tests/opaque-template-inst-member-2.rs
+++ b/tests/expectations/tests/opaque-template-inst-member-2.rs
@@ -4,12 +4,15 @@
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
+/// This is like `opaque-template-inst-member.hpp` except exercising the cases
+/// where we are OK to derive Debug/Hash.
#[repr(C)]
-#[derive(Debug, Default, Copy, Clone)]
+#[derive(Debug, Default, Copy, Clone, Hash)]
pub struct OpaqueTemplate {
}
+/// Should derive Debug/Hash.
#[repr(C)]
-#[derive(Debug, Default, Copy)]
+#[derive(Debug, Default, Copy, Hash)]
pub struct ContainsOpaqueTemplate {
pub mBlah: u32,
pub mBaz: ::std::os::raw::c_int,
@@ -36,8 +39,9 @@ fn bindgen_test_layout_ContainsOpaqueTemplate() {
impl Clone for ContainsOpaqueTemplate {
fn clone(&self) -> Self { *self }
}
+/// Should also derive Debug/Hash.
#[repr(C)]
-#[derive(Debug, Copy)]
+#[derive(Debug, Copy, Hash)]
pub struct InheritsOpaqueTemplate {
pub _base: u8,
pub wow: *mut ::std::os::raw::c_char,
diff --git a/tests/expectations/tests/opaque-template-inst-member.rs b/tests/expectations/tests/opaque-template-inst-member.rs
index 9f0969cd..11c3cc84 100644
--- a/tests/expectations/tests/opaque-template-inst-member.rs
+++ b/tests/expectations/tests/opaque-template-inst-member.rs
@@ -5,9 +5,11 @@
#[repr(C)]
-#[derive(Default, Copy, Clone)]
+#[derive(Default, Copy, Clone, Hash)]
pub struct OpaqueTemplate {
}
+/// This should not end up deriving Debug/Hash because its `mBlah` field cannot derive
+/// Debug/Hash because the instantiation's definition cannot derive Debug/Hash.
#[repr(C)]
pub struct ContainsOpaqueTemplate {
pub mBlah: [u32; 101usize],
@@ -35,6 +37,8 @@ fn bindgen_test_layout_ContainsOpaqueTemplate() {
impl Default for ContainsOpaqueTemplate {
fn default() -> Self { unsafe { ::std::mem::zeroed() } }
}
+/// This shold not end up deriving Debug/Hash either, for similar reasons, although
+/// we're exercising base member edges now.
#[repr(C)]
pub struct InheritsOpaqueTemplate {
pub _base: [u8; 401usize],
diff --git a/tests/expectations/tests/opaque-template-instantiation-namespaced.rs b/tests/expectations/tests/opaque-template-instantiation-namespaced.rs
index 00c55825..396edbd6 100644
--- a/tests/expectations/tests/opaque-template-instantiation-namespaced.rs
+++ b/tests/expectations/tests/opaque-template-instantiation-namespaced.rs
@@ -12,7 +12,7 @@ pub mod root {
#[allow(unused_imports)]
use self::super::super::root;
#[repr(C)]
- #[derive(Debug, Copy, Clone)]
+ #[derive(Debug, Copy, Clone, Hash)]
pub struct Template<T> {
pub member: T,
pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<T>>,
@@ -21,7 +21,7 @@ pub mod root {
fn default() -> Self { unsafe { ::std::mem::zeroed() } }
}
#[repr(C)]
- #[derive(Debug, Default, Copy)]
+ #[derive(Debug, Default, Copy, Hash)]
pub struct Foo {
pub c: ::std::os::raw::c_char,
}
@@ -41,7 +41,7 @@ pub mod root {
fn clone(&self) -> Self { *self }
}
#[repr(C)]
- #[derive(Debug, Default, Copy)]
+ #[derive(Debug, Default, Copy, Hash)]
pub struct Bar {
pub i: ::std::os::raw::c_int,
}
@@ -61,7 +61,7 @@ pub mod root {
fn clone(&self) -> Self { *self }
}
#[repr(C)]
- #[derive(Debug, Copy)]
+ #[derive(Debug, Copy, Hash)]
pub struct ContainsInstantiation {
pub not_opaque: root::zoidberg::Template<root::zoidberg::Foo>,
}
@@ -89,7 +89,7 @@ pub mod root {
fn default() -> Self { unsafe { ::std::mem::zeroed() } }
}
#[repr(C)]
- #[derive(Debug, Default, Copy)]
+ #[derive(Debug, Default, Copy, Hash)]
pub struct ContainsOpaqueInstantiation {
pub opaque: u32,
}
diff --git a/tests/expectations/tests/opaque-template-instantiation.rs b/tests/expectations/tests/opaque-template-instantiation.rs
index f3ef2a06..aafe702f 100644
--- a/tests/expectations/tests/opaque-template-instantiation.rs
+++ b/tests/expectations/tests/opaque-template-instantiation.rs
@@ -5,7 +5,7 @@
#[repr(C)]
-#[derive(Debug, Copy, Clone)]
+#[derive(Debug, Copy, Clone, Hash)]
pub struct Template<T> {
pub member: T,
pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<T>>,
@@ -14,7 +14,7 @@ impl <T> Default for Template<T> {
fn default() -> Self { unsafe { ::std::mem::zeroed() } }
}
#[repr(C)]
-#[derive(Debug, Copy)]
+#[derive(Debug, Copy, Hash)]
pub struct ContainsInstantiation {
pub not_opaque: Template<::std::os::raw::c_char>,
}
@@ -39,7 +39,7 @@ impl Default for ContainsInstantiation {
fn default() -> Self { unsafe { ::std::mem::zeroed() } }
}
#[repr(C)]
-#[derive(Debug, Default, Copy)]
+#[derive(Debug, Default, Copy, Hash)]
pub struct ContainsOpaqueInstantiation {
pub opaque: u32,
}
diff --git a/tests/expectations/tests/opaque-tracing.rs b/tests/expectations/tests/opaque-tracing.rs
index fc91a6ce..5113ccf3 100644
--- a/tests/expectations/tests/opaque-tracing.rs
+++ b/tests/expectations/tests/opaque-tracing.rs
@@ -5,7 +5,7 @@
#[repr(C)]
-#[derive(Debug, Default, Copy)]
+#[derive(Debug, Default, Copy, Hash)]
pub struct Container {
pub _bindgen_opaque_blob: [u32; 2usize],
}
diff --git a/tests/expectations/tests/opaque_in_struct.rs b/tests/expectations/tests/opaque_in_struct.rs
index d41cbf10..db85246a 100644
--- a/tests/expectations/tests/opaque_in_struct.rs
+++ b/tests/expectations/tests/opaque_in_struct.rs
@@ -6,7 +6,7 @@
/// <div rustbindgen opaque>
#[repr(C)]
-#[derive(Debug, Default, Copy)]
+#[derive(Debug, Default, Copy, Hash)]
pub struct opaque {
pub _bindgen_opaque_blob: u32,
}
@@ -21,7 +21,7 @@ impl Clone for opaque {
fn clone(&self) -> Self { *self }
}
#[repr(C)]
-#[derive(Debug, Default, Copy)]
+#[derive(Debug, Default, Copy, Hash)]
pub struct container {
pub contained: opaque,
}
diff --git a/tests/expectations/tests/opaque_pointer.rs b/tests/expectations/tests/opaque_pointer.rs
index feb22439..2e566dc4 100644
--- a/tests/expectations/tests/opaque_pointer.rs
+++ b/tests/expectations/tests/opaque_pointer.rs
@@ -6,7 +6,7 @@
/// <div rustbindgen opaque></div>
#[repr(C)]
-#[derive(Debug, Default, Copy)]
+#[derive(Debug, Default, Copy, Hash)]
pub struct OtherOpaque {
pub _bindgen_opaque_blob: u32,
}
@@ -22,11 +22,11 @@ impl Clone for OtherOpaque {
}
/// <div rustbindgen opaque></div>
#[repr(C)]
-#[derive(Debug, Default, Copy, Clone)]
+#[derive(Debug, Default, Copy, Clone, Hash)]
pub struct Opaque {
}
#[repr(C)]
-#[derive(Debug, Copy)]
+#[derive(Debug, Copy, Hash)]
pub struct WithOpaquePtr {
pub whatever: *mut u8,
pub other: u32,
diff --git a/tests/expectations/tests/opaque_typedef.rs b/tests/expectations/tests/opaque_typedef.rs
index a19a71ac..53cf6f64 100644
--- a/tests/expectations/tests/opaque_typedef.rs
+++ b/tests/expectations/tests/opaque_typedef.rs
@@ -5,7 +5,7 @@
#[repr(C)]
-#[derive(Debug, Default, Copy, Clone)]
+#[derive(Debug, Default, Copy, Clone, Hash)]
pub struct RandomTemplate {
pub _address: u8,
}
diff --git a/tests/headers/issue-801-opaque-sloppiness.hpp b/tests/headers/issue-801-opaque-sloppiness.hpp
index 503bba39..275be023 100644
--- a/tests/headers/issue-801-opaque-sloppiness.hpp
+++ b/tests/headers/issue-801-opaque-sloppiness.hpp
@@ -1,4 +1,4 @@
-// bindgen-flags: --opaque-type "B" --whitelist-type "C"
+// bindgen-flags: --opaque-type "B" --whitelist-type "C" --with-derive-hash
class A;
diff --git a/tests/headers/issue-807-opaque-types-methods-being-generated.hpp b/tests/headers/issue-807-opaque-types-methods-being-generated.hpp
index bdb7cd53..f2133427 100644
--- a/tests/headers/issue-807-opaque-types-methods-being-generated.hpp
+++ b/tests/headers/issue-807-opaque-types-methods-being-generated.hpp
@@ -1,4 +1,4 @@
-// bindgen-flags: --whitelist-type Whitelisted --opaque-type Opaque -- -std=c++11
+// bindgen-flags: --whitelist-type Whitelisted --opaque-type Opaque --with-derive-hash -- -std=c++11
// These types are not explicitly whitelisted, but are reachable through the
// opaque type.
diff --git a/tests/headers/jsval_layout_opaque.hpp b/tests/headers/jsval_layout_opaque.hpp
index 8f36f77d..4a4f367b 100644
--- a/tests/headers/jsval_layout_opaque.hpp
+++ b/tests/headers/jsval_layout_opaque.hpp
@@ -1,3 +1,4 @@
+// bindgen-flags: --with-derive-hash
// bindgen-flags: -- -std=c++11
/**
diff --git a/tests/headers/opaque-template-inst-member-2.hpp b/tests/headers/opaque-template-inst-member-2.hpp
index d4386f48..9d31fa31 100644
--- a/tests/headers/opaque-template-inst-member-2.hpp
+++ b/tests/headers/opaque-template-inst-member-2.hpp
@@ -1,20 +1,20 @@
-// bindgen-flags: --opaque-type 'OpaqueTemplate'
+// bindgen-flags: --opaque-type 'OpaqueTemplate' --with-derive-hash
-// This is like `opaque-template-inst-member.hpp` except exercising the cases
-// where we are OK to derive Debug.
+/// This is like `opaque-template-inst-member.hpp` except exercising the cases
+/// where we are OK to derive Debug/Hash.
template<typename T>
class OpaqueTemplate {
T mData;
};
-// Should derive Debug.
+/// Should derive Debug/Hash.
class ContainsOpaqueTemplate {
OpaqueTemplate<int> mBlah;
int mBaz;
};
-// Should also derive Debug.
+/// Should also derive Debug/Hash.
class InheritsOpaqueTemplate : public OpaqueTemplate<bool> {
char* wow;
};
diff --git a/tests/headers/opaque-template-inst-member.hpp b/tests/headers/opaque-template-inst-member.hpp
index 7748007b..d5954144 100644
--- a/tests/headers/opaque-template-inst-member.hpp
+++ b/tests/headers/opaque-template-inst-member.hpp
@@ -1,4 +1,4 @@
-// bindgen-flags: --opaque-type 'OpaqueTemplate'
+// bindgen-flags: --opaque-type 'OpaqueTemplate' --with-derive-hash
template<typename T>
class OpaqueTemplate {
@@ -6,15 +6,15 @@ class OpaqueTemplate {
bool mCannotDebug[400];
};
-// This should not end up deriving Debug because its `mBlah` field cannot derive
-// Debug because the instantiation's definition cannot derive Debug.
+/// This should not end up deriving Debug/Hash because its `mBlah` field cannot derive
+/// Debug/Hash because the instantiation's definition cannot derive Debug/Hash.
class ContainsOpaqueTemplate {
OpaqueTemplate<int> mBlah;
int mBaz;
};
-// This shold not end up deriving Debug either, for similar reasons, although
-// we're exercising base member edges now.
+/// This shold not end up deriving Debug/Hash either, for similar reasons, although
+/// we're exercising base member edges now.
class InheritsOpaqueTemplate : public OpaqueTemplate<bool> {
char* wow;
};
diff --git a/tests/headers/opaque-template-instantiation-namespaced.hpp b/tests/headers/opaque-template-instantiation-namespaced.hpp
index 31fb0d52..85513fdf 100644
--- a/tests/headers/opaque-template-instantiation-namespaced.hpp
+++ b/tests/headers/opaque-template-instantiation-namespaced.hpp
@@ -1,4 +1,4 @@
-// bindgen-flags: --enable-cxx-namespaces --opaque-type 'zoidberg::Template<zoidberg::Bar>' -- -std=c++14
+// bindgen-flags: --enable-cxx-namespaces --opaque-type 'zoidberg::Template<zoidberg::Bar>' --with-derive-hash -- -std=c++14
namespace zoidberg {
diff --git a/tests/headers/opaque-template-instantiation.hpp b/tests/headers/opaque-template-instantiation.hpp
index 7589b53c..fe29948d 100644
--- a/tests/headers/opaque-template-instantiation.hpp
+++ b/tests/headers/opaque-template-instantiation.hpp
@@ -1,4 +1,4 @@
-// bindgen-flags: --opaque-type 'Template<int>' -- -std=c++14
+// bindgen-flags: --opaque-type 'Template<int>' --with-derive-hash -- -std=c++14
template <typename T>
class Template {
diff --git a/tests/headers/opaque-tracing.hpp b/tests/headers/opaque-tracing.hpp
index 7356245e..42ef3ccf 100644
--- a/tests/headers/opaque-tracing.hpp
+++ b/tests/headers/opaque-tracing.hpp
@@ -1,4 +1,4 @@
-// bindgen-flags: --opaque-type=.* --whitelist-function=foo
+// bindgen-flags: --opaque-type=.* --whitelist-function=foo --with-derive-hash
class Container;
diff --git a/tests/headers/opaque_in_struct.hpp b/tests/headers/opaque_in_struct.hpp
index 3cffeb20..771b80bc 100644
--- a/tests/headers/opaque_in_struct.hpp
+++ b/tests/headers/opaque_in_struct.hpp
@@ -1,3 +1,4 @@
+// bindgen-flags: --with-derive-hash
/** <div rustbindgen opaque> */
diff --git a/tests/headers/opaque_pointer.hpp b/tests/headers/opaque_pointer.hpp
index 53f8ce1f..cc99df99 100644
--- a/tests/headers/opaque_pointer.hpp
+++ b/tests/headers/opaque_pointer.hpp
@@ -1,3 +1,4 @@
+// bindgen-flags: --with-derive-hash
/**
* <div rustbindgen opaque></div>
diff --git a/tests/headers/opaque_typedef.hpp b/tests/headers/opaque_typedef.hpp
index 25640738..f39f2fce 100644
--- a/tests/headers/opaque_typedef.hpp
+++ b/tests/headers/opaque_typedef.hpp
@@ -1,4 +1,4 @@
-// bindgen-flags: -- -std=c++11
+// bindgen-flags: --with-derive-hash -- -std=c++11
template<typename T>
class RandomTemplate;