diff options
author | Zhiting Zhu <zzhu@mozilla.com> | 2017-08-04 17:54:55 -0700 |
---|---|---|
committer | Zhiting Zhu <zzhu@mozilla.com> | 2017-08-09 15:19:00 -0700 |
commit | 3edb811aef594b8731ca2a4878a3fb2a6f3ae61b (patch) | |
tree | 38e9a7682a20d01fd8518a2890d5c70cb2b55d42 | |
parent | e967d18c2c7465bd2f3432e4f39776ffa4f1f3ad (diff) |
Misc tests for derive Hash
-rw-r--r-- | tests/expectations/tests/16-byte-alignment.rs | 15 | ||||
-rw-r--r-- | tests/expectations/tests/char.rs | 2 | ||||
-rw-r--r-- | tests/expectations/tests/issue-493.rs | 13 | ||||
-rw-r--r-- | tests/expectations/tests/typeref.rs | 15 | ||||
-rw-r--r-- | tests/expectations/tests/use-core.rs | 7 | ||||
-rw-r--r-- | tests/headers/16-byte-alignment.h | 1 | ||||
-rw-r--r-- | tests/headers/char.h | 2 | ||||
-rw-r--r-- | tests/headers/issue-493.hpp | 3 | ||||
-rw-r--r-- | tests/headers/typeref.hpp | 1 | ||||
-rw-r--r-- | tests/headers/use-core.h | 2 |
10 files changed, 39 insertions, 22 deletions
diff --git a/tests/expectations/tests/16-byte-alignment.rs b/tests/expectations/tests/16-byte-alignment.rs index c60d69c3..1068f3f5 100644 --- a/tests/expectations/tests/16-byte-alignment.rs +++ b/tests/expectations/tests/16-byte-alignment.rs @@ -28,22 +28,25 @@ 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) { } +} #[repr(C)] -#[derive(Debug, Default, Copy)] +#[derive(Debug, Default, Copy, Hash)] pub struct rte_ipv4_tuple { pub src_addr: u32, pub dst_addr: u32, pub __bindgen_anon_1: rte_ipv4_tuple__bindgen_ty_1, } #[repr(C)] -#[derive(Debug, Default, Copy)] +#[derive(Debug, Default, Copy, Hash)] pub struct rte_ipv4_tuple__bindgen_ty_1 { pub __bindgen_anon_1: __BindgenUnionField<rte_ipv4_tuple__bindgen_ty_1__bindgen_ty_1>, pub sctp_tag: __BindgenUnionField<u32>, pub bindgen_union_field: u32, } #[repr(C)] -#[derive(Debug, Default, Copy)] +#[derive(Debug, Default, Copy, Hash)] pub struct rte_ipv4_tuple__bindgen_ty_1__bindgen_ty_1 { pub dport: u16, pub sport: u16, @@ -116,21 +119,21 @@ impl Clone for rte_ipv4_tuple { fn clone(&self) -> Self { *self } } #[repr(C)] -#[derive(Debug, Default, Copy)] +#[derive(Debug, Default, Copy, Hash)] pub struct rte_ipv6_tuple { pub src_addr: [u8; 16usize], pub dst_addr: [u8; 16usize], pub __bindgen_anon_1: rte_ipv6_tuple__bindgen_ty_1, } #[repr(C)] -#[derive(Debug, Default, Copy)] +#[derive(Debug, Default, Copy, Hash)] pub struct rte_ipv6_tuple__bindgen_ty_1 { pub __bindgen_anon_1: __BindgenUnionField<rte_ipv6_tuple__bindgen_ty_1__bindgen_ty_1>, pub sctp_tag: __BindgenUnionField<u32>, pub bindgen_union_field: u32, } #[repr(C)] -#[derive(Debug, Default, Copy)] +#[derive(Debug, Default, Copy, Hash)] pub struct rte_ipv6_tuple__bindgen_ty_1__bindgen_ty_1 { pub dport: u16, pub sport: u16, diff --git a/tests/expectations/tests/char.rs b/tests/expectations/tests/char.rs index be92e545..f34e075d 100644 --- a/tests/expectations/tests/char.rs +++ b/tests/expectations/tests/char.rs @@ -8,7 +8,7 @@ pub type Char = ::std::os::raw::c_char; pub type SChar = ::std::os::raw::c_schar; pub type UChar = ::std::os::raw::c_uchar; #[repr(C)] -#[derive(Debug, Default, Copy)] +#[derive(Debug, Default, Copy, Hash)] pub struct Test { pub ch: ::std::os::raw::c_char, pub u: ::std::os::raw::c_uchar, diff --git a/tests/expectations/tests/issue-493.rs b/tests/expectations/tests/issue-493.rs index 89f03457..d25bb4a0 100644 --- a/tests/expectations/tests/issue-493.rs +++ b/tests/expectations/tests/issue-493.rs @@ -28,8 +28,11 @@ 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) { } +} #[repr(C)] -#[derive(Debug, Default, Copy, Clone)] +#[derive(Debug, Default, Copy, Clone, Hash)] pub struct basic_string { pub _address: u8, } @@ -37,7 +40,7 @@ pub type basic_string_size_type = ::std::os::raw::c_ulonglong; pub type basic_string_value_type = ::std::os::raw::c_char; pub type basic_string_pointer = *mut basic_string_value_type; #[repr(C)] -#[derive(Debug, Copy, Clone)] +#[derive(Debug, Copy, Clone, Hash)] pub struct basic_string___long { pub __cap_: basic_string_size_type, pub __size_: basic_string_size_type, @@ -52,13 +55,13 @@ pub const basic_string___min_cap: basic_string__bindgen_ty_1 = #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub enum basic_string__bindgen_ty_1 { __min_cap = 0, } #[repr(C)] -#[derive(Debug, Copy, Clone)] +#[derive(Debug, Copy, Clone, Hash)] pub struct basic_string___short { pub __bindgen_anon_1: basic_string___short__bindgen_ty_1, pub __data_: *mut basic_string_value_type, } #[repr(C)] -#[derive(Debug, Default, Copy, Clone)] +#[derive(Debug, Default, Copy, Clone, Hash)] pub struct basic_string___short__bindgen_ty_1 { pub __size_: __BindgenUnionField<::std::os::raw::c_uchar>, pub __lx: __BindgenUnionField<basic_string_value_type>, @@ -83,7 +86,7 @@ pub const basic_string___n_words: basic_string__bindgen_ty_2 = #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub enum basic_string__bindgen_ty_2 { __n_words = 0, } #[repr(C)] -#[derive(Debug, Copy, Clone)] +#[derive(Debug, Copy, Clone, Hash)] pub struct basic_string___raw { pub __words: *mut basic_string_size_type, } diff --git a/tests/expectations/tests/typeref.rs b/tests/expectations/tests/typeref.rs index 53119f09..43427f08 100644 --- a/tests/expectations/tests/typeref.rs +++ b/tests/expectations/tests/typeref.rs @@ -28,8 +28,11 @@ 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) { } +} #[repr(C)] -#[derive(Debug, Default, Copy)] +#[derive(Debug, Default, Copy, Hash)] pub struct nsFoo { pub mBar: mozilla_StyleShapeSource, } @@ -49,7 +52,7 @@ impl Clone for nsFoo { fn clone(&self) -> Self { *self } } #[repr(C)] -#[derive(Debug, Default, Copy)] +#[derive(Debug, Default, Copy, Hash)] pub struct mozilla_FragmentOrURL { pub mIsLocalRef: bool, } @@ -71,7 +74,7 @@ impl Clone for mozilla_FragmentOrURL { fn clone(&self) -> Self { *self } } #[repr(C)] -#[derive(Debug, Default, Copy)] +#[derive(Debug, Default, Copy, Hash)] pub struct mozilla_Position { pub _address: u8, } @@ -86,19 +89,19 @@ impl Clone for mozilla_Position { fn clone(&self) -> Self { *self } } #[repr(C)] -#[derive(Debug, Default, Copy, Clone)] +#[derive(Debug, Default, Copy, Clone, Hash)] pub struct mozilla_StyleShapeSource { pub __bindgen_anon_1: mozilla_StyleShapeSource__bindgen_ty_1, } #[repr(C)] -#[derive(Debug, Default, Copy, Clone)] +#[derive(Debug, Default, Copy, Clone, Hash)] pub struct mozilla_StyleShapeSource__bindgen_ty_1 { pub mPosition: __BindgenUnionField<*mut mozilla_Position>, pub mFragmentOrURL: __BindgenUnionField<*mut mozilla_FragmentOrURL>, pub bindgen_union_field: u64, } #[repr(C)] -#[derive(Debug, Copy)] +#[derive(Debug, Copy, Hash)] pub struct Bar { pub mFoo: *mut nsFoo, } diff --git a/tests/expectations/tests/use-core.rs b/tests/expectations/tests/use-core.rs index 14ac1373..fd89783f 100644 --- a/tests/expectations/tests/use-core.rs +++ b/tests/expectations/tests/use-core.rs @@ -29,8 +29,11 @@ impl <T> ::core::fmt::Debug for __BindgenUnionField<T> { fmt.write_str("__BindgenUnionField") } } +impl <T> ::core::hash::Hash for __BindgenUnionField<T> { + fn hash<H: ::core::hash::Hasher>(&self, _state: &mut H) { } +} #[repr(C)] -#[derive(Debug, Copy)] +#[derive(Debug, Copy, Hash)] pub struct foo { pub a: ::std::os::raw::c_int, pub b: ::std::os::raw::c_int, @@ -65,7 +68,7 @@ impl Default for foo { fn default() -> Self { unsafe { ::core::mem::zeroed() } } } #[repr(C)] -#[derive(Debug, Default, Copy)] +#[derive(Debug, Default, Copy, Hash)] pub struct _bindgen_ty_1 { pub bar: __BindgenUnionField<::std::os::raw::c_int>, pub baz: __BindgenUnionField<::std::os::raw::c_long>, diff --git a/tests/headers/16-byte-alignment.h b/tests/headers/16-byte-alignment.h index 7a7f7548..cca4d285 100644 --- a/tests/headers/16-byte-alignment.h +++ b/tests/headers/16-byte-alignment.h @@ -1,3 +1,4 @@ +// bindgen-flags: --with-derive-hash typedef unsigned char uint8_t; typedef unsigned short uint16_t; diff --git a/tests/headers/char.h b/tests/headers/char.h index ae38653e..8db9ccf0 100644 --- a/tests/headers/char.h +++ b/tests/headers/char.h @@ -1,3 +1,5 @@ +// bindgen-flags: --with-derive-hash +// typedef char Char; typedef signed char SChar; typedef unsigned char UChar; diff --git a/tests/headers/issue-493.hpp b/tests/headers/issue-493.hpp index 975ef5ce..ea39c83c 100644 --- a/tests/headers/issue-493.hpp +++ b/tests/headers/issue-493.hpp @@ -1,3 +1,4 @@ +// bindgen-flags: --with-derive-hash template<class _CharT, class _Traits, class _Allocator> class basic_string { @@ -44,4 +45,4 @@ public: __raw __r; }; }; -};
\ No newline at end of file +}; diff --git a/tests/headers/typeref.hpp b/tests/headers/typeref.hpp index b94c98ef..c417bdb6 100644 --- a/tests/headers/typeref.hpp +++ b/tests/headers/typeref.hpp @@ -1,3 +1,4 @@ +// bindgen-flags: --with-derive-hash struct nsFoo; namespace mozilla { diff --git a/tests/headers/use-core.h b/tests/headers/use-core.h index 0e8a8d6e..b34a71e7 100644 --- a/tests/headers/use-core.h +++ b/tests/headers/use-core.h @@ -1,4 +1,4 @@ -// bindgen-flags: --use-core --raw-line "extern crate core;" +// bindgen-flags: --use-core --raw-line "extern crate core;" --with-derive-hash struct foo { int a, b; |