From 8aa41d195b278d36b9cde9d17c01f5651d9b79b3 Mon Sep 17 00:00:00 2001 From: Zhiting Zhu Date: Wed, 16 Aug 2017 19:34:51 -0500 Subject: [PATCH 01/12] Can derive Eq --- src/codegen/mod.rs | 15 ++- src/ir/analysis/has_float.rs | 239 +++++++++++++++++++++++++++++++++++ src/ir/analysis/mod.rs | 2 + src/ir/context.rs | 51 ++++++-- src/ir/derive.rs | 16 +++ src/ir/item.rs | 32 ++++- src/lib.rs | 23 ++++ src/options.rs | 7 + 8 files changed, 374 insertions(+), 11 deletions(-) create mode 100644 src/ir/analysis/has_float.rs diff --git a/src/codegen/mod.rs b/src/codegen/mod.rs index 2ab507da6e..7066003bd7 100644 --- a/src/codegen/mod.rs +++ b/src/codegen/mod.rs @@ -15,7 +15,7 @@ use ir::comp::{Base, Bitfield, BitfieldUnit, CompInfo, CompKind, Field, FieldData, FieldMethods, Method, MethodKind}; use ir::context::{BindgenContext, ItemId}; use ir::derive::{CanDeriveCopy, CanDeriveDebug, CanDeriveDefault, - CanDeriveHash, CanDerivePartialEq}; + CanDeriveHash, CanDerivePartialEq, CanDeriveEq}; use ir::dot; use ir::enum_ty::{Enum, EnumVariant, EnumVariantValue}; use ir::function::{Abi, Function, FunctionSig}; @@ -1516,6 +1516,10 @@ impl CodeGenerator for CompInfo { derives.push("PartialEq"); } + if item.can_derive_eq(ctx) { + derives.push("Eq"); + } + if !derives.is_empty() { attributes.push(attributes::derives(&derives)) } @@ -3617,6 +3621,12 @@ mod utils { } ).unwrap(); + let union_field_eq_impl = quote_item!(&ctx.ext_cx(), + impl ::$prefix::cmp::Eq for __BindgenUnionField { + } + ) + .unwrap(); + let items = vec![union_field_decl, union_field_impl, union_field_default_impl, @@ -3624,7 +3634,8 @@ mod utils { union_field_copy_impl, union_field_debug_impl, union_field_hash_impl, - union_field_partialeq_impl]; + union_field_partialeq_impl, + union_field_eq_impl]; let old_items = mem::replace(result, items); result.extend(old_items.into_iter()); diff --git a/src/ir/analysis/has_float.rs b/src/ir/analysis/has_float.rs new file mode 100644 index 0000000000..85fe241e77 --- /dev/null +++ b/src/ir/analysis/has_float.rs @@ -0,0 +1,239 @@ +//! Determining which types has float. + +use super::{ConstrainResult, MonotoneFramework, generate_dependencies}; +use std::collections::HashSet; +use std::collections::HashMap; +use ir::context::{BindgenContext, ItemId}; +use ir::traversal::EdgeKind; +use ir::ty::TypeKind; +use ir::comp::Field; +use ir::comp::FieldMethods; + +/// An analysis that finds for each IR item whether it has float or not. +/// +/// We use the monotone constraint function `has_float`, +/// defined as follows: +/// +/// * If T is float or complex float, T trivially has. +/// * If T is a type alias, a templated alias or an indirection to another type, +/// it has float if the type T refers to has. +/// * If T is a compound type, it has float if any of base memter or field +/// has. +/// * If T is an instantiation of an abstract template definition, T has +/// float if any of the template arguments or template definition +/// has. +#[derive(Debug, Clone)] +pub struct HasFloat<'ctx, 'gen> + where 'gen: 'ctx +{ + ctx: &'ctx BindgenContext<'gen>, + + // The incremental result of this analysis's computation. Everything in this + // set has float. + has_float: HashSet, + + // Dependencies saying that if a key ItemId has been inserted into the + // `has_float` set, then each of the ids in Vec need to be + // considered again. + // + // This is a subset of the natural IR graph with reversed edges, where we + // only include the edges from the IR graph that can affect whether a type + // has float or not. + dependencies: HashMap>, +} + +impl<'ctx, 'gen> HasFloat<'ctx, 'gen> { + fn consider_edge(kind: EdgeKind) -> bool { + match kind { + EdgeKind::BaseMember | + EdgeKind::Field | + EdgeKind::TypeReference | + EdgeKind::VarType | + EdgeKind::TemplateArgument | + EdgeKind::TemplateDeclaration | + EdgeKind::TemplateParameterDefinition => true, + + EdgeKind::Constructor | + EdgeKind::Destructor | + EdgeKind::FunctionReturn | + EdgeKind::FunctionParameter | + EdgeKind::InnerType | + EdgeKind::InnerVar | + EdgeKind::Method => false, + EdgeKind::Generic => false, + } + } + + fn insert(&mut self, id: ItemId) -> ConstrainResult { + trace!("inserting {:?} into the has_float set", id); + + let was_not_already_in_set = self.has_float.insert(id); + assert!( + was_not_already_in_set, + "We shouldn't try and insert {:?} twice because if it was \ + already in the set, `constrain` should have exited early.", + id + ); + + ConstrainResult::Changed + } +} + +impl<'ctx, 'gen> MonotoneFramework for HasFloat<'ctx, 'gen> { + type Node = ItemId; + type Extra = &'ctx BindgenContext<'gen>; + type Output = HashSet; + + fn new(ctx: &'ctx BindgenContext<'gen>) -> HasFloat<'ctx, 'gen> { + let has_float = HashSet::new(); + let dependencies = generate_dependencies(ctx, Self::consider_edge); + + HasFloat { + ctx, + has_float, + dependencies, + } + } + + fn initial_worklist(&self) -> Vec { + self.ctx.whitelisted_items().iter().cloned().collect() + } + + fn constrain(&mut self, id: ItemId) -> ConstrainResult { + trace!("constrain: {:?}", id); + + if self.has_float.contains(&id) { + trace!(" already know it do not have float"); + return ConstrainResult::Same; + } + + let item = self.ctx.resolve_item(id); + let ty = match item.as_type() { + Some(ty) => ty, + None => { + trace!(" not a type; ignoring"); + return ConstrainResult::Same; + } + }; + + match *ty.kind() { + TypeKind::Void | + TypeKind::NullPtr | + TypeKind::Int(..) | + TypeKind::Function(..) | + TypeKind::Enum(..) | + TypeKind::Reference(..) | + TypeKind::BlockPointer | + TypeKind::TypeParam | + TypeKind::Opaque | + TypeKind::Pointer(..) | + TypeKind::UnresolvedTypeRef(..) | + TypeKind::ObjCInterface(..) | + TypeKind::ObjCId | + TypeKind::ObjCSel => { + trace!(" simple type that do not have float"); + ConstrainResult::Same + } + + TypeKind::Float(..) | + TypeKind::Complex(..) => { + trace!(" float type has float"); + self.insert(id) + } + + TypeKind::Array(t, _) => { + if self.has_float.contains(&t) { + trace!(" Array with type T that has float also has float"); + return self.insert(id) + } + trace!(" Array with type T that do not have float also do not have float"); + ConstrainResult::Same + } + + TypeKind::ResolvedTypeRef(t) | + TypeKind::TemplateAlias(t, _) | + TypeKind::Alias(t) => { + if self.has_float.contains(&t) { + trace!(" aliases and type refs to T which have float \ + also have float"); + self.insert(id) + } else { + trace!(" aliases and type refs to T which do not have float \ + also do not have floaarrayt"); + ConstrainResult::Same + } + } + + TypeKind::Comp(ref info) => { + let bases_have = info.base_members() + .iter() + .any(|base| self.has_float.contains(&base.ty)); + if bases_have { + trace!(" bases have float, so we also have"); + return self.insert(id); + } + let fields_have = info.fields() + .iter() + .any(|f| { + match *f { + Field::DataMember(ref data) => { + self.has_float.contains(&data.ty()) + } + Field::Bitfields(ref bfu) => { + bfu.bitfields() + .iter().any(|b| { + self.has_float.contains(&b.ty()) + }) + }, + } + }); + if fields_have { + trace!(" fields have float, so we also have"); + return self.insert(id); + } + + trace!(" comp doesn't have float"); + ConstrainResult::Same + } + + TypeKind::TemplateInstantiation(ref template) => { + let args_have = template.template_arguments() + .iter() + .any(|arg| self.has_float.contains(&arg)); + if args_have { + trace!(" template args have float, so \ + insantiation also has float"); + return self.insert(id); + } + + let def_has = self.has_float + .contains(&template.template_definition()); + if def_has { + trace!(" template definition has float, so \ + insantiation also has"); + return self.insert(id); + } + + trace!(" template instantiation do not have float"); + ConstrainResult::Same + } + } + } + + fn each_depending_on(&self, id: ItemId, mut f: F) + where F: FnMut(ItemId), + { + if let Some(edges) = self.dependencies.get(&id) { + for item in edges { + trace!("enqueue {:?} into worklist", item); + f(*item); + } + } + } +} + +impl<'ctx, 'gen> From> for HashSet { + fn from(analysis: HasFloat<'ctx, 'gen>) -> Self { + analysis.has_float + } +} diff --git a/src/ir/analysis/mod.rs b/src/ir/analysis/mod.rs index cf4e3b4d36..42aa4a8f10 100644 --- a/src/ir/analysis/mod.rs +++ b/src/ir/analysis/mod.rs @@ -55,6 +55,8 @@ mod derive_hash; pub use self::derive_hash::CannotDeriveHash; mod derive_partial_eq; pub use self::derive_partial_eq::CannotDerivePartialEq; +mod has_float; +pub use self::has_float::HasFloat; use ir::context::{BindgenContext, ItemId}; use ir::traversal::{EdgeKind, Trace}; diff --git a/src/ir/context.rs b/src/ir/context.rs index eb599dd0ac..67245c295c 100644 --- a/src/ir/context.rs +++ b/src/ir/context.rs @@ -3,9 +3,10 @@ use super::analysis::{CannotDeriveCopy, CannotDeriveDebug, CannotDeriveDefault, CannotDeriveHash, CannotDerivePartialEq, HasTypeParameterInArray, - HasVtableAnalysis, UsedTemplateParameters, analyze}; + HasVtableAnalysis, UsedTemplateParameters, HasFloat, + analyze}; use super::derive::{CanDeriveCopy, CanDeriveDebug, CanDeriveDefault, - CanDeriveHash, CanDerivePartialEq}; + CanDeriveHash, CanDerivePartialEq, CanDeriveEq}; use super::int::IntKind; use super::item::{HasTypeParamInArray, IsOpaque, Item, ItemAncestors, ItemCanonicalPath, ItemSet}; @@ -76,6 +77,14 @@ impl CanDerivePartialEq for ItemId { } } +impl CanDeriveEq for ItemId { + fn can_derive_eq(&self, ctx: &BindgenContext) -> bool { + ctx.options().derive_eq && + ctx.lookup_item_id_can_derive_partialeq(*self) && + !ctx.lookup_item_id_has_float(&self) + } +} + /// A key used to index a resolved type, so we only process it once. /// /// This is almost always a USR string (an unique identifier generated by @@ -235,6 +244,12 @@ pub struct BindgenContext<'ctx> { /// Populated when we enter codegen by `compute_has_type_param_in_array`; always `None` /// before that and `Some` after. has_type_param_in_array: Option>, + + /// The set of (`ItemId's of`) types that has float. + /// + /// Populated when we enter codegen by `compute_has_float`; always `None` + /// before that and `Some` after. + has_float: Option>, } /// A traversal of whitelisted items. @@ -376,6 +391,7 @@ impl<'ctx> BindgenContext<'ctx> { cannot_derive_partialeq: None, have_vtable: None, has_type_param_in_array: None, + has_float: None, }; me.add_item(root_module, None, None); @@ -890,8 +906,9 @@ impl<'ctx> BindgenContext<'ctx> { self.compute_cannot_derive_default(); self.compute_cannot_derive_copy(); self.compute_has_type_param_in_array(); + self.compute_has_float(); self.compute_cannot_derive_hash(); - self.compute_cannot_derive_partialeq(); + self.compute_cannot_derive_partialeq_or_eq(); let ret = cb(self); self.gen_ctx = None; @@ -2018,12 +2035,12 @@ impl<'ctx> BindgenContext<'ctx> { !self.cannot_derive_hash.as_ref().unwrap().contains(&id) } - /// Compute whether we can derive partialeq. - fn compute_cannot_derive_partialeq(&mut self) { + /// Compute whether we can derive PartialEq. This method is also used in calculating + /// whether we can derive Eq + fn compute_cannot_derive_partialeq_or_eq(&mut self) { assert!(self.cannot_derive_partialeq.is_none()); - if self.options.derive_partialeq { - self.cannot_derive_partialeq = - Some(analyze::(self)); + if self.options.derive_partialeq || self.options.derive_eq { + self.cannot_derive_partialeq = Some(analyze::(self)); } } @@ -2072,6 +2089,24 @@ impl<'ctx> BindgenContext<'ctx> { // type parameter in array or not. self.has_type_param_in_array.as_ref().unwrap().contains(id) } + + /// Compute whether the type has float. + fn compute_has_float(&mut self) { + assert!(self.has_float.is_none()); + if self.options.derive_eq { + self.has_float = Some(analyze::(self)); + } + } + + /// Look up whether the item with `id` has array or not. + pub fn lookup_item_id_has_float(&self, id: &ItemId) -> bool { + assert!(self.in_codegen_phase(), + "We only compute has float when we enter codegen"); + + // Look up the computed value for whether the item with `id` has + // float or not. + self.has_float.as_ref().unwrap().contains(id) + } } /// A builder struct for configuring item resolution options. diff --git a/src/ir/derive.rs b/src/ir/derive.rs index ef5116941e..909d5e4242 100644 --- a/src/ir/derive.rs +++ b/src/ir/derive.rs @@ -92,6 +92,22 @@ pub trait CanDerivePartialEq { fn can_derive_partialeq(&self, ctx: &BindgenContext) -> bool; } +/// A trait that encapsulates the logic for whether or not we can derive `Eq` +/// for a given thing. +/// +/// This should ideally be a no-op that just returns `true`, but instead needs +/// to be a recursive method that checks whether all the proper members can +/// derive eq or not, because of the limit rust has on 32 items as max in the +/// array. +pub trait CanDeriveEq { + + /// Return `true` if `Eq` can be derived for this thing, `false` + /// otherwise. + fn can_derive_eq(&self, + ctx: &BindgenContext) + -> bool; +} + /// A trait that encapsulates the logic for whether or not we can derive `Hash`. /// The difference between this trait and the CanDeriveHash is that the type /// implementing this trait cannot use recursion or lookup result from fix point diff --git a/src/ir/item.rs b/src/ir/item.rs index dfb2697ddb..b6fe6d4392 100644 --- a/src/ir/item.rs +++ b/src/ir/item.rs @@ -6,7 +6,7 @@ use super::comment; use super::comp::MethodKind; use super::context::{BindgenContext, ItemId, PartialType}; use super::derive::{CanDeriveCopy, CanDeriveDebug, CanDeriveDefault, - CanDeriveHash, CanDerivePartialEq}; + CanDeriveHash, CanDerivePartialEq, CanDeriveEq}; use super::dot::DotAttributes; use super::function::{Function, FunctionKind}; use super::item_kind::ItemKind; @@ -83,6 +83,12 @@ pub trait HasTypeParamInArray { fn has_type_param_in_array(&self, ctx: &BindgenContext) -> bool; } +/// A trait for determining if some IR thing has float or not. +pub trait HasFloat { + /// Returns `true` if the thing has float, and `false` otherwise. + fn has_float(&self, ctx: &BindgenContext) -> bool; +} + /// A trait for iterating over an item and its parents and up its ancestor chain /// up to (but not including) the implicit root module. pub trait ItemAncestors { @@ -340,6 +346,14 @@ impl CanDerivePartialEq for Item { } } +impl CanDeriveEq for Item { + fn can_derive_eq(&self, ctx: &BindgenContext) -> bool { + ctx.options().derive_eq && + ctx.lookup_item_id_can_derive_partialeq(self.id()) && + !ctx.lookup_item_id_has_float(&self.id()) + } +} + /// An item is the base of the bindgen representation, it can be either a /// module, a type, a function, or a variable (see `ItemKind` for more /// information). @@ -989,6 +1003,22 @@ impl HasTypeParamInArray for Item { } } +impl HasFloat for ItemId { + fn has_float(&self, ctx: &BindgenContext) -> bool { + debug_assert!(ctx.in_codegen_phase(), + "You're not supposed to call this yet"); + ctx.lookup_item_id_has_float(self) + } +} + +impl HasFloat for Item { + fn has_float(&self, ctx: &BindgenContext) -> bool { + debug_assert!(ctx.in_codegen_phase(), + "You're not supposed to call this yet"); + ctx.lookup_item_id_has_float(&self.id()) + } +} + /// A set of items. pub type ItemSet = BTreeSet; diff --git a/src/lib.rs b/src/lib.rs index 3954ee2679..d5dbefae60 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -274,6 +274,10 @@ impl Builder { output_vector.push("--with-derive-partialeq".into()); } + if self.options.derive_eq { + output_vector.push("--with-derive-eq".into()); + } + if !self.options.generate_comments { output_vector.push("--no-doc-comments".into()); } @@ -751,7 +755,21 @@ impl Builder { } /// Set whether `PartialEq` should be derived by default. + /// If we don't compute partialeq, we also cannot compute + /// eq. Set the derive_eq to `false` when doit is `false`. pub fn derive_partialeq(mut self, doit: bool) -> Self { + self.options.derive_partialeq = doit; + if !doit { + self.options.derive_eq = false; + } + self + } + + /// Set whether `Eq` should be derived by default. + /// We can't compute Eq without computing PartialEq, so + /// we set the same option to derive_partialeq. + pub fn derive_eq(mut self, doit: bool) -> Self { + self.options.derive_eq = doit; self.options.derive_partialeq = doit; self } @@ -1094,6 +1112,10 @@ pub struct BindgenOptions { /// and types. pub derive_partialeq: bool, + /// True if we should derive Eq trait implementations for C/C++ structures + /// and types. + pub derive_eq: bool, + /// True if we should avoid using libstd to use libcore instead. pub use_core: bool, @@ -1237,6 +1259,7 @@ impl Default for BindgenOptions { derive_default: false, derive_hash: false, derive_partialeq: false, + derive_eq: false, enable_cxx_namespaces: false, disable_name_namespacing: false, use_core: false, diff --git a/src/options.rs b/src/options.rs index 68b127ae0d..780959e2f4 100644 --- a/src/options.rs +++ b/src/options.rs @@ -81,6 +81,9 @@ where Arg::with_name("with-derive-partialeq") .long("with-derive-partialeq") .help("Derive partialeq on any type."), + Arg::with_name("with-derive-eq") + .long("with-derive-eq") + .help("Derive eq on any type. Enable this option also enables --with-derive-partialeq"), Arg::with_name("no-doc-comments") .long("no-doc-comments") .help("Avoid including doc comments in the output, see: \ @@ -325,6 +328,10 @@ where builder = builder.derive_partialeq(true); } + if matches.is_present("with-derive-eq") { + builder = builder.derive_eq(true); + } + if matches.is_present("no-derive-default") { builder = builder.derive_default(false); } From 8778ecd8dd10b0db25637ede6bae78c4869cf368 Mon Sep 17 00:00:00 2001 From: Zhiting Zhu Date: Wed, 16 Aug 2017 19:38:20 -0500 Subject: [PATCH 02/12] Union related tests for can derive Eq --- tests/expectations/tests/union-in-ns_1_0.rs | 1 + tests/expectations/tests/union_dtor_1_0.rs | 1 + tests/expectations/tests/union_fields_1_0.rs | 1 + tests/expectations/tests/union_template_1_0.rs | 9 +++++---- tests/expectations/tests/union_with_anon_struct.rs | 2 +- tests/expectations/tests/union_with_anon_struct_1_0.rs | 5 +++-- .../tests/union_with_anon_struct_bitfield.rs | 2 +- .../tests/union_with_anon_struct_bitfield_1_0.rs | 5 +++-- tests/expectations/tests/union_with_anon_union_1_0.rs | 5 +++-- .../expectations/tests/union_with_anon_unnamed_struct.rs | 2 +- .../tests/union_with_anon_unnamed_struct_1_0.rs | 5 +++-- .../tests/union_with_anon_unnamed_union_1_0.rs | 5 +++-- tests/expectations/tests/union_with_big_member_1_0.rs | 3 ++- tests/expectations/tests/union_with_nesting_1_0.rs | 9 +++++---- tests/headers/union_fields.hpp | 2 +- tests/headers/union_fields_1_0.hpp | 2 +- tests/headers/union_template.hpp | 2 +- tests/headers/union_template_1_0.hpp | 2 +- tests/headers/union_with_anon_struct.h | 2 +- tests/headers/union_with_anon_struct_1_0.h | 2 +- tests/headers/union_with_anon_struct_bitfield.h | 2 +- tests/headers/union_with_anon_struct_bitfield_1_0.h | 2 +- tests/headers/union_with_anon_union.h | 2 +- tests/headers/union_with_anon_union_1_0.h | 2 +- tests/headers/union_with_anon_unnamed_struct.h | 2 +- tests/headers/union_with_anon_unnamed_struct_1_0.h | 2 +- tests/headers/union_with_anon_unnamed_union.h | 2 +- tests/headers/union_with_anon_unnamed_union_1_0.h | 2 +- tests/headers/union_with_big_member.h | 2 +- tests/headers/union_with_big_member_1_0.h | 2 +- tests/headers/union_with_nesting.h | 2 +- tests/headers/union_with_nesting_1_0.h | 2 +- 32 files changed, 51 insertions(+), 40 deletions(-) diff --git a/tests/expectations/tests/union-in-ns_1_0.rs b/tests/expectations/tests/union-in-ns_1_0.rs index aea426f494..b3618ab7a6 100644 --- a/tests/expectations/tests/union-in-ns_1_0.rs +++ b/tests/expectations/tests/union-in-ns_1_0.rs @@ -40,6 +40,7 @@ pub mod root { impl ::std::cmp::PartialEq for __BindgenUnionField { fn eq(&self, _other: &__BindgenUnionField) -> bool { true } } + impl ::std::cmp::Eq for __BindgenUnionField { } #[allow(unused_imports)] use self::super::root; #[repr(C)] diff --git a/tests/expectations/tests/union_dtor_1_0.rs b/tests/expectations/tests/union_dtor_1_0.rs index 47ed49c250..2c8f80d7a1 100644 --- a/tests/expectations/tests/union_dtor_1_0.rs +++ b/tests/expectations/tests/union_dtor_1_0.rs @@ -34,6 +34,7 @@ impl ::std::hash::Hash for __BindgenUnionField { impl ::std::cmp::PartialEq for __BindgenUnionField { fn eq(&self, _other: &__BindgenUnionField) -> bool { true } } +impl ::std::cmp::Eq for __BindgenUnionField { } #[repr(C)] #[derive(Debug, Default)] pub struct UnionWithDtor { diff --git a/tests/expectations/tests/union_fields_1_0.rs b/tests/expectations/tests/union_fields_1_0.rs index 2bbd90eddd..3f244b787d 100644 --- a/tests/expectations/tests/union_fields_1_0.rs +++ b/tests/expectations/tests/union_fields_1_0.rs @@ -34,6 +34,7 @@ impl ::std::hash::Hash for __BindgenUnionField { impl ::std::cmp::PartialEq for __BindgenUnionField { fn eq(&self, _other: &__BindgenUnionField) -> bool { true } } +impl ::std::cmp::Eq for __BindgenUnionField { } #[repr(C)] #[derive(Debug, Default, Copy, Hash, PartialEq)] pub struct nsStyleUnion { diff --git a/tests/expectations/tests/union_template_1_0.rs b/tests/expectations/tests/union_template_1_0.rs index f322be6487..afe14c7018 100644 --- a/tests/expectations/tests/union_template_1_0.rs +++ b/tests/expectations/tests/union_template_1_0.rs @@ -34,29 +34,30 @@ impl ::std::hash::Hash for __BindgenUnionField { impl ::std::cmp::PartialEq for __BindgenUnionField { fn eq(&self, _other: &__BindgenUnionField) -> bool { true } } +impl ::std::cmp::Eq for __BindgenUnionField { } #[repr(C)] -#[derive(Debug, Default, Copy, Clone, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct NastyStruct { pub mIsSome: bool, pub mStorage: NastyStruct__bindgen_ty_1, pub __bindgen_anon_1: NastyStruct__bindgen_ty_2, } #[repr(C)] -#[derive(Debug, Default, Copy, Clone, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct NastyStruct__bindgen_ty_1 { pub mFoo: __BindgenUnionField<*mut ::std::os::raw::c_void>, pub mDummy: __BindgenUnionField<::std::os::raw::c_ulong>, pub bindgen_union_field: u64, } #[repr(C)] -#[derive(Debug, Default, Copy, Clone, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct NastyStruct__bindgen_ty_2 { pub wat: __BindgenUnionField<::std::os::raw::c_short>, pub wut: __BindgenUnionField<*mut ::std::os::raw::c_int>, pub bindgen_union_field: u64, } #[repr(C)] -#[derive(Debug, Default, Copy, Clone, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct Whatever { pub mTPtr: __BindgenUnionField<*mut ::std::os::raw::c_void>, pub mInt: __BindgenUnionField<::std::os::raw::c_int>, diff --git a/tests/expectations/tests/union_with_anon_struct.rs b/tests/expectations/tests/union_with_anon_struct.rs index 3526e6741f..d48538a0cb 100644 --- a/tests/expectations/tests/union_with_anon_struct.rs +++ b/tests/expectations/tests/union_with_anon_struct.rs @@ -11,7 +11,7 @@ pub union foo { _bindgen_union_align: [u32; 2usize], } #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct foo__bindgen_ty_1 { pub a: ::std::os::raw::c_uint, pub b: ::std::os::raw::c_uint, diff --git a/tests/expectations/tests/union_with_anon_struct_1_0.rs b/tests/expectations/tests/union_with_anon_struct_1_0.rs index a04b59db04..8c0971f7bc 100644 --- a/tests/expectations/tests/union_with_anon_struct_1_0.rs +++ b/tests/expectations/tests/union_with_anon_struct_1_0.rs @@ -34,14 +34,15 @@ impl ::std::hash::Hash for __BindgenUnionField { impl ::std::cmp::PartialEq for __BindgenUnionField { fn eq(&self, _other: &__BindgenUnionField) -> bool { true } } +impl ::std::cmp::Eq for __BindgenUnionField { } #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct foo { pub bar: __BindgenUnionField, pub bindgen_union_field: [u32; 2usize], } #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct foo__bindgen_ty_1 { pub a: ::std::os::raw::c_uint, pub b: ::std::os::raw::c_uint, diff --git a/tests/expectations/tests/union_with_anon_struct_bitfield.rs b/tests/expectations/tests/union_with_anon_struct_bitfield.rs index 68ba92e485..c258f90125 100644 --- a/tests/expectations/tests/union_with_anon_struct_bitfield.rs +++ b/tests/expectations/tests/union_with_anon_struct_bitfield.rs @@ -12,7 +12,7 @@ pub union foo { _bindgen_union_align: u32, } #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct foo__bindgen_ty_1 { pub _bitfield_1: u32, pub __bindgen_align: [u32; 0usize], diff --git a/tests/expectations/tests/union_with_anon_struct_bitfield_1_0.rs b/tests/expectations/tests/union_with_anon_struct_bitfield_1_0.rs index 29ca26ccc5..53faf3a4bb 100644 --- a/tests/expectations/tests/union_with_anon_struct_bitfield_1_0.rs +++ b/tests/expectations/tests/union_with_anon_struct_bitfield_1_0.rs @@ -34,15 +34,16 @@ impl ::std::hash::Hash for __BindgenUnionField { impl ::std::cmp::PartialEq for __BindgenUnionField { fn eq(&self, _other: &__BindgenUnionField) -> bool { true } } +impl ::std::cmp::Eq for __BindgenUnionField { } #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct foo { pub a: __BindgenUnionField<::std::os::raw::c_int>, pub __bindgen_anon_1: __BindgenUnionField, pub bindgen_union_field: u32, } #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct foo__bindgen_ty_1 { pub _bitfield_1: u32, pub __bindgen_align: [u32; 0usize], diff --git a/tests/expectations/tests/union_with_anon_union_1_0.rs b/tests/expectations/tests/union_with_anon_union_1_0.rs index 0a96374f28..62a62f85d6 100644 --- a/tests/expectations/tests/union_with_anon_union_1_0.rs +++ b/tests/expectations/tests/union_with_anon_union_1_0.rs @@ -34,14 +34,15 @@ impl ::std::hash::Hash for __BindgenUnionField { impl ::std::cmp::PartialEq for __BindgenUnionField { fn eq(&self, _other: &__BindgenUnionField) -> bool { true } } +impl ::std::cmp::Eq for __BindgenUnionField { } #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct foo { pub bar: __BindgenUnionField, pub bindgen_union_field: u32, } #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct foo__bindgen_ty_1 { pub a: __BindgenUnionField<::std::os::raw::c_uint>, pub b: __BindgenUnionField<::std::os::raw::c_ushort>, diff --git a/tests/expectations/tests/union_with_anon_unnamed_struct.rs b/tests/expectations/tests/union_with_anon_unnamed_struct.rs index d5734f03c7..61b36d1aa7 100644 --- a/tests/expectations/tests/union_with_anon_unnamed_struct.rs +++ b/tests/expectations/tests/union_with_anon_unnamed_struct.rs @@ -12,7 +12,7 @@ pub union pixel { _bindgen_union_align: u32, } #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct pixel__bindgen_ty_1 { pub r: ::std::os::raw::c_uchar, pub g: ::std::os::raw::c_uchar, diff --git a/tests/expectations/tests/union_with_anon_unnamed_struct_1_0.rs b/tests/expectations/tests/union_with_anon_unnamed_struct_1_0.rs index 277071afda..45d824bae3 100644 --- a/tests/expectations/tests/union_with_anon_unnamed_struct_1_0.rs +++ b/tests/expectations/tests/union_with_anon_unnamed_struct_1_0.rs @@ -34,15 +34,16 @@ impl ::std::hash::Hash for __BindgenUnionField { impl ::std::cmp::PartialEq for __BindgenUnionField { fn eq(&self, _other: &__BindgenUnionField) -> bool { true } } +impl ::std::cmp::Eq for __BindgenUnionField { } #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct pixel { pub rgba: __BindgenUnionField<::std::os::raw::c_uint>, pub __bindgen_anon_1: __BindgenUnionField, pub bindgen_union_field: u32, } #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct pixel__bindgen_ty_1 { pub r: ::std::os::raw::c_uchar, pub g: ::std::os::raw::c_uchar, diff --git a/tests/expectations/tests/union_with_anon_unnamed_union_1_0.rs b/tests/expectations/tests/union_with_anon_unnamed_union_1_0.rs index 3f782a63fb..a33c1ccd0c 100644 --- a/tests/expectations/tests/union_with_anon_unnamed_union_1_0.rs +++ b/tests/expectations/tests/union_with_anon_unnamed_union_1_0.rs @@ -34,15 +34,16 @@ impl ::std::hash::Hash for __BindgenUnionField { impl ::std::cmp::PartialEq for __BindgenUnionField { fn eq(&self, _other: &__BindgenUnionField) -> bool { true } } +impl ::std::cmp::Eq for __BindgenUnionField { } #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct foo { pub a: __BindgenUnionField<::std::os::raw::c_uint>, pub __bindgen_anon_1: __BindgenUnionField, pub bindgen_union_field: u32, } #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct foo__bindgen_ty_1 { pub b: __BindgenUnionField<::std::os::raw::c_ushort>, pub c: __BindgenUnionField<::std::os::raw::c_uchar>, diff --git a/tests/expectations/tests/union_with_big_member_1_0.rs b/tests/expectations/tests/union_with_big_member_1_0.rs index 9ba01a14f7..03226ccef4 100644 --- a/tests/expectations/tests/union_with_big_member_1_0.rs +++ b/tests/expectations/tests/union_with_big_member_1_0.rs @@ -34,6 +34,7 @@ impl ::std::hash::Hash for __BindgenUnionField { impl ::std::cmp::PartialEq for __BindgenUnionField { fn eq(&self, _other: &__BindgenUnionField) -> bool { true } } +impl ::std::cmp::Eq for __BindgenUnionField { } #[repr(C)] #[derive(Copy)] pub struct WithBigArray { @@ -65,7 +66,7 @@ impl Default for WithBigArray { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct WithBigArray2 { pub a: __BindgenUnionField<::std::os::raw::c_int>, pub b: __BindgenUnionField<[::std::os::raw::c_char; 33usize]>, diff --git a/tests/expectations/tests/union_with_nesting_1_0.rs b/tests/expectations/tests/union_with_nesting_1_0.rs index 73192a45ab..138707580f 100644 --- a/tests/expectations/tests/union_with_nesting_1_0.rs +++ b/tests/expectations/tests/union_with_nesting_1_0.rs @@ -34,21 +34,22 @@ impl ::std::hash::Hash for __BindgenUnionField { impl ::std::cmp::PartialEq for __BindgenUnionField { fn eq(&self, _other: &__BindgenUnionField) -> bool { true } } +impl ::std::cmp::Eq for __BindgenUnionField { } #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct foo { pub a: __BindgenUnionField<::std::os::raw::c_uint>, pub __bindgen_anon_1: __BindgenUnionField, pub bindgen_union_field: u32, } #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct foo__bindgen_ty_1 { pub __bindgen_anon_1: foo__bindgen_ty_1__bindgen_ty_1, pub __bindgen_anon_2: foo__bindgen_ty_1__bindgen_ty_2, } #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct foo__bindgen_ty_1__bindgen_ty_1 { pub b1: __BindgenUnionField<::std::os::raw::c_ushort>, pub b2: __BindgenUnionField<::std::os::raw::c_ushort>, @@ -81,7 +82,7 @@ impl Clone for foo__bindgen_ty_1__bindgen_ty_1 { fn clone(&self) -> Self { *self } } #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct foo__bindgen_ty_1__bindgen_ty_2 { pub c1: __BindgenUnionField<::std::os::raw::c_ushort>, pub c2: __BindgenUnionField<::std::os::raw::c_ushort>, diff --git a/tests/headers/union_fields.hpp b/tests/headers/union_fields.hpp index 7397ad5853..7bb2a3ce3b 100644 --- a/tests/headers/union_fields.hpp +++ b/tests/headers/union_fields.hpp @@ -1,4 +1,4 @@ -// bindgen-flags: --with-derive-hash --with-derive-partialeq +// bindgen-flags: --with-derive-hash --with-derive-partialeq --with-derive-eq // typedef union { int mInt; diff --git a/tests/headers/union_fields_1_0.hpp b/tests/headers/union_fields_1_0.hpp index ef0272f0e1..bbb67fbc6e 100644 --- a/tests/headers/union_fields_1_0.hpp +++ b/tests/headers/union_fields_1_0.hpp @@ -1,4 +1,4 @@ -// bindgen-flags: --rust-target 1.0 --with-derive-hash --with-derive-partialeq +// bindgen-flags: --rust-target 1.0 --with-derive-hash --with-derive-partialeq --with-derive-eq typedef union { int mInt; diff --git a/tests/headers/union_template.hpp b/tests/headers/union_template.hpp index fbebb44fcc..8b57f5a0e7 100644 --- a/tests/headers/union_template.hpp +++ b/tests/headers/union_template.hpp @@ -1,4 +1,4 @@ -// bindgen-flags: --with-derive-hash --with-derive-partialeq +// bindgen-flags: --with-derive-hash --with-derive-partialeq --with-derive-eq // template struct NastyStruct { diff --git a/tests/headers/union_template_1_0.hpp b/tests/headers/union_template_1_0.hpp index 65a11b309b..18e3d74a37 100644 --- a/tests/headers/union_template_1_0.hpp +++ b/tests/headers/union_template_1_0.hpp @@ -1,4 +1,4 @@ -// bindgen-flags: --rust-target 1.0 --with-derive-hash --with-derive-partialeq +// bindgen-flags: --rust-target 1.0 --with-derive-hash --with-derive-partialeq --with-derive-eq template struct NastyStruct { diff --git a/tests/headers/union_with_anon_struct.h b/tests/headers/union_with_anon_struct.h index 5968a48c48..b239b2d87a 100644 --- a/tests/headers/union_with_anon_struct.h +++ b/tests/headers/union_with_anon_struct.h @@ -1,4 +1,4 @@ -// bindgen-flags: --with-derive-hash --with-derive-partialeq +// bindgen-flags: --with-derive-hash --with-derive-partialeq --with-derive-eq // union foo { struct { diff --git a/tests/headers/union_with_anon_struct_1_0.h b/tests/headers/union_with_anon_struct_1_0.h index a24f5a90e0..9313299eb0 100644 --- a/tests/headers/union_with_anon_struct_1_0.h +++ b/tests/headers/union_with_anon_struct_1_0.h @@ -1,4 +1,4 @@ -// bindgen-flags: --rust-target 1.0 --with-derive-hash --with-derive-partialeq +// bindgen-flags: --rust-target 1.0 --with-derive-hash --with-derive-partialeq --with-derive-eq union foo { struct { diff --git a/tests/headers/union_with_anon_struct_bitfield.h b/tests/headers/union_with_anon_struct_bitfield.h index 8a6a6a74a8..bbb1ef4189 100644 --- a/tests/headers/union_with_anon_struct_bitfield.h +++ b/tests/headers/union_with_anon_struct_bitfield.h @@ -1,4 +1,4 @@ -// bindgen-flags: --with-derive-hash --with-derive-partialeq +// bindgen-flags: --with-derive-hash --with-derive-partialeq --with-derive-eq // union foo { int a; diff --git a/tests/headers/union_with_anon_struct_bitfield_1_0.h b/tests/headers/union_with_anon_struct_bitfield_1_0.h index ae069c50f4..0b0e3d7371 100644 --- a/tests/headers/union_with_anon_struct_bitfield_1_0.h +++ b/tests/headers/union_with_anon_struct_bitfield_1_0.h @@ -1,4 +1,4 @@ -// bindgen-flags: --rust-target 1.0 --with-derive-hash --with-derive-partialeq +// bindgen-flags: --rust-target 1.0 --with-derive-hash --with-derive-partialeq --with-derive-eq union foo { int a; diff --git a/tests/headers/union_with_anon_union.h b/tests/headers/union_with_anon_union.h index 8f76cbde6c..02b09e2e02 100644 --- a/tests/headers/union_with_anon_union.h +++ b/tests/headers/union_with_anon_union.h @@ -1,4 +1,4 @@ -// bindgen-flags: --with-derive-hash --with-derive-partialeq +// bindgen-flags: --with-derive-hash --with-derive-partialeq --with-derive-eq // union foo { union { diff --git a/tests/headers/union_with_anon_union_1_0.h b/tests/headers/union_with_anon_union_1_0.h index 77876c08d6..28a7231dbf 100644 --- a/tests/headers/union_with_anon_union_1_0.h +++ b/tests/headers/union_with_anon_union_1_0.h @@ -1,4 +1,4 @@ -// bindgen-flags: --rust-target 1.0 --with-derive-hash --with-derive-partialeq +// bindgen-flags: --rust-target 1.0 --with-derive-hash --with-derive-partialeq --with-derive-eq union foo { union { diff --git a/tests/headers/union_with_anon_unnamed_struct.h b/tests/headers/union_with_anon_unnamed_struct.h index 5214db4c73..0490331889 100644 --- a/tests/headers/union_with_anon_unnamed_struct.h +++ b/tests/headers/union_with_anon_unnamed_struct.h @@ -1,4 +1,4 @@ -// bindgen-flags: --with-derive-hash --with-derive-partialeq +// bindgen-flags: --with-derive-hash --with-derive-partialeq --with-derive-eq // union pixel { unsigned int rgba; diff --git a/tests/headers/union_with_anon_unnamed_struct_1_0.h b/tests/headers/union_with_anon_unnamed_struct_1_0.h index a99545351e..506a41f661 100644 --- a/tests/headers/union_with_anon_unnamed_struct_1_0.h +++ b/tests/headers/union_with_anon_unnamed_struct_1_0.h @@ -1,4 +1,4 @@ -// bindgen-flags: --rust-target 1.0 --with-derive-hash --with-derive-partialeq +// bindgen-flags: --rust-target 1.0 --with-derive-hash --with-derive-partialeq --with-derive-eq union pixel { unsigned int rgba; diff --git a/tests/headers/union_with_anon_unnamed_union.h b/tests/headers/union_with_anon_unnamed_union.h index 74345dd898..dbccd5b52f 100644 --- a/tests/headers/union_with_anon_unnamed_union.h +++ b/tests/headers/union_with_anon_unnamed_union.h @@ -1,4 +1,4 @@ -// bindgen-flags: --with-derive-hash --with-derive-partialeq +// bindgen-flags: --with-derive-hash --with-derive-partialeq --with-derive-eq // union foo { unsigned int a; diff --git a/tests/headers/union_with_anon_unnamed_union_1_0.h b/tests/headers/union_with_anon_unnamed_union_1_0.h index bae5577398..c556a61311 100644 --- a/tests/headers/union_with_anon_unnamed_union_1_0.h +++ b/tests/headers/union_with_anon_unnamed_union_1_0.h @@ -1,4 +1,4 @@ -// bindgen-flags: --rust-target 1.0 --with-derive-hash --with-derive-partialeq +// bindgen-flags: --rust-target 1.0 --with-derive-hash --with-derive-partialeq --with-derive-eq union foo { unsigned int a; diff --git a/tests/headers/union_with_big_member.h b/tests/headers/union_with_big_member.h index 7bff36eabc..e8a3fe0a9c 100644 --- a/tests/headers/union_with_big_member.h +++ b/tests/headers/union_with_big_member.h @@ -1,4 +1,4 @@ -// bindgen-flags: --with-derive-hash --with-derive-partialeq +// bindgen-flags: --with-derive-hash --with-derive-partialeq --with-derive-eq // union WithBigArray { int a; diff --git a/tests/headers/union_with_big_member_1_0.h b/tests/headers/union_with_big_member_1_0.h index 2cffd2c5fd..0429435478 100644 --- a/tests/headers/union_with_big_member_1_0.h +++ b/tests/headers/union_with_big_member_1_0.h @@ -1,4 +1,4 @@ -// bindgen-flags: --rust-target 1.0 --with-derive-hash --with-derive-partialeq +// bindgen-flags: --rust-target 1.0 --with-derive-hash --with-derive-partialeq --with-derive-eq union WithBigArray { int a; diff --git a/tests/headers/union_with_nesting.h b/tests/headers/union_with_nesting.h index 95c55581bb..ae25244a04 100644 --- a/tests/headers/union_with_nesting.h +++ b/tests/headers/union_with_nesting.h @@ -1,4 +1,4 @@ -// bindgen-flags: --with-derive-hash --with-derive-partialeq +// bindgen-flags: --with-derive-hash --with-derive-partialeq --with-derive-eq // union foo { unsigned int a; diff --git a/tests/headers/union_with_nesting_1_0.h b/tests/headers/union_with_nesting_1_0.h index e89c321223..3cdb7238bc 100644 --- a/tests/headers/union_with_nesting_1_0.h +++ b/tests/headers/union_with_nesting_1_0.h @@ -1,4 +1,4 @@ -// bindgen-flags: --rust-target 1.0 --with-derive-hash --with-derive-partialeq +// bindgen-flags: --rust-target 1.0 --with-derive-hash --with-derive-partialeq --with-derive-eq union foo { unsigned int a; From 393ac53cdc591e8bfd68e373b6df06c11fc35443 Mon Sep 17 00:00:00 2001 From: Zhiting Zhu Date: Wed, 16 Aug 2017 19:42:09 -0500 Subject: [PATCH 03/12] Struct related tests for can derive Eq --- .../tests/struct_containing_forward_declared_struct.rs | 4 ++-- tests/expectations/tests/struct_typedef.rs | 4 ++-- tests/expectations/tests/struct_typedef_ns.rs | 4 ++-- tests/expectations/tests/struct_with_anon_struct.rs | 4 ++-- .../expectations/tests/struct_with_anon_struct_array.rs | 6 +++--- .../tests/struct_with_anon_struct_pointer.rs | 4 ++-- tests/expectations/tests/struct_with_anon_union_1_0.rs | 5 +++-- .../tests/struct_with_anon_unnamed_struct.rs | 4 ++-- .../tests/struct_with_anon_unnamed_union_1_0.rs | 5 +++-- tests/expectations/tests/struct_with_bitfields.rs | 2 +- tests/expectations/tests/struct_with_derive_debug.rs | 4 ++-- tests/expectations/tests/struct_with_nesting.rs | 4 ++-- tests/expectations/tests/struct_with_nesting_1_0.rs | 9 +++++---- tests/expectations/tests/struct_with_packing.rs | 2 +- tests/expectations/tests/struct_with_struct.rs | 4 ++-- .../tests/struct_with_typedef_template_arg.rs | 2 +- .../headers/struct_containing_forward_declared_struct.h | 2 +- tests/headers/struct_typedef.h | 2 +- tests/headers/struct_typedef_ns.hpp | 2 +- tests/headers/struct_with_anon_struct.h | 2 +- tests/headers/struct_with_anon_struct_array.h | 2 +- tests/headers/struct_with_anon_struct_pointer.h | 2 +- tests/headers/struct_with_anon_union.h | 2 +- tests/headers/struct_with_anon_union_1_0.h | 2 +- tests/headers/struct_with_anon_unnamed_struct.h | 2 +- tests/headers/struct_with_anon_unnamed_union.h | 2 +- tests/headers/struct_with_anon_unnamed_union_1_0.h | 2 +- tests/headers/struct_with_bitfields.h | 2 +- tests/headers/struct_with_derive_debug.h | 2 +- tests/headers/struct_with_large_array.hpp | 2 +- tests/headers/struct_with_nesting.h | 2 +- tests/headers/struct_with_nesting_1_0.h | 2 +- tests/headers/struct_with_packing.h | 2 +- tests/headers/struct_with_struct.h | 2 +- tests/headers/struct_with_typedef_template_arg.hpp | 2 +- 35 files changed, 54 insertions(+), 51 deletions(-) diff --git a/tests/expectations/tests/struct_containing_forward_declared_struct.rs b/tests/expectations/tests/struct_containing_forward_declared_struct.rs index 5bd5b3943d..db47ce6fd5 100644 --- a/tests/expectations/tests/struct_containing_forward_declared_struct.rs +++ b/tests/expectations/tests/struct_containing_forward_declared_struct.rs @@ -5,7 +5,7 @@ #[repr(C)] -#[derive(Debug, Copy, Hash, PartialEq)] +#[derive(Debug, Copy, Hash, PartialEq, Eq)] pub struct a { pub val_a: *mut b, } @@ -28,7 +28,7 @@ impl Default for a { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct b { pub val_b: ::std::os::raw::c_int, } diff --git a/tests/expectations/tests/struct_typedef.rs b/tests/expectations/tests/struct_typedef.rs index 834a6de922..fb680b6988 100644 --- a/tests/expectations/tests/struct_typedef.rs +++ b/tests/expectations/tests/struct_typedef.rs @@ -5,7 +5,7 @@ #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct typedef_named_struct { pub has_name: bool, } @@ -26,7 +26,7 @@ impl Clone for typedef_named_struct { fn clone(&self) -> Self { *self } } #[repr(C)] -#[derive(Debug, Copy, Hash, PartialEq)] +#[derive(Debug, Copy, Hash, PartialEq, Eq)] pub struct _bindgen_ty_1 { pub no_name: *mut ::std::os::raw::c_void, } diff --git a/tests/expectations/tests/struct_typedef_ns.rs b/tests/expectations/tests/struct_typedef_ns.rs index 4180564c8d..74c6092336 100644 --- a/tests/expectations/tests/struct_typedef_ns.rs +++ b/tests/expectations/tests/struct_typedef_ns.rs @@ -12,7 +12,7 @@ pub mod root { #[allow(unused_imports)] use self::super::super::root; #[repr(C)] - #[derive(Debug, Default, Copy, Hash, PartialEq)] + #[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct typedef_struct { pub foo: ::std::os::raw::c_int, } @@ -41,7 +41,7 @@ pub mod root { #[allow(unused_imports)] use self::super::super::root; #[repr(C)] - #[derive(Debug, Default, Copy, Hash, PartialEq)] + #[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct _bindgen_ty_1 { pub foo: ::std::os::raw::c_int, } diff --git a/tests/expectations/tests/struct_with_anon_struct.rs b/tests/expectations/tests/struct_with_anon_struct.rs index f31f0b1b0b..024eaac44d 100644 --- a/tests/expectations/tests/struct_with_anon_struct.rs +++ b/tests/expectations/tests/struct_with_anon_struct.rs @@ -5,12 +5,12 @@ #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct foo { pub bar: foo__bindgen_ty_1, } #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct foo__bindgen_ty_1 { pub a: ::std::os::raw::c_int, pub b: ::std::os::raw::c_int, diff --git a/tests/expectations/tests/struct_with_anon_struct_array.rs b/tests/expectations/tests/struct_with_anon_struct_array.rs index 7baf1022e2..fe3e8b0c97 100644 --- a/tests/expectations/tests/struct_with_anon_struct_array.rs +++ b/tests/expectations/tests/struct_with_anon_struct_array.rs @@ -5,13 +5,13 @@ #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct foo { pub bar: [foo__bindgen_ty_1; 2usize], pub baz: [[[foo__bindgen_ty_2; 4usize]; 3usize]; 2usize], } #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct foo__bindgen_ty_1 { pub a: ::std::os::raw::c_int, pub b: ::std::os::raw::c_int, @@ -37,7 +37,7 @@ impl Clone for foo__bindgen_ty_1 { fn clone(&self) -> Self { *self } } #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct foo__bindgen_ty_2 { pub a: ::std::os::raw::c_int, pub b: ::std::os::raw::c_int, diff --git a/tests/expectations/tests/struct_with_anon_struct_pointer.rs b/tests/expectations/tests/struct_with_anon_struct_pointer.rs index 4636e5c8aa..006de1cd4f 100644 --- a/tests/expectations/tests/struct_with_anon_struct_pointer.rs +++ b/tests/expectations/tests/struct_with_anon_struct_pointer.rs @@ -5,12 +5,12 @@ #[repr(C)] -#[derive(Debug, Copy, Hash, PartialEq)] +#[derive(Debug, Copy, Hash, PartialEq, Eq)] pub struct foo { pub bar: *mut foo__bindgen_ty_1, } #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct foo__bindgen_ty_1 { pub a: ::std::os::raw::c_int, pub b: ::std::os::raw::c_int, diff --git a/tests/expectations/tests/struct_with_anon_union_1_0.rs b/tests/expectations/tests/struct_with_anon_union_1_0.rs index e39a09348e..4a25fd6d5b 100644 --- a/tests/expectations/tests/struct_with_anon_union_1_0.rs +++ b/tests/expectations/tests/struct_with_anon_union_1_0.rs @@ -34,13 +34,14 @@ impl ::std::hash::Hash for __BindgenUnionField { impl ::std::cmp::PartialEq for __BindgenUnionField { fn eq(&self, _other: &__BindgenUnionField) -> bool { true } } +impl ::std::cmp::Eq for __BindgenUnionField { } #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct foo { pub bar: foo__bindgen_ty_1, } #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct foo__bindgen_ty_1 { pub a: __BindgenUnionField<::std::os::raw::c_uint>, pub b: __BindgenUnionField<::std::os::raw::c_ushort>, diff --git a/tests/expectations/tests/struct_with_anon_unnamed_struct.rs b/tests/expectations/tests/struct_with_anon_unnamed_struct.rs index 7e0f7e19f6..0349d70ce1 100644 --- a/tests/expectations/tests/struct_with_anon_unnamed_struct.rs +++ b/tests/expectations/tests/struct_with_anon_unnamed_struct.rs @@ -5,12 +5,12 @@ #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct foo { pub __bindgen_anon_1: foo__bindgen_ty_1, } #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct foo__bindgen_ty_1 { pub a: ::std::os::raw::c_uint, pub b: ::std::os::raw::c_uint, diff --git a/tests/expectations/tests/struct_with_anon_unnamed_union_1_0.rs b/tests/expectations/tests/struct_with_anon_unnamed_union_1_0.rs index d0b86cb80e..5ce4064f67 100644 --- a/tests/expectations/tests/struct_with_anon_unnamed_union_1_0.rs +++ b/tests/expectations/tests/struct_with_anon_unnamed_union_1_0.rs @@ -34,13 +34,14 @@ impl ::std::hash::Hash for __BindgenUnionField { impl ::std::cmp::PartialEq for __BindgenUnionField { fn eq(&self, _other: &__BindgenUnionField) -> bool { true } } +impl ::std::cmp::Eq for __BindgenUnionField { } #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct foo { pub __bindgen_anon_1: foo__bindgen_ty_1, } #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct foo__bindgen_ty_1 { pub a: __BindgenUnionField<::std::os::raw::c_uint>, pub b: __BindgenUnionField<::std::os::raw::c_ushort>, diff --git a/tests/expectations/tests/struct_with_bitfields.rs b/tests/expectations/tests/struct_with_bitfields.rs index 6455356a71..d874351b33 100644 --- a/tests/expectations/tests/struct_with_bitfields.rs +++ b/tests/expectations/tests/struct_with_bitfields.rs @@ -5,7 +5,7 @@ #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct bitfield { pub _bitfield_1: u8, pub e: ::std::os::raw::c_int, diff --git a/tests/expectations/tests/struct_with_derive_debug.rs b/tests/expectations/tests/struct_with_derive_debug.rs index 18e503530b..03046674d3 100644 --- a/tests/expectations/tests/struct_with_derive_debug.rs +++ b/tests/expectations/tests/struct_with_derive_debug.rs @@ -5,7 +5,7 @@ #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct LittleArray { pub a: [::std::os::raw::c_int; 32usize], } @@ -48,7 +48,7 @@ impl Default for BigArray { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct WithLittleArray { pub a: LittleArray, } diff --git a/tests/expectations/tests/struct_with_nesting.rs b/tests/expectations/tests/struct_with_nesting.rs index 4df90fd08d..7b82964f41 100644 --- a/tests/expectations/tests/struct_with_nesting.rs +++ b/tests/expectations/tests/struct_with_nesting.rs @@ -19,7 +19,7 @@ pub union foo__bindgen_ty_1 { _bindgen_union_align: u32, } #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct foo__bindgen_ty_1__bindgen_ty_1 { pub c1: ::std::os::raw::c_ushort, pub c2: ::std::os::raw::c_ushort, @@ -51,7 +51,7 @@ impl Clone for foo__bindgen_ty_1__bindgen_ty_1 { fn clone(&self) -> Self { *self } } #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct foo__bindgen_ty_1__bindgen_ty_2 { pub d1: ::std::os::raw::c_uchar, pub d2: ::std::os::raw::c_uchar, diff --git a/tests/expectations/tests/struct_with_nesting_1_0.rs b/tests/expectations/tests/struct_with_nesting_1_0.rs index 6e06a368f6..5d014b9505 100644 --- a/tests/expectations/tests/struct_with_nesting_1_0.rs +++ b/tests/expectations/tests/struct_with_nesting_1_0.rs @@ -34,14 +34,15 @@ impl ::std::hash::Hash for __BindgenUnionField { impl ::std::cmp::PartialEq for __BindgenUnionField { fn eq(&self, _other: &__BindgenUnionField) -> bool { true } } +impl ::std::cmp::Eq for __BindgenUnionField { } #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct foo { pub a: ::std::os::raw::c_uint, pub __bindgen_anon_1: foo__bindgen_ty_1, } #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct foo__bindgen_ty_1 { pub b: __BindgenUnionField<::std::os::raw::c_uint>, pub __bindgen_anon_1: __BindgenUnionField, @@ -49,7 +50,7 @@ pub struct foo__bindgen_ty_1 { pub bindgen_union_field: u32, } #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct foo__bindgen_ty_1__bindgen_ty_1 { pub c1: ::std::os::raw::c_ushort, pub c2: ::std::os::raw::c_ushort, @@ -81,7 +82,7 @@ impl Clone for foo__bindgen_ty_1__bindgen_ty_1 { fn clone(&self) -> Self { *self } } #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct foo__bindgen_ty_1__bindgen_ty_2 { pub d1: ::std::os::raw::c_uchar, pub d2: ::std::os::raw::c_uchar, diff --git a/tests/expectations/tests/struct_with_packing.rs b/tests/expectations/tests/struct_with_packing.rs index e0731da431..1b3f4ca28a 100644 --- a/tests/expectations/tests/struct_with_packing.rs +++ b/tests/expectations/tests/struct_with_packing.rs @@ -5,7 +5,7 @@ #[repr(C, packed)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct a { pub b: ::std::os::raw::c_char, pub c: ::std::os::raw::c_short, diff --git a/tests/expectations/tests/struct_with_struct.rs b/tests/expectations/tests/struct_with_struct.rs index ad8551a3e8..47c99937f9 100644 --- a/tests/expectations/tests/struct_with_struct.rs +++ b/tests/expectations/tests/struct_with_struct.rs @@ -5,12 +5,12 @@ #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct foo { pub bar: foo__bindgen_ty_1, } #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct foo__bindgen_ty_1 { pub x: ::std::os::raw::c_uint, pub y: ::std::os::raw::c_uint, diff --git a/tests/expectations/tests/struct_with_typedef_template_arg.rs b/tests/expectations/tests/struct_with_typedef_template_arg.rs index 15d48e056c..ad4f394a04 100644 --- a/tests/expectations/tests/struct_with_typedef_template_arg.rs +++ b/tests/expectations/tests/struct_with_typedef_template_arg.rs @@ -5,7 +5,7 @@ #[repr(C)] -#[derive(Debug, Default, Copy, Clone, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct Proxy { pub _address: u8, } diff --git a/tests/headers/struct_containing_forward_declared_struct.h b/tests/headers/struct_containing_forward_declared_struct.h index c118786ce5..cf7cb5c40c 100644 --- a/tests/headers/struct_containing_forward_declared_struct.h +++ b/tests/headers/struct_containing_forward_declared_struct.h @@ -1,4 +1,4 @@ -// bindgen-flags: --with-derive-hash --with-derive-partialeq +// bindgen-flags: --with-derive-hash --with-derive-partialeq --with-derive-eq struct a { struct b* val_a; }; diff --git a/tests/headers/struct_typedef.h b/tests/headers/struct_typedef.h index b1f21354fb..de861c5feb 100644 --- a/tests/headers/struct_typedef.h +++ b/tests/headers/struct_typedef.h @@ -1,4 +1,4 @@ -// bindgen-flags: --with-derive-hash --with-derive-partialeq +// bindgen-flags: --with-derive-hash --with-derive-partialeq --with-derive-eq // typedef struct { _Bool has_name; diff --git a/tests/headers/struct_typedef_ns.hpp b/tests/headers/struct_typedef_ns.hpp index bed8634b30..07ecc160d2 100644 --- a/tests/headers/struct_typedef_ns.hpp +++ b/tests/headers/struct_typedef_ns.hpp @@ -1,4 +1,4 @@ -// bindgen-flags: --with-derive-hash --with-derive-partialeq --enable-cxx-namespaces +// bindgen-flags: --with-derive-hash --with-derive-partialeq --with-derive-eq --enable-cxx-namespaces namespace whatever { typedef struct { diff --git a/tests/headers/struct_with_anon_struct.h b/tests/headers/struct_with_anon_struct.h index 4578a8754a..a5e8476d3c 100644 --- a/tests/headers/struct_with_anon_struct.h +++ b/tests/headers/struct_with_anon_struct.h @@ -1,4 +1,4 @@ -// bindgen-flags: --with-derive-hash --with-derive-partialeq +// bindgen-flags: --with-derive-hash --with-derive-partialeq --with-derive-eq // struct foo { struct { diff --git a/tests/headers/struct_with_anon_struct_array.h b/tests/headers/struct_with_anon_struct_array.h index c66bb10e2c..94a8ea0a62 100644 --- a/tests/headers/struct_with_anon_struct_array.h +++ b/tests/headers/struct_with_anon_struct_array.h @@ -1,4 +1,4 @@ -// bindgen-flags: --with-derive-hash --with-derive-partialeq +// bindgen-flags: --with-derive-hash --with-derive-partialeq --with-derive-eq // struct foo { struct { diff --git a/tests/headers/struct_with_anon_struct_pointer.h b/tests/headers/struct_with_anon_struct_pointer.h index 5844b509e6..d92c801102 100644 --- a/tests/headers/struct_with_anon_struct_pointer.h +++ b/tests/headers/struct_with_anon_struct_pointer.h @@ -1,4 +1,4 @@ -// bindgen-flags: --with-derive-hash --with-derive-partialeq +// bindgen-flags: --with-derive-hash --with-derive-partialeq --with-derive-eq struct foo { struct { int a; diff --git a/tests/headers/struct_with_anon_union.h b/tests/headers/struct_with_anon_union.h index 1d7b7a436f..bd75563d35 100644 --- a/tests/headers/struct_with_anon_union.h +++ b/tests/headers/struct_with_anon_union.h @@ -1,4 +1,4 @@ -// bindgen-flags: --with-derive-hash --with-derive-partialeq +// bindgen-flags: --with-derive-hash --with-derive-partialeq --with-derive-eq // struct foo { union { diff --git a/tests/headers/struct_with_anon_union_1_0.h b/tests/headers/struct_with_anon_union_1_0.h index c727ce413c..847c354b59 100644 --- a/tests/headers/struct_with_anon_union_1_0.h +++ b/tests/headers/struct_with_anon_union_1_0.h @@ -1,4 +1,4 @@ -// bindgen-flags: --rust-target 1.0 --with-derive-hash --with-derive-partialeq +// bindgen-flags: --rust-target 1.0 --with-derive-hash --with-derive-partialeq --with-derive-eq struct foo { union { diff --git a/tests/headers/struct_with_anon_unnamed_struct.h b/tests/headers/struct_with_anon_unnamed_struct.h index 399056e73d..92705238d6 100644 --- a/tests/headers/struct_with_anon_unnamed_struct.h +++ b/tests/headers/struct_with_anon_unnamed_struct.h @@ -1,4 +1,4 @@ -// bindgen-flags: --with-derive-hash --with-derive-partialeq +// bindgen-flags: --with-derive-hash --with-derive-partialeq --with-derive-eq struct foo { struct { unsigned int a; diff --git a/tests/headers/struct_with_anon_unnamed_union.h b/tests/headers/struct_with_anon_unnamed_union.h index 1961ebc86f..00fa4900c1 100644 --- a/tests/headers/struct_with_anon_unnamed_union.h +++ b/tests/headers/struct_with_anon_unnamed_union.h @@ -1,4 +1,4 @@ -// bindgen-flags: --with-derive-hash --with-derive-partialeq +// bindgen-flags: --with-derive-hash --with-derive-partialeq --with-derive-eq struct foo { union { unsigned int a; diff --git a/tests/headers/struct_with_anon_unnamed_union_1_0.h b/tests/headers/struct_with_anon_unnamed_union_1_0.h index 1f8280cd60..791a1593af 100644 --- a/tests/headers/struct_with_anon_unnamed_union_1_0.h +++ b/tests/headers/struct_with_anon_unnamed_union_1_0.h @@ -1,4 +1,4 @@ -// bindgen-flags: --rust-target 1.0 --with-derive-hash --with-derive-partialeq +// bindgen-flags: --rust-target 1.0 --with-derive-hash --with-derive-partialeq --with-derive-eq struct foo { union { diff --git a/tests/headers/struct_with_bitfields.h b/tests/headers/struct_with_bitfields.h index 7b58c4b822..ba1af26d72 100644 --- a/tests/headers/struct_with_bitfields.h +++ b/tests/headers/struct_with_bitfields.h @@ -1,4 +1,4 @@ -// bindgen-flags: --with-derive-hash --with-derive-partialeq +// bindgen-flags: --with-derive-hash --with-derive-partialeq --with-derive-eq // struct bitfield { unsigned short diff --git a/tests/headers/struct_with_derive_debug.h b/tests/headers/struct_with_derive_debug.h index 493b29ca16..201748d9c5 100644 --- a/tests/headers/struct_with_derive_debug.h +++ b/tests/headers/struct_with_derive_debug.h @@ -1,4 +1,4 @@ -// bindgen-flags: --with-derive-hash --with-derive-partialeq +// bindgen-flags: --with-derive-hash --with-derive-partialeq --with-derive-eq // struct LittleArray { int a[32]; diff --git a/tests/headers/struct_with_large_array.hpp b/tests/headers/struct_with_large_array.hpp index 2c9255271f..58e8e4d19a 100644 --- a/tests/headers/struct_with_large_array.hpp +++ b/tests/headers/struct_with_large_array.hpp @@ -1,4 +1,4 @@ -// bindgen-flags: --with-derive-hash --with-derive-partialeq +// bindgen-flags: --with-derive-hash --with-derive-partialeq --with-derive-eq // struct S { char large_array[33]; diff --git a/tests/headers/struct_with_nesting.h b/tests/headers/struct_with_nesting.h index 532b46e271..ac902b443e 100644 --- a/tests/headers/struct_with_nesting.h +++ b/tests/headers/struct_with_nesting.h @@ -1,4 +1,4 @@ -// bindgen-flags: --with-derive-hash --with-derive-partialeq +// bindgen-flags: --with-derive-hash --with-derive-partialeq --with-derive-eq // struct foo { unsigned int a; diff --git a/tests/headers/struct_with_nesting_1_0.h b/tests/headers/struct_with_nesting_1_0.h index 125a90268c..a24ae1db58 100644 --- a/tests/headers/struct_with_nesting_1_0.h +++ b/tests/headers/struct_with_nesting_1_0.h @@ -1,4 +1,4 @@ -// bindgen-flags: --rust-target 1.0 --with-derive-hash --with-derive-partialeq +// bindgen-flags: --rust-target 1.0 --with-derive-hash --with-derive-partialeq --with-derive-eq struct foo { unsigned int a; diff --git a/tests/headers/struct_with_packing.h b/tests/headers/struct_with_packing.h index 41b5840f9e..9ed5031759 100644 --- a/tests/headers/struct_with_packing.h +++ b/tests/headers/struct_with_packing.h @@ -1,4 +1,4 @@ -// bindgen-flags: --with-derive-hash --with-derive-partialeq +// bindgen-flags: --with-derive-hash --with-derive-partialeq --with-derive-eq // struct a { char b; diff --git a/tests/headers/struct_with_struct.h b/tests/headers/struct_with_struct.h index 953472c889..1a17807465 100644 --- a/tests/headers/struct_with_struct.h +++ b/tests/headers/struct_with_struct.h @@ -1,4 +1,4 @@ -// bindgen-flags: --with-derive-hash --with-derive-partialeq +// bindgen-flags: --with-derive-hash --with-derive-partialeq --with-derive-eq // struct foo { struct { diff --git a/tests/headers/struct_with_typedef_template_arg.hpp b/tests/headers/struct_with_typedef_template_arg.hpp index 38a1ab3d54..ec1b55aa4b 100644 --- a/tests/headers/struct_with_typedef_template_arg.hpp +++ b/tests/headers/struct_with_typedef_template_arg.hpp @@ -1,4 +1,4 @@ -// bindgen-flags: --with-derive-hash --with-derive-partialeq +// bindgen-flags: --with-derive-hash --with-derive-partialeq --with-derive-eq template struct Proxy { typedef void (*foo)(T* bar); From 1990e9109e526d08a30f67f7a7528b8f73814c25 Mon Sep 17 00:00:00 2001 From: Zhiting Zhu Date: Wed, 16 Aug 2017 19:43:17 -0500 Subject: [PATCH 04/12] Class related tests for can derive Eq --- tests/expectations/tests/class.rs | 4 ++-- tests/expectations/tests/class_1_0.rs | 5 +++-- tests/expectations/tests/class_nested.rs | 14 +++++++------- tests/expectations/tests/class_no_members.rs | 6 +++--- tests/expectations/tests/class_static.rs | 2 +- tests/expectations/tests/class_static_const.rs | 2 +- tests/expectations/tests/class_use_as.rs | 4 ++-- tests/expectations/tests/class_with_dtor.rs | 4 ++-- .../tests/class_with_inner_struct.rs | 10 +++++----- .../tests/class_with_inner_struct_1_0.rs | 17 +++++++++-------- tests/expectations/tests/class_with_typedef.rs | 4 ++-- tests/headers/class.hpp | 2 +- tests/headers/class_1_0.hpp | 2 +- tests/headers/class_nested.hpp | 2 +- tests/headers/class_no_members.hpp | 2 +- tests/headers/class_static.hpp | 2 +- tests/headers/class_static_const.hpp | 2 +- tests/headers/class_use_as.hpp | 2 +- tests/headers/class_with_dtor.hpp | 2 +- tests/headers/class_with_inner_struct.hpp | 2 +- tests/headers/class_with_inner_struct_1_0.hpp | 2 +- tests/headers/class_with_typedef.hpp | 2 +- 22 files changed, 48 insertions(+), 46 deletions(-) diff --git a/tests/expectations/tests/class.rs b/tests/expectations/tests/class.rs index 0332c50ece..d121665521 100644 --- a/tests/expectations/tests/class.rs +++ b/tests/expectations/tests/class.rs @@ -141,7 +141,7 @@ impl Default for C_with_zero_length_array_and_incomplete_array { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } #[repr(C)] -#[derive(Debug, Default, Hash, PartialEq)] +#[derive(Debug, Default, Hash, PartialEq, Eq)] pub struct WithDtor { pub b: ::std::os::raw::c_int, } @@ -229,7 +229,7 @@ impl Default for WithUnion { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct RealAbstractionWithTonsOfMethods { pub _address: u8, } diff --git a/tests/expectations/tests/class_1_0.rs b/tests/expectations/tests/class_1_0.rs index 21399a4902..8ccf4e01c6 100644 --- a/tests/expectations/tests/class_1_0.rs +++ b/tests/expectations/tests/class_1_0.rs @@ -67,6 +67,7 @@ impl ::std::hash::Hash for __BindgenUnionField { impl ::std::cmp::PartialEq for __BindgenUnionField { fn eq(&self, _other: &__BindgenUnionField) -> bool { true } } +impl ::std::cmp::Eq for __BindgenUnionField { } #[repr(C)] #[derive(Copy)] pub struct C { @@ -171,7 +172,7 @@ impl Default for C_with_zero_length_array_and_incomplete_array { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } #[repr(C)] -#[derive(Debug, Default, Hash, PartialEq)] +#[derive(Debug, Default, Hash, PartialEq, Eq)] pub struct WithDtor { pub b: ::std::os::raw::c_int, } @@ -253,7 +254,7 @@ impl Clone for WithUnion { fn clone(&self) -> Self { *self } } #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct RealAbstractionWithTonsOfMethods { pub _address: u8, } diff --git a/tests/expectations/tests/class_nested.rs b/tests/expectations/tests/class_nested.rs index dc40fd0657..76658b2e24 100644 --- a/tests/expectations/tests/class_nested.rs +++ b/tests/expectations/tests/class_nested.rs @@ -5,12 +5,12 @@ #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct A { pub member_a: ::std::os::raw::c_int, } #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct A_B { pub member_b: ::std::os::raw::c_int, } @@ -30,7 +30,7 @@ impl Clone for A_B { fn clone(&self) -> Self { *self } } #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct A_C { pub baz: ::std::os::raw::c_int, } @@ -50,7 +50,7 @@ impl Clone for A_C { fn clone(&self) -> Self { *self } } #[repr(C)] -#[derive(Debug, Copy, Clone, Hash, PartialEq)] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct A_D { pub foo: T, pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>, @@ -93,7 +93,7 @@ extern "C" { pub static mut baz: A_D<::std::os::raw::c_int>; } #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct D { pub member: A_B, } @@ -113,13 +113,13 @@ impl Clone for D { fn clone(&self) -> Self { *self } } #[repr(C)] -#[derive(Debug, Copy, Clone, Hash, PartialEq)] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct Templated { pub member: T, pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>, } #[repr(C)] -#[derive(Debug, Copy, Clone, Hash, PartialEq)] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct Templated_Templated_inner { pub member_ptr: *mut T, pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>, diff --git a/tests/expectations/tests/class_no_members.rs b/tests/expectations/tests/class_no_members.rs index 4eb883d9db..7fc05c5fd7 100644 --- a/tests/expectations/tests/class_no_members.rs +++ b/tests/expectations/tests/class_no_members.rs @@ -5,7 +5,7 @@ #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct whatever { pub _address: u8, } @@ -20,7 +20,7 @@ impl Clone for whatever { fn clone(&self) -> Self { *self } } #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct whatever_child { pub _address: u8, } @@ -35,7 +35,7 @@ impl Clone for whatever_child { fn clone(&self) -> Self { *self } } #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct whatever_child_with_member { pub m_member: ::std::os::raw::c_int, } diff --git a/tests/expectations/tests/class_static.rs b/tests/expectations/tests/class_static.rs index 703fa07295..84f129df20 100644 --- a/tests/expectations/tests/class_static.rs +++ b/tests/expectations/tests/class_static.rs @@ -5,7 +5,7 @@ #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct MyClass { pub _address: u8, } diff --git a/tests/expectations/tests/class_static_const.rs b/tests/expectations/tests/class_static_const.rs index 27e5b645fc..9a4b542524 100644 --- a/tests/expectations/tests/class_static_const.rs +++ b/tests/expectations/tests/class_static_const.rs @@ -5,7 +5,7 @@ #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct A { pub _address: u8, } diff --git a/tests/expectations/tests/class_use_as.rs b/tests/expectations/tests/class_use_as.rs index c721f1aec3..4d2ae2752c 100644 --- a/tests/expectations/tests/class_use_as.rs +++ b/tests/expectations/tests/class_use_as.rs @@ -6,7 +6,7 @@ ///
#[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct whatever { pub replacement: ::std::os::raw::c_int, } @@ -26,7 +26,7 @@ impl Clone for whatever { fn clone(&self) -> Self { *self } } #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct container { pub c: whatever, } diff --git a/tests/expectations/tests/class_with_dtor.rs b/tests/expectations/tests/class_with_dtor.rs index 0ef190a942..8171288ae4 100644 --- a/tests/expectations/tests/class_with_dtor.rs +++ b/tests/expectations/tests/class_with_dtor.rs @@ -5,7 +5,7 @@ #[repr(C)] -#[derive(Debug, Hash, PartialEq)] +#[derive(Debug, Hash, PartialEq, Eq)] pub struct HandleWithDtor { pub ptr: *mut T, pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>, @@ -15,7 +15,7 @@ impl Default for HandleWithDtor { } pub type HandleValue = HandleWithDtor<::std::os::raw::c_int>; #[repr(C)] -#[derive(Debug, Hash, PartialEq)] +#[derive(Debug, Hash, PartialEq, Eq)] pub struct WithoutDtor { pub shouldBeWithDtor: HandleValue, } diff --git a/tests/expectations/tests/class_with_inner_struct.rs b/tests/expectations/tests/class_with_inner_struct.rs index 7cc0024f2e..03df600838 100644 --- a/tests/expectations/tests/class_with_inner_struct.rs +++ b/tests/expectations/tests/class_with_inner_struct.rs @@ -12,7 +12,7 @@ pub struct A { pub __bindgen_anon_1: A__bindgen_ty_2, } #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct A_Segment { pub begin: ::std::os::raw::c_int, pub end: ::std::os::raw::c_int, @@ -108,12 +108,12 @@ impl Default for A { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct B { pub d: ::std::os::raw::c_uint, } #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct B_Segment { pub begin: ::std::os::raw::c_int, pub end: ::std::os::raw::c_int, @@ -219,7 +219,7 @@ impl Clone for C__bindgen_ty_1__bindgen_ty_1 { fn clone(&self) -> Self { *self } } #[repr(C)] -#[derive(Debug, Copy, Hash, PartialEq)] +#[derive(Debug, Copy, Hash, PartialEq, Eq)] pub struct C__bindgen_ty_1__bindgen_ty_2 { pub mStepSyntax: StepSyntax, pub mSteps: ::std::os::raw::c_uint, @@ -271,7 +271,7 @@ impl Default for C__bindgen_ty_1 { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct C_Segment { pub begin: ::std::os::raw::c_int, pub end: ::std::os::raw::c_int, diff --git a/tests/expectations/tests/class_with_inner_struct_1_0.rs b/tests/expectations/tests/class_with_inner_struct_1_0.rs index aa4bc2f0dc..42376deea7 100644 --- a/tests/expectations/tests/class_with_inner_struct_1_0.rs +++ b/tests/expectations/tests/class_with_inner_struct_1_0.rs @@ -34,15 +34,16 @@ impl ::std::hash::Hash for __BindgenUnionField { impl ::std::cmp::PartialEq for __BindgenUnionField { fn eq(&self, _other: &__BindgenUnionField) -> bool { true } } +impl ::std::cmp::Eq for __BindgenUnionField { } #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct A { pub c: ::std::os::raw::c_uint, pub named_union: A__bindgen_ty_1, pub __bindgen_anon_1: A__bindgen_ty_2, } #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct A_Segment { pub begin: ::std::os::raw::c_int, pub end: ::std::os::raw::c_int, @@ -68,7 +69,7 @@ impl Clone for A_Segment { fn clone(&self) -> Self { *self } } #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct A__bindgen_ty_1 { pub f: __BindgenUnionField<::std::os::raw::c_int>, pub bindgen_union_field: u32, @@ -89,7 +90,7 @@ impl Clone for A__bindgen_ty_1 { fn clone(&self) -> Self { *self } } #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct A__bindgen_ty_2 { pub d: __BindgenUnionField<::std::os::raw::c_int>, pub bindgen_union_field: u32, @@ -129,12 +130,12 @@ impl Clone for A { fn clone(&self) -> Self { *self } } #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct B { pub d: ::std::os::raw::c_uint, } #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct B_Segment { pub begin: ::std::os::raw::c_int, pub end: ::std::os::raw::c_int, @@ -240,7 +241,7 @@ impl Clone for C__bindgen_ty_1__bindgen_ty_1 { fn clone(&self) -> Self { *self } } #[repr(C)] -#[derive(Debug, Copy, Hash, PartialEq)] +#[derive(Debug, Copy, Hash, PartialEq, Eq)] pub struct C__bindgen_ty_1__bindgen_ty_2 { pub mStepSyntax: StepSyntax, pub mSteps: ::std::os::raw::c_uint, @@ -289,7 +290,7 @@ impl Clone for C__bindgen_ty_1 { fn clone(&self) -> Self { *self } } #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct C_Segment { pub begin: ::std::os::raw::c_int, pub end: ::std::os::raw::c_int, diff --git a/tests/expectations/tests/class_with_typedef.rs b/tests/expectations/tests/class_with_typedef.rs index 053bc06bb8..159f273516 100644 --- a/tests/expectations/tests/class_with_typedef.rs +++ b/tests/expectations/tests/class_with_typedef.rs @@ -6,7 +6,7 @@ pub type AnotherInt = ::std::os::raw::c_int; #[repr(C)] -#[derive(Debug, Copy, Hash, PartialEq)] +#[derive(Debug, Copy, Hash, PartialEq, Eq)] pub struct C { pub c: C_MyInt, pub ptr: *mut C_MyInt, @@ -85,7 +85,7 @@ impl C { } } #[repr(C)] -#[derive(Debug, Copy, Hash, PartialEq)] +#[derive(Debug, Copy, Hash, PartialEq, Eq)] pub struct D { pub _base: C, pub ptr: *mut C_MyInt, diff --git a/tests/headers/class.hpp b/tests/headers/class.hpp index c8c041dcca..ac2da1a469 100644 --- a/tests/headers/class.hpp +++ b/tests/headers/class.hpp @@ -1,4 +1,4 @@ -// bindgen-flags: --with-derive-hash --with-derive-partialeq +// bindgen-flags: --with-derive-hash --with-derive-partialeq --with-derive-eq // class C { int a; diff --git a/tests/headers/class_1_0.hpp b/tests/headers/class_1_0.hpp index 7400a2a527..ee00c2b7fd 100644 --- a/tests/headers/class_1_0.hpp +++ b/tests/headers/class_1_0.hpp @@ -1,4 +1,4 @@ -// bindgen-flags: --rust-target 1.0 --with-derive-hash --with-derive-partialeq +// bindgen-flags: --rust-target 1.0 --with-derive-hash --with-derive-partialeq --with-derive-eq class C { int a; diff --git a/tests/headers/class_nested.hpp b/tests/headers/class_nested.hpp index 09213576d9..d6ca02c20a 100644 --- a/tests/headers/class_nested.hpp +++ b/tests/headers/class_nested.hpp @@ -1,4 +1,4 @@ -// bindgen-flags: --with-derive-hash --with-derive-partialeq +// bindgen-flags: --with-derive-hash --with-derive-partialeq --with-derive-eq class A { public: int member_a; diff --git a/tests/headers/class_no_members.hpp b/tests/headers/class_no_members.hpp index 4c80f7f872..6963e372d3 100644 --- a/tests/headers/class_no_members.hpp +++ b/tests/headers/class_no_members.hpp @@ -1,4 +1,4 @@ -// bindgen-flags: --with-derive-hash --with-derive-partialeq +// bindgen-flags: --with-derive-hash --with-derive-partialeq --with-derive-eq // bindgen-flags: -- -std=c++11 class whatever { diff --git a/tests/headers/class_static.hpp b/tests/headers/class_static.hpp index 18660132bf..d8f9be6d3f 100644 --- a/tests/headers/class_static.hpp +++ b/tests/headers/class_static.hpp @@ -1,4 +1,4 @@ -// bindgen-flags: --with-derive-hash --with-derive-partialeq +// bindgen-flags: --with-derive-hash --with-derive-partialeq --with-derive-eq class MyClass { public: static const int* example; diff --git a/tests/headers/class_static_const.hpp b/tests/headers/class_static_const.hpp index 7742c78239..3e320edcbe 100644 --- a/tests/headers/class_static_const.hpp +++ b/tests/headers/class_static_const.hpp @@ -1,4 +1,4 @@ -// bindgen-flags: --with-derive-hash --with-derive-partialeq +// bindgen-flags: --with-derive-hash --with-derive-partialeq --with-derive-eq using int32_t = int; typedef unsigned int uint32_t; diff --git a/tests/headers/class_use_as.hpp b/tests/headers/class_use_as.hpp index 267185c7bc..b7eaf29bd7 100644 --- a/tests/headers/class_use_as.hpp +++ b/tests/headers/class_use_as.hpp @@ -1,4 +1,4 @@ -// bindgen-flags: --with-derive-hash --with-derive-partialeq +// bindgen-flags: --with-derive-hash --with-derive-partialeq --with-derive-eq /** *
diff --git a/tests/headers/class_with_dtor.hpp b/tests/headers/class_with_dtor.hpp index 42374c478a..f52858a7b4 100644 --- a/tests/headers/class_with_dtor.hpp +++ b/tests/headers/class_with_dtor.hpp @@ -1,4 +1,4 @@ -// bindgen-flags: --with-derive-hash --with-derive-partialeq +// bindgen-flags: --with-derive-hash --with-derive-partialeq --with-derive-eq template diff --git a/tests/headers/class_with_inner_struct.hpp b/tests/headers/class_with_inner_struct.hpp index c50cfa2bd4..3cb6cfed8b 100644 --- a/tests/headers/class_with_inner_struct.hpp +++ b/tests/headers/class_with_inner_struct.hpp @@ -1,4 +1,4 @@ -// bindgen-flags: --with-derive-hash --with-derive-partialeq +// bindgen-flags: --with-derive-hash --with-derive-partialeq --with-derive-eq // bindgen-flags: -- -std=c++11 class A { diff --git a/tests/headers/class_with_inner_struct_1_0.hpp b/tests/headers/class_with_inner_struct_1_0.hpp index 86338b060d..0bb8a57fe4 100644 --- a/tests/headers/class_with_inner_struct_1_0.hpp +++ b/tests/headers/class_with_inner_struct_1_0.hpp @@ -1,4 +1,4 @@ -// bindgen-flags: --rust-target 1.0 --with-derive-hash --with-derive-partialeq +// bindgen-flags: --rust-target 1.0 --with-derive-hash --with-derive-partialeq --with-derive-eq // bindgen-flags: -- -std=c++11 class A { diff --git a/tests/headers/class_with_typedef.hpp b/tests/headers/class_with_typedef.hpp index df2afb981f..7c3d3c97c1 100644 --- a/tests/headers/class_with_typedef.hpp +++ b/tests/headers/class_with_typedef.hpp @@ -1,4 +1,4 @@ -// bindgen-flags: --with-derive-hash --with-derive-partialeq +// bindgen-flags: --with-derive-hash --with-derive-partialeq --with-derive-eq typedef int AnotherInt; class C { From 11511cc0be53db91d495a5924f2631215db80158 Mon Sep 17 00:00:00 2001 From: Zhiting Zhu Date: Wed, 16 Aug 2017 19:47:31 -0500 Subject: [PATCH 05/12] Opaque tests for can derive Eq --- .../expectations/tests/issue-801-opaque-sloppiness.rs | 4 ++-- .../issue-807-opaque-types-methods-being-generated.rs | 10 +++++----- tests/expectations/tests/jsval_layout_opaque.rs | 2 +- tests/expectations/tests/jsval_layout_opaque_1_0.rs | 7 ++++--- .../tests/opaque-template-inst-member-2.rs | 6 +++--- .../expectations/tests/opaque-template-inst-member.rs | 2 +- .../tests/opaque-template-instantiation-namespaced.rs | 10 +++++----- .../tests/opaque-template-instantiation.rs | 6 +++--- tests/expectations/tests/opaque-tracing.rs | 2 +- tests/expectations/tests/opaque_in_struct.rs | 4 ++-- tests/expectations/tests/opaque_pointer.rs | 4 ++-- tests/expectations/tests/opaque_typedef.rs | 2 +- tests/headers/issue-801-opaque-sloppiness.hpp | 2 +- .../issue-807-opaque-types-methods-being-generated.hpp | 2 +- tests/headers/jsval_layout_opaque.hpp | 2 +- tests/headers/jsval_layout_opaque_1_0.hpp | 2 +- tests/headers/opaque-template-inst-member-2.hpp | 2 +- tests/headers/opaque-template-inst-member.hpp | 2 +- .../opaque-template-instantiation-namespaced.hpp | 2 +- tests/headers/opaque-template-instantiation.hpp | 2 +- tests/headers/opaque-tracing.hpp | 2 +- tests/headers/opaque_in_struct.hpp | 2 +- tests/headers/opaque_pointer.hpp | 2 +- tests/headers/opaque_typedef.hpp | 2 +- 24 files changed, 42 insertions(+), 41 deletions(-) diff --git a/tests/expectations/tests/issue-801-opaque-sloppiness.rs b/tests/expectations/tests/issue-801-opaque-sloppiness.rs index b1462ca91b..dbf21cf90d 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, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] 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, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] 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 debfd32e15..ed7d8a73ed 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, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] 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, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] 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, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] 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, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] 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, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] 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 587fafe36b..0a77b24ee9 100644 --- a/tests/expectations/tests/jsval_layout_opaque.rs +++ b/tests/expectations/tests/jsval_layout_opaque.rs @@ -84,7 +84,7 @@ pub union jsval_layout { _bindgen_union_align: u64, } #[repr(C)] -#[derive(Debug, Copy, Hash, PartialEq)] +#[derive(Debug, Copy, Hash, PartialEq, Eq)] pub struct jsval_layout__bindgen_ty_1 { pub _bitfield_1: u64, pub __bindgen_align: [u64; 0usize], diff --git a/tests/expectations/tests/jsval_layout_opaque_1_0.rs b/tests/expectations/tests/jsval_layout_opaque_1_0.rs index fd71f8629b..563124d502 100644 --- a/tests/expectations/tests/jsval_layout_opaque_1_0.rs +++ b/tests/expectations/tests/jsval_layout_opaque_1_0.rs @@ -34,6 +34,7 @@ impl ::std::hash::Hash for __BindgenUnionField { impl ::std::cmp::PartialEq for __BindgenUnionField { fn eq(&self, _other: &__BindgenUnionField) -> bool { true } } +impl ::std::cmp::Eq for __BindgenUnionField { } 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; @@ -114,7 +115,7 @@ pub struct jsval_layout { pub bindgen_union_field: u64, } #[repr(C)] -#[derive(Debug, Copy, Hash, PartialEq)] +#[derive(Debug, Copy, Hash, PartialEq, Eq)] pub struct jsval_layout__bindgen_ty_1 { pub _bitfield_1: u64, pub __bindgen_align: [u64; 0usize], @@ -220,12 +221,12 @@ impl jsval_layout__bindgen_ty_1 { } } #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct jsval_layout__bindgen_ty_2 { pub payload: jsval_layout__bindgen_ty_2__bindgen_ty_1, } #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct jsval_layout__bindgen_ty_2__bindgen_ty_1 { pub i32: __BindgenUnionField, pub u32: __BindgenUnionField, diff --git a/tests/expectations/tests/opaque-template-inst-member-2.rs b/tests/expectations/tests/opaque-template-inst-member-2.rs index 848babe4c8..53122ba629 100644 --- a/tests/expectations/tests/opaque-template-inst-member-2.rs +++ b/tests/expectations/tests/opaque-template-inst-member-2.rs @@ -7,12 +7,12 @@ /// This is like `opaque-template-inst-member.hpp` except exercising the cases /// where we are OK to derive Debug/Hash/PartialEq. #[repr(C)] -#[derive(Debug, Default, Copy, Clone, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct OpaqueTemplate { } /// Should derive Debug/Hash/PartialEq. #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct ContainsOpaqueTemplate { pub mBlah: u32, pub mBaz: ::std::os::raw::c_int, @@ -41,7 +41,7 @@ impl Clone for ContainsOpaqueTemplate { } /// Should also derive Debug/Hash/PartialEq. #[repr(C)] -#[derive(Debug, Copy, Hash, PartialEq)] +#[derive(Debug, Copy, Hash, PartialEq, Eq)] 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 bab28917f2..32995873b1 100644 --- a/tests/expectations/tests/opaque-template-inst-member.rs +++ b/tests/expectations/tests/opaque-template-inst-member.rs @@ -5,7 +5,7 @@ #[repr(C)] -#[derive(Default, Copy, Clone, Hash, PartialEq)] +#[derive(Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct OpaqueTemplate { } /// This should not end up deriving Debug/Hash/PartialEq because its `mBlah` field cannot derive diff --git a/tests/expectations/tests/opaque-template-instantiation-namespaced.rs b/tests/expectations/tests/opaque-template-instantiation-namespaced.rs index 6fc0f840e8..7bf657ed2f 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, Hash, PartialEq)] + #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct Template { pub member: T, pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>, @@ -21,7 +21,7 @@ pub mod root { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } #[repr(C)] - #[derive(Debug, Default, Copy, Hash, PartialEq)] + #[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] 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, Hash, PartialEq)] + #[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] 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, Hash, PartialEq)] + #[derive(Debug, Copy, Hash, PartialEq, Eq)] pub struct ContainsInstantiation { pub not_opaque: root::zoidberg::Template, } @@ -89,7 +89,7 @@ pub mod root { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } #[repr(C)] - #[derive(Debug, Default, Copy, Hash, PartialEq)] + #[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] 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 89f42e5372..010186a574 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, Hash, PartialEq)] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct Template { pub member: T, pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>, @@ -14,7 +14,7 @@ impl Default for Template { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } #[repr(C)] -#[derive(Debug, Copy, Hash, PartialEq)] +#[derive(Debug, Copy, Hash, PartialEq, Eq)] 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, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct ContainsOpaqueInstantiation { pub opaque: u32, } diff --git a/tests/expectations/tests/opaque-tracing.rs b/tests/expectations/tests/opaque-tracing.rs index a5e0dc2b8c..8c80c83ae5 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, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] 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 29da8da454..a4ba46498b 100644 --- a/tests/expectations/tests/opaque_in_struct.rs +++ b/tests/expectations/tests/opaque_in_struct.rs @@ -6,7 +6,7 @@ ///
#[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] 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, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct container { pub contained: opaque, } diff --git a/tests/expectations/tests/opaque_pointer.rs b/tests/expectations/tests/opaque_pointer.rs index 7988a261c6..bd2a624e00 100644 --- a/tests/expectations/tests/opaque_pointer.rs +++ b/tests/expectations/tests/opaque_pointer.rs @@ -6,7 +6,7 @@ ///
#[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct OtherOpaque { pub _bindgen_opaque_blob: u32, } @@ -22,7 +22,7 @@ impl Clone for OtherOpaque { } ///
#[repr(C)] -#[derive(Debug, Default, Copy, Clone, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct Opaque { } #[repr(C)] diff --git a/tests/expectations/tests/opaque_typedef.rs b/tests/expectations/tests/opaque_typedef.rs index 0971739644..96df276ccd 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, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] 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 72d234fb1d..678586342e 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" --with-derive-hash --with-derive-partialeq +// bindgen-flags: --opaque-type "B" --whitelist-type "C" --with-derive-hash --with-derive-partialeq --with-derive-eq 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 e66ccc5e4f..91f221ce23 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 --with-derive-hash --with-derive-partialeq -- -std=c++11 +// bindgen-flags: --whitelist-type Whitelisted --opaque-type Opaque --with-derive-hash --with-derive-partialeq --with-derive-eq -- -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 6a730e8e92..09b5bebe4b 100644 --- a/tests/headers/jsval_layout_opaque.hpp +++ b/tests/headers/jsval_layout_opaque.hpp @@ -1,4 +1,4 @@ -// bindgen-flags: --with-derive-hash --with-derive-partialeq +// bindgen-flags: --with-derive-hash --with-derive-partialeq --with-derive-eq // bindgen-flags: -- -std=c++11 /** diff --git a/tests/headers/jsval_layout_opaque_1_0.hpp b/tests/headers/jsval_layout_opaque_1_0.hpp index dd598274bf..61eefe1e5a 100644 --- a/tests/headers/jsval_layout_opaque_1_0.hpp +++ b/tests/headers/jsval_layout_opaque_1_0.hpp @@ -1,4 +1,4 @@ -// bindgen-flags: --rust-target 1.0 --with-derive-hash --with-derive-partialeq +// bindgen-flags: --rust-target 1.0 --with-derive-hash --with-derive-partialeq --with-derive-eq // 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 09a4ea05ac..85b648ffb8 100644 --- a/tests/headers/opaque-template-inst-member-2.hpp +++ b/tests/headers/opaque-template-inst-member-2.hpp @@ -1,4 +1,4 @@ -// bindgen-flags: --opaque-type 'OpaqueTemplate' --with-derive-hash --with-derive-partialeq +// bindgen-flags: --opaque-type 'OpaqueTemplate' --with-derive-hash --with-derive-partialeq --with-derive-eq /// This is like `opaque-template-inst-member.hpp` except exercising the cases /// where we are OK to derive Debug/Hash/PartialEq. diff --git a/tests/headers/opaque-template-inst-member.hpp b/tests/headers/opaque-template-inst-member.hpp index 2586850f55..4cb3dd72fd 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' --with-derive-hash --with-derive-partialeq +// bindgen-flags: --opaque-type 'OpaqueTemplate' --with-derive-hash --with-derive-partialeq --with-derive-eq template class OpaqueTemplate { diff --git a/tests/headers/opaque-template-instantiation-namespaced.hpp b/tests/headers/opaque-template-instantiation-namespaced.hpp index 0c78fc7d69..e1cadcc2a9 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' --with-derive-hash --with-derive-partialeq -- -std=c++14 +// bindgen-flags: --enable-cxx-namespaces --opaque-type 'zoidberg::Template' --with-derive-hash --with-derive-partialeq --with-derive-eq -- -std=c++14 namespace zoidberg { diff --git a/tests/headers/opaque-template-instantiation.hpp b/tests/headers/opaque-template-instantiation.hpp index f0c860f045..fff49af287 100644 --- a/tests/headers/opaque-template-instantiation.hpp +++ b/tests/headers/opaque-template-instantiation.hpp @@ -1,4 +1,4 @@ -// bindgen-flags: --opaque-type 'Template' --with-derive-hash --with-derive-partialeq -- -std=c++14 +// bindgen-flags: --opaque-type 'Template' --with-derive-hash --with-derive-partialeq --with-derive-eq -- -std=c++14 template class Template { diff --git a/tests/headers/opaque-tracing.hpp b/tests/headers/opaque-tracing.hpp index 5ea7294799..326ebbe770 100644 --- a/tests/headers/opaque-tracing.hpp +++ b/tests/headers/opaque-tracing.hpp @@ -1,4 +1,4 @@ -// bindgen-flags: --opaque-type=.* --whitelist-function=foo --with-derive-hash --with-derive-partialeq +// bindgen-flags: --opaque-type=.* --whitelist-function=foo --with-derive-hash --with-derive-partialeq --with-derive-eq class Container; diff --git a/tests/headers/opaque_in_struct.hpp b/tests/headers/opaque_in_struct.hpp index 2de2de3ecf..12910e1f77 100644 --- a/tests/headers/opaque_in_struct.hpp +++ b/tests/headers/opaque_in_struct.hpp @@ -1,4 +1,4 @@ -// bindgen-flags: --with-derive-hash --with-derive-partialeq +// bindgen-flags: --with-derive-hash --with-derive-partialeq --with-derive-eq /**
*/ diff --git a/tests/headers/opaque_pointer.hpp b/tests/headers/opaque_pointer.hpp index 40475b8b1b..008689859b 100644 --- a/tests/headers/opaque_pointer.hpp +++ b/tests/headers/opaque_pointer.hpp @@ -1,4 +1,4 @@ -// bindgen-flags: --with-derive-hash --with-derive-partialeq +// bindgen-flags: --with-derive-hash --with-derive-partialeq --with-derive-eq /** *
diff --git a/tests/headers/opaque_typedef.hpp b/tests/headers/opaque_typedef.hpp index 805867781e..878d5bcbc1 100644 --- a/tests/headers/opaque_typedef.hpp +++ b/tests/headers/opaque_typedef.hpp @@ -1,4 +1,4 @@ -// bindgen-flags: --with-derive-hash --with-derive-partialeq -- -std=c++11 +// bindgen-flags: --with-derive-hash --with-derive-partialeq --with-derive-eq -- -std=c++11 template class RandomTemplate; From a3a00f2b89745d5fecdf738debf39a60893f5089 Mon Sep 17 00:00:00 2001 From: Zhiting Zhu Date: Wed, 16 Aug 2017 21:12:51 -0500 Subject: [PATCH 06/12] Function related tests for derive Eq --- tests/expectations/tests/derive-fn-ptr.rs | 2 +- tests/expectations/tests/func_ptr_in_struct.rs | 2 +- tests/headers/derive-fn-ptr.h | 2 +- tests/headers/func_ptr.h | 2 +- tests/headers/func_ptr_in_struct.h | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/expectations/tests/derive-fn-ptr.rs b/tests/expectations/tests/derive-fn-ptr.rs index c98f2ec7a9..ac4792969e 100644 --- a/tests/expectations/tests/derive-fn-ptr.rs +++ b/tests/expectations/tests/derive-fn-ptr.rs @@ -58,7 +58,7 @@ pub type my_fun2_t = arg11: ::std::os::raw::c_int, arg12: ::std::os::raw::c_int)>; #[repr(C)] -#[derive(Debug, Copy, Hash, PartialEq)] +#[derive(Debug, Copy, Hash, PartialEq, Eq)] pub struct Bar { pub callback: my_fun2_t, } diff --git a/tests/expectations/tests/func_ptr_in_struct.rs b/tests/expectations/tests/func_ptr_in_struct.rs index d0e076eea8..e3d1abffe0 100644 --- a/tests/expectations/tests/func_ptr_in_struct.rs +++ b/tests/expectations/tests/func_ptr_in_struct.rs @@ -7,7 +7,7 @@ #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub enum baz { } #[repr(C)] -#[derive(Debug, Copy, Hash, PartialEq)] +#[derive(Debug, Copy, Hash, PartialEq, Eq)] pub struct Foo { pub bar: ::std::option::Option Date: Wed, 16 Aug 2017 21:14:09 -0500 Subject: [PATCH 07/12] Complex float related tests for derive Eq --- tests/expectations/tests/complex.rs | 4 ++-- tests/headers/complex.h | 2 +- tests/headers/complex_global.h | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/expectations/tests/complex.rs b/tests/expectations/tests/complex.rs index 805733c7cb..6159f979a0 100644 --- a/tests/expectations/tests/complex.rs +++ b/tests/expectations/tests/complex.rs @@ -31,7 +31,7 @@ impl Clone for TestDouble { fn clone(&self) -> Self { *self } } #[repr(C)] -#[derive(Debug, Copy, Hash, PartialEq)] +#[derive(Debug, Copy, Hash, PartialEq, Eq)] pub struct TestDoublePtr { pub mMember: *mut __BindgenComplex, } @@ -74,7 +74,7 @@ impl Clone for TestFloat { fn clone(&self) -> Self { *self } } #[repr(C)] -#[derive(Debug, Copy, Hash, PartialEq)] +#[derive(Debug, Copy, Hash, PartialEq, Eq)] pub struct TestFloatPtr { pub mMember: *mut __BindgenComplex, } diff --git a/tests/headers/complex.h b/tests/headers/complex.h index d0fb05b4e2..2996be1feb 100644 --- a/tests/headers/complex.h +++ b/tests/headers/complex.h @@ -1,4 +1,4 @@ -// bindgen-flags: --with-derive-hash --with-derive-partialeq +// bindgen-flags: --with-derive-hash --with-derive-partialeq --with-derive-eq #define COMPLEX_TEST(ty_, name_) \ struct Test##name_ { \ diff --git a/tests/headers/complex_global.h b/tests/headers/complex_global.h index 6ceb62da62..6b9ffa53a1 100644 --- a/tests/headers/complex_global.h +++ b/tests/headers/complex_global.h @@ -1,4 +1,4 @@ -// bindgen-flags: --with-derive-hash --with-derive-partialeq +// bindgen-flags: --with-derive-hash --with-derive-partialeq --with-derive-eq float _Complex globalValueFloat; double _Complex globalValueDouble; long double _Complex globalValueLongDouble; From 8ed02618a57ead804c58b263f66dd8047c4bc9c6 Mon Sep 17 00:00:00 2001 From: Zhiting Zhu Date: Wed, 16 Aug 2017 21:15:15 -0500 Subject: [PATCH 08/12] Anonymous related tests for derive Eq --- tests/expectations/tests/anon_enum_trait.rs | 4 ++-- tests/expectations/tests/anon_struct_in_union.rs | 2 +- tests/expectations/tests/anon_struct_in_union_1_0.rs | 7 ++++--- tests/expectations/tests/anon_union.rs | 4 ++-- tests/expectations/tests/anon_union_1_0.rs | 11 ++++++----- tests/headers/anon_enum.hpp | 2 +- tests/headers/anon_enum_trait.hpp | 2 +- tests/headers/anon_struct_in_union.h | 2 +- tests/headers/anon_struct_in_union_1_0.h | 2 +- tests/headers/anon_union.hpp | 2 +- tests/headers/anon_union_1_0.hpp | 2 +- 11 files changed, 21 insertions(+), 19 deletions(-) diff --git a/tests/expectations/tests/anon_enum_trait.rs b/tests/expectations/tests/anon_enum_trait.rs index c2ae221b33..f0c1d364f5 100644 --- a/tests/expectations/tests/anon_enum_trait.rs +++ b/tests/expectations/tests/anon_enum_trait.rs @@ -5,7 +5,7 @@ #[repr(C)] -#[derive(Debug, Default, Copy, Clone, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct DataType { pub _address: u8, } @@ -27,7 +27,7 @@ pub const DataType_type_: DataType__bindgen_ty_1 = #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub enum DataType__bindgen_ty_1 { generic_type = 0, } #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct Foo { pub _address: u8, } diff --git a/tests/expectations/tests/anon_struct_in_union.rs b/tests/expectations/tests/anon_struct_in_union.rs index 9dbf30de56..783a62cf02 100644 --- a/tests/expectations/tests/anon_struct_in_union.rs +++ b/tests/expectations/tests/anon_struct_in_union.rs @@ -16,7 +16,7 @@ pub union s__bindgen_ty_1 { _bindgen_union_align: u32, } #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct s__bindgen_ty_1_inner { pub b: ::std::os::raw::c_int, } diff --git a/tests/expectations/tests/anon_struct_in_union_1_0.rs b/tests/expectations/tests/anon_struct_in_union_1_0.rs index 74b6fe4a1e..8c29f8e4f0 100644 --- a/tests/expectations/tests/anon_struct_in_union_1_0.rs +++ b/tests/expectations/tests/anon_struct_in_union_1_0.rs @@ -34,19 +34,20 @@ impl ::std::hash::Hash for __BindgenUnionField { impl ::std::cmp::PartialEq for __BindgenUnionField { fn eq(&self, _other: &__BindgenUnionField) -> bool { true } } +impl ::std::cmp::Eq for __BindgenUnionField { } #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct s { pub u: s__bindgen_ty_1, } #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct s__bindgen_ty_1 { pub field: __BindgenUnionField, pub bindgen_union_field: u32, } #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct s__bindgen_ty_1_inner { pub b: ::std::os::raw::c_int, } diff --git a/tests/expectations/tests/anon_union.rs b/tests/expectations/tests/anon_union.rs index a055cbe578..f2da118da2 100644 --- a/tests/expectations/tests/anon_union.rs +++ b/tests/expectations/tests/anon_union.rs @@ -17,12 +17,12 @@ pub const TErrorResult_UnionState_HasException: TErrorResult_UnionState = #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub enum TErrorResult_UnionState { HasMessage = 0, } #[repr(C)] -#[derive(Debug, Default, Copy, Clone, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct TErrorResult_Message { pub _address: u8, } #[repr(C)] -#[derive(Debug, Default, Copy, Clone, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct TErrorResult_DOMExceptionInfo { pub _address: u8, } diff --git a/tests/expectations/tests/anon_union_1_0.rs b/tests/expectations/tests/anon_union_1_0.rs index 64a177766d..b96928d42a 100644 --- a/tests/expectations/tests/anon_union_1_0.rs +++ b/tests/expectations/tests/anon_union_1_0.rs @@ -34,8 +34,9 @@ impl ::std::hash::Hash for __BindgenUnionField { impl ::std::cmp::PartialEq for __BindgenUnionField { fn eq(&self, _other: &__BindgenUnionField) -> bool { true } } +impl ::std::cmp::Eq for __BindgenUnionField { } #[repr(C)] -#[derive(Debug, Copy, Clone, Hash, PartialEq)] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct TErrorResult { pub mResult: ::std::os::raw::c_int, pub __bindgen_anon_1: TErrorResult__bindgen_ty_1, @@ -48,17 +49,17 @@ pub const TErrorResult_UnionState_HasException: TErrorResult_UnionState = #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub enum TErrorResult_UnionState { HasMessage = 0, } #[repr(C)] -#[derive(Debug, Default, Copy, Clone, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct TErrorResult_Message { pub _address: u8, } #[repr(C)] -#[derive(Debug, Default, Copy, Clone, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct TErrorResult_DOMExceptionInfo { pub _address: u8, } #[repr(C)] -#[derive(Debug, Default, Copy, Clone, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct TErrorResult__bindgen_ty_1 { pub mMessage: __BindgenUnionField<*mut TErrorResult_Message>, pub mDOMExceptionInfo: __BindgenUnionField<*mut TErrorResult_DOMExceptionInfo>, @@ -68,7 +69,7 @@ impl Default for TErrorResult { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } #[repr(C)] -#[derive(Debug, Copy, Hash, PartialEq)] +#[derive(Debug, Copy, Hash, PartialEq, Eq)] pub struct ErrorResult { pub _base: TErrorResult, } diff --git a/tests/headers/anon_enum.hpp b/tests/headers/anon_enum.hpp index 48df3c7a1a..3e8ff3d4ae 100644 --- a/tests/headers/anon_enum.hpp +++ b/tests/headers/anon_enum.hpp @@ -1,4 +1,4 @@ -// bindgen-flags: --with-derive-hash --with-derive-partialeq +// bindgen-flags: --with-derive-hash --with-derive-partialeq --with-derive-eq struct Test { int foo; float bar; diff --git a/tests/headers/anon_enum_trait.hpp b/tests/headers/anon_enum_trait.hpp index 7d16405489..865411e213 100644 --- a/tests/headers/anon_enum_trait.hpp +++ b/tests/headers/anon_enum_trait.hpp @@ -1,4 +1,4 @@ -// bindgen-flags: --with-derive-hash --with-derive-partialeq +// bindgen-flags: --with-derive-hash --with-derive-partialeq --with-derive-eq template class DataType { diff --git a/tests/headers/anon_struct_in_union.h b/tests/headers/anon_struct_in_union.h index 98d5505649..2587ede54a 100644 --- a/tests/headers/anon_struct_in_union.h +++ b/tests/headers/anon_struct_in_union.h @@ -1,4 +1,4 @@ -// bindgen-flags: --with-derive-hash --with-derive-partialeq +// bindgen-flags: --with-derive-hash --with-derive-partialeq --with-derive-eq struct s { union { struct inner { diff --git a/tests/headers/anon_struct_in_union_1_0.h b/tests/headers/anon_struct_in_union_1_0.h index 86e5ca73ae..6b59723a3c 100644 --- a/tests/headers/anon_struct_in_union_1_0.h +++ b/tests/headers/anon_struct_in_union_1_0.h @@ -1,4 +1,4 @@ -// bindgen-flags: --rust-target 1.0 --with-derive-hash --with-derive-partialeq +// bindgen-flags: --rust-target 1.0 --with-derive-hash --with-derive-partialeq --with-derive-eq struct s { union { diff --git a/tests/headers/anon_union.hpp b/tests/headers/anon_union.hpp index ca1d3bc194..8e649abb5e 100644 --- a/tests/headers/anon_union.hpp +++ b/tests/headers/anon_union.hpp @@ -1,4 +1,4 @@ -// bindgen-flags: --with-derive-hash --with-derive-partialeq +// bindgen-flags: --with-derive-hash --with-derive-partialeq --with-derive-eq template struct TErrorResult { enum UnionState { diff --git a/tests/headers/anon_union_1_0.hpp b/tests/headers/anon_union_1_0.hpp index 1a5e2b0dcd..699efa3203 100644 --- a/tests/headers/anon_union_1_0.hpp +++ b/tests/headers/anon_union_1_0.hpp @@ -1,4 +1,4 @@ -// bindgen-flags: --rust-target 1.0 --with-derive-hash --with-derive-partialeq +// bindgen-flags: --rust-target 1.0 --with-derive-hash --with-derive-partialeq --with-derive-eq template struct TErrorResult { From b87f4ba8ba8851cc9f8cbd06cbaf348c689aa402 Mon Sep 17 00:00:00 2001 From: Zhiting Zhu Date: Wed, 16 Aug 2017 21:17:21 -0500 Subject: [PATCH 09/12] Template related tests for derive Eq --- .../tests/anonymous-template-types.rs | 8 ++-- .../tests/empty_template_param_name.rs | 2 +- tests/expectations/tests/template-fun-ty.rs | 6 +-- tests/expectations/tests/template.rs | 42 +++++++++---------- tests/expectations/tests/template_alias.rs | 2 +- .../tests/template_alias_namespace.rs | 2 +- .../template_typedef_transitive_param.rs | 4 +- .../expectations/tests/templateref_opaque.rs | 4 +- tests/headers/anonymous-template-types.hpp | 2 +- tests/headers/empty_template_param_name.hpp | 2 +- tests/headers/template-fun-ty.hpp | 2 +- tests/headers/template.hpp | 2 +- tests/headers/template_alias.hpp | 2 +- tests/headers/template_alias_namespace.hpp | 2 +- .../template_typedef_transitive_param.hpp | 2 +- tests/headers/templateref_opaque.hpp | 2 +- 16 files changed, 43 insertions(+), 43 deletions(-) diff --git a/tests/expectations/tests/anonymous-template-types.rs b/tests/expectations/tests/anonymous-template-types.rs index cc6827516e..532e2427c9 100644 --- a/tests/expectations/tests/anonymous-template-types.rs +++ b/tests/expectations/tests/anonymous-template-types.rs @@ -5,7 +5,7 @@ #[repr(C)] -#[derive(Debug, Copy, Clone, Hash, PartialEq)] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct Foo { pub t_member: T, pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>, @@ -14,12 +14,12 @@ impl Default for Foo { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } #[repr(C)] -#[derive(Debug, Default, Copy, Clone, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct Bar { pub member: ::std::os::raw::c_char, } #[repr(C)] -#[derive(Debug, Copy, Clone, Hash, PartialEq)] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct Quux { pub v_member: V, pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>, @@ -28,7 +28,7 @@ impl Default for Quux { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } #[repr(C)] -#[derive(Debug, Default, Copy, Clone, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct Lobo { pub also_member: ::std::os::raw::c_char, } diff --git a/tests/expectations/tests/empty_template_param_name.rs b/tests/expectations/tests/empty_template_param_name.rs index aff9d14d54..30289ce48a 100644 --- a/tests/expectations/tests/empty_template_param_name.rs +++ b/tests/expectations/tests/empty_template_param_name.rs @@ -6,7 +6,7 @@ pub type __void_t = ::std::os::raw::c_void; #[repr(C)] -#[derive(Debug, Default, Copy, Clone, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct __iterator_traits { pub _address: u8, } diff --git a/tests/expectations/tests/template-fun-ty.rs b/tests/expectations/tests/template-fun-ty.rs index 1cecdada6f..8403f794a6 100644 --- a/tests/expectations/tests/template-fun-ty.rs +++ b/tests/expectations/tests/template-fun-ty.rs @@ -5,19 +5,19 @@ #[repr(C)] -#[derive(Debug, Default, Copy, Clone, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct Foo { pub _address: u8, } pub type Foo_FunctionPtr = ::std::option::Option T>; #[repr(C)] -#[derive(Debug, Default, Copy, Clone, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct RefPtr { pub _address: u8, } #[repr(C)] -#[derive(Debug, Default, Copy, Clone, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct RefPtr_Proxy { pub _address: u8, } diff --git a/tests/expectations/tests/template.rs b/tests/expectations/tests/template.rs index ff18874d12..91bdee729f 100644 --- a/tests/expectations/tests/template.rs +++ b/tests/expectations/tests/template.rs @@ -5,7 +5,7 @@ #[repr(C)] -#[derive(Debug, Hash, PartialEq)] +#[derive(Debug, Hash, PartialEq, Eq)] pub struct Foo { pub m_member: T, pub m_member_ptr: *mut T, @@ -16,7 +16,7 @@ impl Default for Foo { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } #[repr(C)] -#[derive(Debug, Copy, Clone, Hash, PartialEq)] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct B { pub m_member: T, pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>, @@ -34,7 +34,7 @@ pub struct mozilla_Foo { _unused: [u8; 0], } #[repr(C)] -#[derive(Debug, Copy, Hash, PartialEq)] +#[derive(Debug, Copy, Hash, PartialEq, Eq)] pub struct C { pub mB: B<::std::os::raw::c_uint>, pub mBConstPtr: B<*const ::std::os::raw::c_int>, @@ -140,13 +140,13 @@ impl Default for C { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } #[repr(C)] -#[derive(Debug, Hash, PartialEq)] +#[derive(Debug, Hash, PartialEq, Eq)] pub struct D { pub m_foo: D_MyFoo, } pub type D_MyFoo = Foo<::std::os::raw::c_int>; #[repr(C)] -#[derive(Debug, Hash, PartialEq)] +#[derive(Debug, Hash, PartialEq, Eq)] pub struct D_U { pub m_nested_foo: D_MyFoo, pub m_baz: Z, @@ -159,7 +159,7 @@ impl Default for D { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } #[repr(C)] -#[derive(Debug, Copy, Clone, Hash, PartialEq)] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct Rooted { pub prev: *mut T, pub next: *mut Rooted<*mut ::std::os::raw::c_void>, @@ -170,7 +170,7 @@ impl Default for Rooted { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } #[repr(C)] -#[derive(Debug, Copy, Hash, PartialEq)] +#[derive(Debug, Copy, Hash, PartialEq, Eq)] pub struct RootedContainer { pub root: Rooted<*mut ::std::os::raw::c_void>, } @@ -193,7 +193,7 @@ impl Default for RootedContainer { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } #[repr(C)] -#[derive(Debug, Hash, PartialEq)] +#[derive(Debug, Hash, PartialEq, Eq)] pub struct WithDtor { pub member: T, pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>, @@ -203,7 +203,7 @@ impl Default for WithDtor { } pub type WithDtorIntFwd = WithDtor<::std::os::raw::c_int>; #[repr(C)] -#[derive(Debug, Hash, PartialEq)] +#[derive(Debug, Hash, PartialEq, Eq)] pub struct PODButContainsDtor { pub member: WithDtorIntFwd, } @@ -224,11 +224,11 @@ impl Default for PODButContainsDtor { } ///
#[repr(C)] -#[derive(Debug, Default, Copy, Clone, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct Opaque { } #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct POD { pub opaque_member: u32, } @@ -249,7 +249,7 @@ impl Clone for POD { } ///
#[repr(C)] -#[derive(Debug, Copy, Clone, Hash, PartialEq)] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct NestedReplaced { pub buff: *mut T, pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>, @@ -258,7 +258,7 @@ impl Default for NestedReplaced { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } #[repr(C)] -#[derive(Debug, Copy, Clone, Hash, PartialEq)] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct NestedBase { pub buff: *mut T, pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>, @@ -267,7 +267,7 @@ impl Default for NestedBase { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } #[repr(C)] -#[derive(Debug, Copy, Clone, Hash, PartialEq)] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct Incomplete { pub d: T, pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>, @@ -276,7 +276,7 @@ impl Default for Incomplete { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } #[repr(C)] -#[derive(Debug, Copy, Clone, Hash, PartialEq)] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct NestedContainer { pub c: T, pub nested: NestedReplaced, @@ -287,7 +287,7 @@ impl Default for NestedContainer { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct Untemplated { pub _address: u8, } @@ -302,7 +302,7 @@ impl Clone for Untemplated { fn clone(&self) -> Self { *self } } #[repr(C)] -#[derive(Debug, Default, Copy, Clone, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct Templated { pub m_untemplated: Untemplated, } @@ -311,7 +311,7 @@ pub struct Templated { /// ///
#[repr(C)] -#[derive(Debug, Hash, PartialEq)] +#[derive(Debug, Hash, PartialEq, Eq)] pub struct ReplacedWithoutDestructor { pub buff: *mut T, pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>, @@ -320,7 +320,7 @@ impl Default for ReplacedWithoutDestructor { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } #[repr(C)] -#[derive(Debug, Hash, PartialEq)] +#[derive(Debug, Hash, PartialEq, Eq)] pub struct ShouldNotBeCopiable { pub m_member: ReplacedWithoutDestructor, pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>, @@ -329,7 +329,7 @@ impl Default for ShouldNotBeCopiable { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } #[repr(C)] -#[derive(Debug, Hash, PartialEq)] +#[derive(Debug, Hash, PartialEq, Eq)] pub struct ShouldNotBeCopiableAsWell { pub m_member: ReplacedWithoutDestructorFwd, pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>, @@ -342,7 +342,7 @@ impl Default for ShouldNotBeCopiableAsWell { /// ///
#[repr(C)] -#[derive(Debug, Hash, PartialEq)] +#[derive(Debug, Hash, PartialEq, Eq)] pub struct ReplacedWithoutDestructorFwd { pub buff: *mut T, pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>, diff --git a/tests/expectations/tests/template_alias.rs b/tests/expectations/tests/template_alias.rs index 1857e71401..c3f080dbf9 100644 --- a/tests/expectations/tests/template_alias.rs +++ b/tests/expectations/tests/template_alias.rs @@ -6,7 +6,7 @@ pub type JS_detail_Wrapped = T; #[repr(C)] -#[derive(Debug, Copy, Clone, Hash, PartialEq)] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct JS_Rooted { pub ptr: JS_detail_Wrapped, pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>, diff --git a/tests/expectations/tests/template_alias_namespace.rs b/tests/expectations/tests/template_alias_namespace.rs index 46db54dd04..a9cd315d90 100644 --- a/tests/expectations/tests/template_alias_namespace.rs +++ b/tests/expectations/tests/template_alias_namespace.rs @@ -17,7 +17,7 @@ pub mod root { pub type Wrapped = T; } #[repr(C)] - #[derive(Debug, Copy, Clone, Hash, PartialEq)] + #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct Rooted { pub ptr: root::JS::detail::Wrapped, pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>, diff --git a/tests/expectations/tests/template_typedef_transitive_param.rs b/tests/expectations/tests/template_typedef_transitive_param.rs index d31144132b..7768d522e6 100644 --- a/tests/expectations/tests/template_typedef_transitive_param.rs +++ b/tests/expectations/tests/template_typedef_transitive_param.rs @@ -5,12 +5,12 @@ #[repr(C)] -#[derive(Debug, Default, Copy, Clone, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct Wrapper { pub _address: u8, } #[repr(C)] -#[derive(Debug, Copy, Clone, Hash, PartialEq)] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct Wrapper_Wrapped { pub t: T, pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>, diff --git a/tests/expectations/tests/templateref_opaque.rs b/tests/expectations/tests/templateref_opaque.rs index 3f11938280..481a31bba6 100644 --- a/tests/expectations/tests/templateref_opaque.rs +++ b/tests/expectations/tests/templateref_opaque.rs @@ -5,13 +5,13 @@ #[repr(C)] -#[derive(Debug, Default, Copy, Clone, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct detail_PointerType { pub _address: u8, } pub type detail_PointerType_Type = *mut T; #[repr(C)] -#[derive(Debug, Default, Copy, Clone, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct UniquePtr { pub _address: u8, } diff --git a/tests/headers/anonymous-template-types.hpp b/tests/headers/anonymous-template-types.hpp index 883f60f583..d4ad534b2b 100644 --- a/tests/headers/anonymous-template-types.hpp +++ b/tests/headers/anonymous-template-types.hpp @@ -1,4 +1,4 @@ -// bindgen-flags: --with-derive-hash --with-derive-partialeq -- -std=c++14 +// bindgen-flags: --with-derive-hash --with-derive-partialeq --with-derive-eq -- -std=c++14 template struct Foo { diff --git a/tests/headers/empty_template_param_name.hpp b/tests/headers/empty_template_param_name.hpp index 11b6221c44..ab2aab9241 100644 --- a/tests/headers/empty_template_param_name.hpp +++ b/tests/headers/empty_template_param_name.hpp @@ -1,4 +1,4 @@ -// bindgen-flags: --with-derive-hash --with-derive-partialeq +// bindgen-flags: --with-derive-hash --with-derive-partialeq --with-derive-eq // bindgen-flags: -- -std=c++11 template using __void_t = void; diff --git a/tests/headers/template-fun-ty.hpp b/tests/headers/template-fun-ty.hpp index ea820e2a2a..bb9d23cf13 100644 --- a/tests/headers/template-fun-ty.hpp +++ b/tests/headers/template-fun-ty.hpp @@ -1,4 +1,4 @@ -// bindgen-flags: --with-derive-hash --with-derive-partialeq +// bindgen-flags: --with-derive-hash --with-derive-partialeq --with-derive-eq template class Foo { diff --git a/tests/headers/template.hpp b/tests/headers/template.hpp index b7566c71d1..eea2c4def5 100644 --- a/tests/headers/template.hpp +++ b/tests/headers/template.hpp @@ -1,4 +1,4 @@ -// bindgen-flags: --with-derive-hash --with-derive-partialeq -- -std=c++11 +// bindgen-flags: --with-derive-hash --with-derive-partialeq --with-derive-eq -- -std=c++11 // template class Foo { T m_member; diff --git a/tests/headers/template_alias.hpp b/tests/headers/template_alias.hpp index 1877db5c55..8b3ea692ef 100644 --- a/tests/headers/template_alias.hpp +++ b/tests/headers/template_alias.hpp @@ -1,4 +1,4 @@ -// bindgen-flags: --with-derive-hash --with-derive-partialeq -- -std=c++14 +// bindgen-flags: --with-derive-hash --with-derive-partialeq --with-derive-eq -- -std=c++14 namespace JS { namespace detail { diff --git a/tests/headers/template_alias_namespace.hpp b/tests/headers/template_alias_namespace.hpp index fafa6f2739..c20bf2069b 100644 --- a/tests/headers/template_alias_namespace.hpp +++ b/tests/headers/template_alias_namespace.hpp @@ -1,4 +1,4 @@ -// bindgen-flags: --with-derive-hash --with-derive-partialeq --enable-cxx-namespaces -- -std=c++14 +// bindgen-flags: --with-derive-hash --with-derive-partialeq --with-derive-eq --enable-cxx-namespaces -- -std=c++14 namespace JS { namespace detail { diff --git a/tests/headers/template_typedef_transitive_param.hpp b/tests/headers/template_typedef_transitive_param.hpp index 0f657c1e36..34a5b92c25 100644 --- a/tests/headers/template_typedef_transitive_param.hpp +++ b/tests/headers/template_typedef_transitive_param.hpp @@ -1,4 +1,4 @@ -// bindgen-flags: --with-derive-hash --with-derive-partialeq +// bindgen-flags: --with-derive-hash --with-derive-partialeq --with-derive-eq template struct Wrapper { struct Wrapped { diff --git a/tests/headers/templateref_opaque.hpp b/tests/headers/templateref_opaque.hpp index e52f7e8215..2f6a002718 100644 --- a/tests/headers/templateref_opaque.hpp +++ b/tests/headers/templateref_opaque.hpp @@ -1,4 +1,4 @@ -// bindgen-flags: --with-derive-hash --with-derive-partialeq +// bindgen-flags: --with-derive-hash --with-derive-partialeq --with-derive-eq namespace detail { template From bca8be63ab6e7a8be327bacadca33abe9bc18d4c Mon Sep 17 00:00:00 2001 From: Zhiting Zhu Date: Wed, 16 Aug 2017 21:22:51 -0500 Subject: [PATCH 10/12] Layout related tests for derive Eq --- .../issue-648-derive-debug-with-padding.rs | 4 +- tests/expectations/tests/layout_array.rs | 6 +-- .../tests/layout_array_too_long.rs | 8 ++-- tests/expectations/tests/layout_eth_conf.rs | 34 ++++++++--------- .../expectations/tests/layout_eth_conf_1_0.rs | 37 ++++++++++--------- tests/expectations/tests/layout_mbuf.rs | 12 +++--- tests/expectations/tests/layout_mbuf_1_0.rs | 27 +++++++------- .../issue-648-derive-debug-with-padding.h | 2 +- tests/headers/layout_array.h | 2 +- tests/headers/layout_array_too_long.h | 2 +- tests/headers/layout_eth_conf.h | 2 +- tests/headers/layout_eth_conf_1_0.h | 2 +- tests/headers/layout_mbuf.h | 2 +- tests/headers/layout_mbuf_1_0.h | 2 +- 14 files changed, 72 insertions(+), 70 deletions(-) diff --git a/tests/expectations/tests/issue-648-derive-debug-with-padding.rs b/tests/expectations/tests/issue-648-derive-debug-with-padding.rs index b77b0e60d3..85937c3f96 100644 --- a/tests/expectations/tests/issue-648-derive-debug-with-padding.rs +++ b/tests/expectations/tests/issue-648-derive-debug-with-padding.rs @@ -30,8 +30,8 @@ impl Clone for NoDebug { impl Default for NoDebug { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } -/// This should derive Debug/Hash/PartialEq because the padding size is less than the max derive -/// Debug/Hash/PartialEq impl for arrays. However, we conservatively don't derive Debug/Hash because +/// This should derive Debug/Hash/PartialEq/Eq because the padding size is less than the max derive +/// Debug/Hash/PartialEq/Eq impl for arrays. However, we conservatively don't derive Debug/Hash because /// we determine Debug derive-ability before we compute padding, which happens at /// codegen. (Again, we expect to get the alignment wrong for similar reasons.) #[repr(C)] diff --git a/tests/expectations/tests/layout_array.rs b/tests/expectations/tests/layout_array.rs index 081000bd08..9f2082ecfa 100644 --- a/tests/expectations/tests/layout_array.rs +++ b/tests/expectations/tests/layout_array.rs @@ -106,7 +106,7 @@ impl Default for rte_mempool_ops { } /// The rte_spinlock_t type. #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct rte_spinlock_t { /// < lock status 0 = unlocked, 1 = locked pub locked: ::std::os::raw::c_int, @@ -181,7 +181,7 @@ pub struct malloc_heap { pub total_size: usize, } #[repr(C)] -#[derive(Debug, Copy, Hash, PartialEq)] +#[derive(Debug, Copy, Hash, PartialEq, Eq)] pub struct malloc_heap__bindgen_ty_1 { pub lh_first: *mut malloc_elem, } @@ -239,7 +239,7 @@ impl Default for malloc_heap { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct malloc_elem { pub _address: u8, } diff --git a/tests/expectations/tests/layout_array_too_long.rs b/tests/expectations/tests/layout_array_too_long.rs index b68d9a33c8..1a3da41ea6 100644 --- a/tests/expectations/tests/layout_array_too_long.rs +++ b/tests/expectations/tests/layout_array_too_long.rs @@ -20,7 +20,7 @@ pub enum _bindgen_ty_1 { } /// @internal fragmented mbuf #[repr(C)] -#[derive(Debug, Copy, Hash, PartialEq)] +#[derive(Debug, Copy, Hash, PartialEq, Eq)] pub struct ip_frag { /// < offset into the packet pub ofs: u16, @@ -59,7 +59,7 @@ impl Default for ip_frag { } /// @internal to uniquely indetify fragmented datagram. #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct ip_frag_key { /// < src address, first 8 bytes used for IPv4 pub src_dst: [u64; 4usize], @@ -115,7 +115,7 @@ pub struct ip_frag_pkt { pub __bindgen_padding_0: [u64; 6usize], } #[repr(C)] -#[derive(Debug, Copy, Hash, PartialEq)] +#[derive(Debug, Copy, Hash, PartialEq, Eq)] pub struct ip_frag_pkt__bindgen_ty_1 { pub tqe_next: *mut ip_frag_pkt, pub tqe_prev: *mut *mut ip_frag_pkt, @@ -196,7 +196,7 @@ impl Default for ip_frag_pkt { } /// < fragment mbuf #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct rte_mbuf { pub _address: u8, } diff --git a/tests/expectations/tests/layout_eth_conf.rs b/tests/expectations/tests/layout_eth_conf.rs index 1926ae7cbc..38c105d334 100644 --- a/tests/expectations/tests/layout_eth_conf.rs +++ b/tests/expectations/tests/layout_eth_conf.rs @@ -52,7 +52,7 @@ pub enum rte_eth_rx_mq_mode { } /// A structure used to configure the RX features of an Ethernet port. #[repr(C)] -#[derive(Debug, Copy, Hash, PartialEq)] +#[derive(Debug, Copy, Hash, PartialEq, Eq)] pub struct rte_eth_rxmode { /// The multi-queue packet distribution mode to be used, e.g. RSS. pub mq_mode: rte_eth_rx_mq_mode, @@ -470,7 +470,7 @@ pub enum rte_eth_tx_mq_mode { } /// A structure used to configure the TX features of an Ethernet port. #[repr(C)] -#[derive(Debug, Copy, Hash, PartialEq)] +#[derive(Debug, Copy, Hash, PartialEq, Eq)] pub struct rte_eth_txmode { /// < TX multi-queues mode. pub mq_mode: rte_eth_tx_mq_mode, @@ -641,7 +641,7 @@ impl rte_eth_txmode { /// types of IPv4/IPv6 packets to which the RSS hashing must be applied. /// Supplying an *rss_hf* equal to zero disables the RSS feature. #[repr(C)] -#[derive(Debug, Copy, Hash, PartialEq)] +#[derive(Debug, Copy, Hash, PartialEq, Eq)] pub struct rte_eth_rss_conf { /// < If not NULL, 40-byte hash key. pub rss_key: *mut u8, @@ -718,7 +718,7 @@ pub struct rte_eth_vmdq_dcb_conf { pub dcb_tc: [u8; 8usize], } #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct rte_eth_vmdq_dcb_conf__bindgen_ty_1 { /// < The vlan id of the received frame pub vlan_id: u16, @@ -798,7 +798,7 @@ impl Default for rte_eth_vmdq_dcb_conf { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } #[repr(C)] -#[derive(Debug, Copy, Hash, PartialEq)] +#[derive(Debug, Copy, Hash, PartialEq, Eq)] pub struct rte_eth_dcb_rx_conf { /// < Possible DCB TCs, 4 or 8 TCs pub nb_tcs: rte_eth_nb_tcs, @@ -830,7 +830,7 @@ impl Default for rte_eth_dcb_rx_conf { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } #[repr(C)] -#[derive(Debug, Copy, Hash, PartialEq)] +#[derive(Debug, Copy, Hash, PartialEq, Eq)] pub struct rte_eth_vmdq_dcb_tx_conf { /// < With DCB, 16 or 32 pools. pub nb_queue_pools: rte_eth_nb_pools, @@ -864,7 +864,7 @@ impl Default for rte_eth_vmdq_dcb_tx_conf { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } #[repr(C)] -#[derive(Debug, Copy, Hash, PartialEq)] +#[derive(Debug, Copy, Hash, PartialEq, Eq)] pub struct rte_eth_dcb_tx_conf { /// < Possible DCB TCs, 4 or 8 TCs. pub nb_tcs: rte_eth_nb_tcs, @@ -896,7 +896,7 @@ impl Default for rte_eth_dcb_tx_conf { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } #[repr(C)] -#[derive(Debug, Copy, Hash, PartialEq)] +#[derive(Debug, Copy, Hash, PartialEq, Eq)] pub struct rte_eth_vmdq_tx_conf { /// < VMDq mode, 64 pools. pub nb_queue_pools: rte_eth_nb_pools, @@ -939,7 +939,7 @@ pub struct rte_eth_vmdq_rx_conf { pub pool_map: [rte_eth_vmdq_rx_conf__bindgen_ty_1; 64usize], } #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct rte_eth_vmdq_rx_conf__bindgen_ty_1 { /// < The vlan id of the received frame pub vlan_id: u16, @@ -1052,7 +1052,7 @@ pub enum rte_fdir_status_mode { } /// A structure used to define the input for IPV4 flow #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct rte_eth_ipv4_flow { /// < IPv4 source address in big endian. pub src_ip: u32, @@ -1102,7 +1102,7 @@ impl Clone for rte_eth_ipv4_flow { } /// A structure used to define the input for IPV6 flow #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct rte_eth_ipv6_flow { /// < IPv6 source address in big endian. pub src_ip: [u32; 4usize], @@ -1153,7 +1153,7 @@ impl Clone for rte_eth_ipv6_flow { /// A structure used to configure FDIR masks that are used by the device /// to match the various fields of RX packet headers. #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct rte_eth_fdir_masks { /// < Bit mask for vlan_tci in big endian pub vlan_tci_mask: u16, @@ -1239,7 +1239,7 @@ pub enum rte_eth_payload_type { /// A structure used to select bytes extracted from the protocol layers to /// flexible payload for filter #[repr(C)] -#[derive(Debug, Copy, Hash, PartialEq)] +#[derive(Debug, Copy, Hash, PartialEq, Eq)] pub struct rte_eth_flex_payload_cfg { /// < Payload type pub type_: rte_eth_payload_type, @@ -1274,7 +1274,7 @@ impl Default for rte_eth_flex_payload_cfg { /// A structure used to define FDIR masks for flexible payload /// for each flow type #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct rte_eth_fdir_flex_mask { pub flow_type: u16, pub mask: [u8; 16usize], @@ -1304,7 +1304,7 @@ impl Clone for rte_eth_fdir_flex_mask { /// A structure used to define all flexible payload related setting /// include flex payload and flex mask #[repr(C)] -#[derive(Debug, Copy, Hash, PartialEq)] +#[derive(Debug, Copy, Hash, PartialEq, Eq)] pub struct rte_eth_fdir_flex_conf { /// < The number of following payload cfg pub nb_payloads: u16, @@ -1353,7 +1353,7 @@ impl Default for rte_eth_fdir_flex_conf { /// /// If mode is RTE_FDIR_DISABLE, the pballoc value is ignored. #[repr(C)] -#[derive(Debug, Copy, Hash, PartialEq)] +#[derive(Debug, Copy, Hash, PartialEq, Eq)] pub struct rte_fdir_conf { /// < Flow Director mode. pub mode: rte_fdir_mode, @@ -1411,7 +1411,7 @@ impl Default for rte_fdir_conf { } /// A structure used to enable/disable specific device interrupts. #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct rte_intr_conf { /// enable/disable lsc interrupt. 0 (default) - disable, 1 enable pub lsc: u16, diff --git a/tests/expectations/tests/layout_eth_conf_1_0.rs b/tests/expectations/tests/layout_eth_conf_1_0.rs index b845321e8e..c03a3dd4b0 100644 --- a/tests/expectations/tests/layout_eth_conf_1_0.rs +++ b/tests/expectations/tests/layout_eth_conf_1_0.rs @@ -34,6 +34,7 @@ impl ::std::hash::Hash for __BindgenUnionField { impl ::std::cmp::PartialEq for __BindgenUnionField { fn eq(&self, _other: &__BindgenUnionField) -> bool { true } } +impl ::std::cmp::Eq for __BindgenUnionField { } pub const ETH_MQ_RX_RSS_FLAG: ::std::os::raw::c_uint = 1; pub const ETH_MQ_RX_DCB_FLAG: ::std::os::raw::c_uint = 2; pub const ETH_MQ_RX_VMDQ_FLAG: ::std::os::raw::c_uint = 4; @@ -82,7 +83,7 @@ pub enum rte_eth_rx_mq_mode { } /// A structure used to configure the RX features of an Ethernet port. #[repr(C)] -#[derive(Debug, Copy, Hash, PartialEq)] +#[derive(Debug, Copy, Hash, PartialEq, Eq)] pub struct rte_eth_rxmode { /// The multi-queue packet distribution mode to be used, e.g. RSS. pub mq_mode: rte_eth_rx_mq_mode, @@ -500,7 +501,7 @@ pub enum rte_eth_tx_mq_mode { } /// A structure used to configure the TX features of an Ethernet port. #[repr(C)] -#[derive(Debug, Copy, Hash, PartialEq)] +#[derive(Debug, Copy, Hash, PartialEq, Eq)] pub struct rte_eth_txmode { /// < TX multi-queues mode. pub mq_mode: rte_eth_tx_mq_mode, @@ -671,7 +672,7 @@ impl rte_eth_txmode { /// types of IPv4/IPv6 packets to which the RSS hashing must be applied. /// Supplying an *rss_hf* equal to zero disables the RSS feature. #[repr(C)] -#[derive(Debug, Copy, Hash, PartialEq)] +#[derive(Debug, Copy, Hash, PartialEq, Eq)] pub struct rte_eth_rss_conf { /// < If not NULL, 40-byte hash key. pub rss_key: *mut u8, @@ -748,7 +749,7 @@ pub struct rte_eth_vmdq_dcb_conf { pub dcb_tc: [u8; 8usize], } #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct rte_eth_vmdq_dcb_conf__bindgen_ty_1 { /// < The vlan id of the received frame pub vlan_id: u16, @@ -828,7 +829,7 @@ impl Default for rte_eth_vmdq_dcb_conf { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } #[repr(C)] -#[derive(Debug, Copy, Hash, PartialEq)] +#[derive(Debug, Copy, Hash, PartialEq, Eq)] pub struct rte_eth_dcb_rx_conf { /// < Possible DCB TCs, 4 or 8 TCs pub nb_tcs: rte_eth_nb_tcs, @@ -860,7 +861,7 @@ impl Default for rte_eth_dcb_rx_conf { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } #[repr(C)] -#[derive(Debug, Copy, Hash, PartialEq)] +#[derive(Debug, Copy, Hash, PartialEq, Eq)] pub struct rte_eth_vmdq_dcb_tx_conf { /// < With DCB, 16 or 32 pools. pub nb_queue_pools: rte_eth_nb_pools, @@ -894,7 +895,7 @@ impl Default for rte_eth_vmdq_dcb_tx_conf { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } #[repr(C)] -#[derive(Debug, Copy, Hash, PartialEq)] +#[derive(Debug, Copy, Hash, PartialEq, Eq)] pub struct rte_eth_dcb_tx_conf { /// < Possible DCB TCs, 4 or 8 TCs. pub nb_tcs: rte_eth_nb_tcs, @@ -926,7 +927,7 @@ impl Default for rte_eth_dcb_tx_conf { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } #[repr(C)] -#[derive(Debug, Copy, Hash, PartialEq)] +#[derive(Debug, Copy, Hash, PartialEq, Eq)] pub struct rte_eth_vmdq_tx_conf { /// < VMDq mode, 64 pools. pub nb_queue_pools: rte_eth_nb_pools, @@ -969,7 +970,7 @@ pub struct rte_eth_vmdq_rx_conf { pub pool_map: [rte_eth_vmdq_rx_conf__bindgen_ty_1; 64usize], } #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct rte_eth_vmdq_rx_conf__bindgen_ty_1 { /// < The vlan id of the received frame pub vlan_id: u16, @@ -1082,7 +1083,7 @@ pub enum rte_fdir_status_mode { } /// A structure used to define the input for IPV4 flow #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct rte_eth_ipv4_flow { /// < IPv4 source address in big endian. pub src_ip: u32, @@ -1132,7 +1133,7 @@ impl Clone for rte_eth_ipv4_flow { } /// A structure used to define the input for IPV6 flow #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct rte_eth_ipv6_flow { /// < IPv6 source address in big endian. pub src_ip: [u32; 4usize], @@ -1183,7 +1184,7 @@ impl Clone for rte_eth_ipv6_flow { /// A structure used to configure FDIR masks that are used by the device /// to match the various fields of RX packet headers. #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct rte_eth_fdir_masks { /// < Bit mask for vlan_tci in big endian pub vlan_tci_mask: u16, @@ -1269,7 +1270,7 @@ pub enum rte_eth_payload_type { /// A structure used to select bytes extracted from the protocol layers to /// flexible payload for filter #[repr(C)] -#[derive(Debug, Copy, Hash, PartialEq)] +#[derive(Debug, Copy, Hash, PartialEq, Eq)] pub struct rte_eth_flex_payload_cfg { /// < Payload type pub type_: rte_eth_payload_type, @@ -1304,7 +1305,7 @@ impl Default for rte_eth_flex_payload_cfg { /// A structure used to define FDIR masks for flexible payload /// for each flow type #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct rte_eth_fdir_flex_mask { pub flow_type: u16, pub mask: [u8; 16usize], @@ -1334,7 +1335,7 @@ impl Clone for rte_eth_fdir_flex_mask { /// A structure used to define all flexible payload related setting /// include flex payload and flex mask #[repr(C)] -#[derive(Debug, Copy, Hash, PartialEq)] +#[derive(Debug, Copy, Hash, PartialEq, Eq)] pub struct rte_eth_fdir_flex_conf { /// < The number of following payload cfg pub nb_payloads: u16, @@ -1383,7 +1384,7 @@ impl Default for rte_eth_fdir_flex_conf { /// /// If mode is RTE_FDIR_DISABLE, the pballoc value is ignored. #[repr(C)] -#[derive(Debug, Copy, Hash, PartialEq)] +#[derive(Debug, Copy, Hash, PartialEq, Eq)] pub struct rte_fdir_conf { /// < Flow Director mode. pub mode: rte_fdir_mode, @@ -1441,7 +1442,7 @@ impl Default for rte_fdir_conf { } /// A structure used to enable/disable specific device interrupts. #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct rte_intr_conf { /// enable/disable lsc interrupt. 0 (default) - disable, 1 enable pub lsc: u16, @@ -1554,7 +1555,7 @@ impl Default for rte_eth_conf__bindgen_ty_1 { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct rte_eth_conf__bindgen_ty_2 { pub vmdq_dcb_tx_conf: __BindgenUnionField, pub dcb_tx_conf: __BindgenUnionField, diff --git a/tests/expectations/tests/layout_mbuf.rs b/tests/expectations/tests/layout_mbuf.rs index b336e548a3..63cd92bb9c 100644 --- a/tests/expectations/tests/layout_mbuf.rs +++ b/tests/expectations/tests/layout_mbuf.rs @@ -12,7 +12,7 @@ pub type MARKER8 = [u8; 0usize]; pub type MARKER64 = [u64; 0usize]; /// The atomic counter structure. #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct rte_atomic16_t { /// < An internal counter value. pub cnt: i16, @@ -128,7 +128,7 @@ pub union rte_mbuf__bindgen_ty_2 { _bindgen_union_align: u32, } #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct rte_mbuf__bindgen_ty_2__bindgen_ty_1 { pub _bitfield_1: [u8; 4usize], pub __bindgen_align: [u32; 0usize], @@ -480,7 +480,7 @@ pub union rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1 { _bindgen_union_align: u32, } #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1 { pub hash: u16, pub id: u16, @@ -570,7 +570,7 @@ impl Default for rte_mbuf__bindgen_ty_3__bindgen_ty_1 { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct rte_mbuf__bindgen_ty_3__bindgen_ty_2 { pub lo: u32, pub hi: u32, @@ -679,7 +679,7 @@ pub union rte_mbuf__bindgen_ty_5 { _bindgen_union_align: u64, } #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct rte_mbuf__bindgen_ty_5__bindgen_ty_1 { pub _bitfield_1: [u16; 4usize], pub __bindgen_align: [u64; 0usize], @@ -1079,7 +1079,7 @@ impl Default for rte_mbuf { } /// < Pool from which mbuf was allocated. #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct rte_mempool { pub _address: u8, } diff --git a/tests/expectations/tests/layout_mbuf_1_0.rs b/tests/expectations/tests/layout_mbuf_1_0.rs index afe46930bb..b9c6e69bb6 100644 --- a/tests/expectations/tests/layout_mbuf_1_0.rs +++ b/tests/expectations/tests/layout_mbuf_1_0.rs @@ -34,6 +34,7 @@ impl ::std::hash::Hash for __BindgenUnionField { impl ::std::cmp::PartialEq for __BindgenUnionField { fn eq(&self, _other: &__BindgenUnionField) -> bool { true } } +impl ::std::cmp::Eq for __BindgenUnionField { } pub const RTE_CACHE_LINE_MIN_SIZE: ::std::os::raw::c_uint = 64; pub const RTE_CACHE_LINE_SIZE: ::std::os::raw::c_uint = 64; pub type phys_addr_t = u64; @@ -42,7 +43,7 @@ pub type MARKER8 = [u8; 0usize]; pub type MARKER64 = [u64; 0usize]; /// The atomic counter structure. #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct rte_atomic16_t { /// < An internal counter value. pub cnt: i16, @@ -116,7 +117,7 @@ pub struct rte_mbuf { /// or non-atomic) is controlled by the CONFIG_RTE_MBUF_REFCNT_ATOMIC /// config option. #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct rte_mbuf__bindgen_ty_1 { /// < Atomically accessed refcnt pub refcnt_atomic: __BindgenUnionField, @@ -147,7 +148,7 @@ impl Clone for rte_mbuf__bindgen_ty_1 { fn clone(&self) -> Self { *self } } #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct rte_mbuf__bindgen_ty_2 { /// < L2/L3/L4 and tunnel information. pub packet_type: __BindgenUnionField, @@ -155,7 +156,7 @@ pub struct rte_mbuf__bindgen_ty_2 { pub bindgen_union_field: u32, } #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct rte_mbuf__bindgen_ty_2__bindgen_ty_1 { pub _bitfield_1: [u8; 4usize], pub __bindgen_align: [u32; 0usize], @@ -478,7 +479,7 @@ impl Clone for rte_mbuf__bindgen_ty_2 { fn clone(&self) -> Self { *self } } #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct rte_mbuf__bindgen_ty_3 { /// < RSS hash result if RSS enabled pub rss: __BindgenUnionField, @@ -491,20 +492,20 @@ pub struct rte_mbuf__bindgen_ty_3 { pub bindgen_union_field: [u32; 2usize], } #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct rte_mbuf__bindgen_ty_3__bindgen_ty_1 { pub __bindgen_anon_1: rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1, pub hi: u32, } #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1 { pub __bindgen_anon_1: __BindgenUnionField, pub lo: __BindgenUnionField, pub bindgen_union_field: u32, } #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1 { pub hash: u16, pub id: u16, @@ -588,7 +589,7 @@ impl Clone for rte_mbuf__bindgen_ty_3__bindgen_ty_1 { fn clone(&self) -> Self { *self } } #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct rte_mbuf__bindgen_ty_3__bindgen_ty_2 { pub lo: u32, pub hi: u32, @@ -652,7 +653,7 @@ impl Clone for rte_mbuf__bindgen_ty_3 { fn clone(&self) -> Self { *self } } #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct rte_mbuf__bindgen_ty_4 { /// < Can be used for external metadata pub userdata: __BindgenUnionField<*mut ::std::os::raw::c_void>, @@ -683,7 +684,7 @@ impl Clone for rte_mbuf__bindgen_ty_4 { fn clone(&self) -> Self { *self } } #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct rte_mbuf__bindgen_ty_5 { /// < combined for easy fetch pub tx_offload: __BindgenUnionField, @@ -691,7 +692,7 @@ pub struct rte_mbuf__bindgen_ty_5 { pub bindgen_union_field: u64, } #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct rte_mbuf__bindgen_ty_5__bindgen_ty_1 { pub _bitfield_1: [u16; 4usize], pub __bindgen_align: [u64; 0usize], @@ -1088,7 +1089,7 @@ impl Default for rte_mbuf { } /// < Pool from which mbuf was allocated. #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct rte_mempool { pub _address: u8, } diff --git a/tests/headers/issue-648-derive-debug-with-padding.h b/tests/headers/issue-648-derive-debug-with-padding.h index e3433b0712..2ef70e47c8 100644 --- a/tests/headers/issue-648-derive-debug-with-padding.h +++ b/tests/headers/issue-648-derive-debug-with-padding.h @@ -1,4 +1,4 @@ -// bindgen-flags: --with-derive-hash --with-derive-partialeq +// bindgen-flags: --with-derive-hash --with-derive-partialeq --with-derive-eq /** * We emit a `[u8; 63usize]` padding field for this struct, which cannot derive * Debug/Hash because 63 is over the hard coded limit. (Yes, this struct doesn't end diff --git a/tests/headers/layout_array.h b/tests/headers/layout_array.h index 9db81f9153..6a20f7c3c5 100644 --- a/tests/headers/layout_array.h +++ b/tests/headers/layout_array.h @@ -1,4 +1,4 @@ -// bindgen-flags: --with-derive-hash --with-derive-partialeq +// bindgen-flags: --with-derive-hash --with-derive-partialeq --with-derive-eq typedef unsigned char uint8_t; typedef unsigned short uint16_t; typedef unsigned int uint32_t; diff --git a/tests/headers/layout_array_too_long.h b/tests/headers/layout_array_too_long.h index 9db20a3645..5240f0406e 100644 --- a/tests/headers/layout_array_too_long.h +++ b/tests/headers/layout_array_too_long.h @@ -1,4 +1,4 @@ -// bindgen-flags: --with-derive-hash --with-derive-partialeq +// bindgen-flags: --with-derive-hash --with-derive-partialeq --with-derive-eq typedef unsigned char uint8_t; typedef unsigned short uint16_t; typedef unsigned int uint32_t; diff --git a/tests/headers/layout_eth_conf.h b/tests/headers/layout_eth_conf.h index 3c09f9f55a..637b56961a 100644 --- a/tests/headers/layout_eth_conf.h +++ b/tests/headers/layout_eth_conf.h @@ -1,4 +1,4 @@ -// bindgen-flags: --with-derive-hash --with-derive-partialeq +// bindgen-flags: --with-derive-hash --with-derive-partialeq --with-derive-eq typedef unsigned char uint8_t; typedef unsigned short uint16_t; typedef unsigned int uint32_t; diff --git a/tests/headers/layout_eth_conf_1_0.h b/tests/headers/layout_eth_conf_1_0.h index 7fcbcddbf9..285c8c7a25 100644 --- a/tests/headers/layout_eth_conf_1_0.h +++ b/tests/headers/layout_eth_conf_1_0.h @@ -1,4 +1,4 @@ -// bindgen-flags: --rust-target 1.0 --with-derive-hash --with-derive-partialeq +// bindgen-flags: --rust-target 1.0 --with-derive-hash --with-derive-partialeq --with-derive-eq typedef unsigned char uint8_t; typedef unsigned short uint16_t; diff --git a/tests/headers/layout_mbuf.h b/tests/headers/layout_mbuf.h index 0e82846b22..0e342f45e0 100644 --- a/tests/headers/layout_mbuf.h +++ b/tests/headers/layout_mbuf.h @@ -1,4 +1,4 @@ -// bindgen-flags: --with-derive-hash --with-derive-partialeq +// bindgen-flags: --with-derive-hash --with-derive-partialeq --with-derive-eq #define RTE_CACHE_LINE_MIN_SIZE 64 /**< Minimum Cache line size. */ diff --git a/tests/headers/layout_mbuf_1_0.h b/tests/headers/layout_mbuf_1_0.h index ed815acb11..2854de5038 100644 --- a/tests/headers/layout_mbuf_1_0.h +++ b/tests/headers/layout_mbuf_1_0.h @@ -1,4 +1,4 @@ -// bindgen-flags: --rust-target 1.0 --with-derive-hash --with-derive-partialeq +// bindgen-flags: --rust-target 1.0 --with-derive-hash --with-derive-partialeq --with-derive-eq #define RTE_CACHE_LINE_MIN_SIZE 64 /**< Minimum Cache line size. */ From 3fc501f93fa9b5a19f97b7a7a2a3625616af7128 Mon Sep 17 00:00:00 2001 From: Zhiting Zhu Date: Wed, 16 Aug 2017 21:24:21 -0500 Subject: [PATCH 11/12] Misc tests for derive Eq --- tests/expectations/tests/16-byte-alignment.rs | 4 ++-- tests/expectations/tests/16-byte-alignment_1_0.rs | 13 +++++++------ tests/expectations/tests/char.rs | 2 +- tests/expectations/tests/issue-493.rs | 7 ++++--- tests/expectations/tests/issue-493_1_0.rs | 11 ++++++----- tests/expectations/tests/typeref.rs | 6 +++--- tests/expectations/tests/typeref_1_0.rs | 13 +++++++------ tests/expectations/tests/use-core.rs | 2 +- tests/expectations/tests/use-core_1_0.rs | 5 +++-- tests/headers/16-byte-alignment.h | 2 +- tests/headers/16-byte-alignment_1_0.h | 2 +- tests/headers/char.h | 2 +- tests/headers/issue-493.hpp | 2 +- tests/headers/issue-493_1_0.hpp | 2 +- tests/headers/issue-648-derive-debug-with-padding.h | 4 ++-- tests/headers/typeref.hpp | 2 +- tests/headers/typeref_1_0.hpp | 2 +- tests/headers/use-core.h | 2 +- tests/headers/use-core_1_0.h | 2 +- 19 files changed, 45 insertions(+), 40 deletions(-) diff --git a/tests/expectations/tests/16-byte-alignment.rs b/tests/expectations/tests/16-byte-alignment.rs index 45ec2ead3a..8610365697 100644 --- a/tests/expectations/tests/16-byte-alignment.rs +++ b/tests/expectations/tests/16-byte-alignment.rs @@ -19,7 +19,7 @@ pub union rte_ipv4_tuple__bindgen_ty_1 { _bindgen_union_align: u32, } #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct rte_ipv4_tuple__bindgen_ty_1__bindgen_ty_1 { pub dport: u16, pub sport: u16, @@ -112,7 +112,7 @@ pub union rte_ipv6_tuple__bindgen_ty_1 { _bindgen_union_align: u32, } #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct rte_ipv6_tuple__bindgen_ty_1__bindgen_ty_1 { pub dport: u16, pub sport: u16, diff --git a/tests/expectations/tests/16-byte-alignment_1_0.rs b/tests/expectations/tests/16-byte-alignment_1_0.rs index ee8a32611d..98cb1a49de 100644 --- a/tests/expectations/tests/16-byte-alignment_1_0.rs +++ b/tests/expectations/tests/16-byte-alignment_1_0.rs @@ -34,22 +34,23 @@ impl ::std::hash::Hash for __BindgenUnionField { impl ::std::cmp::PartialEq for __BindgenUnionField { fn eq(&self, _other: &__BindgenUnionField) -> bool { true } } +impl ::std::cmp::Eq for __BindgenUnionField { } #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] 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, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct rte_ipv4_tuple__bindgen_ty_1 { pub __bindgen_anon_1: __BindgenUnionField, pub sctp_tag: __BindgenUnionField, pub bindgen_union_field: u32, } #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct rte_ipv4_tuple__bindgen_ty_1__bindgen_ty_1 { pub dport: u16, pub sport: u16, @@ -122,21 +123,21 @@ impl Clone for rte_ipv4_tuple { fn clone(&self) -> Self { *self } } #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] 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, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct rte_ipv6_tuple__bindgen_ty_1 { pub __bindgen_anon_1: __BindgenUnionField, pub sctp_tag: __BindgenUnionField, pub bindgen_union_field: u32, } #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] 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 ac1700f591..1e45c74319 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, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] 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 d5486ccc61..7a9473660d 100644 --- a/tests/expectations/tests/issue-493.rs +++ b/tests/expectations/tests/issue-493.rs @@ -34,8 +34,9 @@ impl ::std::hash::Hash for __BindgenUnionField { impl ::std::cmp::PartialEq for __BindgenUnionField { fn eq(&self, _other: &__BindgenUnionField) -> bool { true } } +impl ::std::cmp::Eq for __BindgenUnionField { } #[repr(C)] -#[derive(Debug, Default, Copy, Clone, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct basic_string { pub _address: u8, } @@ -43,7 +44,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, Hash, PartialEq)] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct basic_string___long { pub __cap_: basic_string_size_type, pub __size_: basic_string_size_type, @@ -89,7 +90,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, Hash, PartialEq)] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct basic_string___raw { pub __words: *mut basic_string_size_type, } diff --git a/tests/expectations/tests/issue-493_1_0.rs b/tests/expectations/tests/issue-493_1_0.rs index 4ddc61883e..710cd41e26 100644 --- a/tests/expectations/tests/issue-493_1_0.rs +++ b/tests/expectations/tests/issue-493_1_0.rs @@ -34,8 +34,9 @@ impl ::std::hash::Hash for __BindgenUnionField { impl ::std::cmp::PartialEq for __BindgenUnionField { fn eq(&self, _other: &__BindgenUnionField) -> bool { true } } +impl ::std::cmp::Eq for __BindgenUnionField { } #[repr(C)] -#[derive(Debug, Default, Copy, Clone, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct basic_string { pub _address: u8, } @@ -43,7 +44,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, Hash, PartialEq)] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct basic_string___long { pub __cap_: basic_string_size_type, pub __size_: basic_string_size_type, @@ -58,13 +59,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, Hash, PartialEq)] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] 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, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct basic_string___short__bindgen_ty_1 { pub __size_: __BindgenUnionField<::std::os::raw::c_uchar>, pub __lx: __BindgenUnionField, @@ -89,7 +90,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, Hash, PartialEq)] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] 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 0a4edf4c7f..cefd02ba9d 100644 --- a/tests/expectations/tests/typeref.rs +++ b/tests/expectations/tests/typeref.rs @@ -24,7 +24,7 @@ impl Default for nsFoo { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct mozilla_FragmentOrURL { pub mIsLocalRef: bool, } @@ -46,7 +46,7 @@ impl Clone for mozilla_FragmentOrURL { fn clone(&self) -> Self { *self } } #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct mozilla_Position { pub _address: u8, } @@ -77,7 +77,7 @@ impl Default for mozilla_StyleShapeSource { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } #[repr(C)] -#[derive(Debug, Copy, Hash, PartialEq)] +#[derive(Debug, Copy, Hash, PartialEq, Eq)] pub struct Bar { pub mFoo: *mut nsFoo, } diff --git a/tests/expectations/tests/typeref_1_0.rs b/tests/expectations/tests/typeref_1_0.rs index d472f02b9b..0d24074362 100644 --- a/tests/expectations/tests/typeref_1_0.rs +++ b/tests/expectations/tests/typeref_1_0.rs @@ -34,8 +34,9 @@ impl ::std::hash::Hash for __BindgenUnionField { impl ::std::cmp::PartialEq for __BindgenUnionField { fn eq(&self, _other: &__BindgenUnionField) -> bool { true } } +impl ::std::cmp::Eq for __BindgenUnionField { } #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct nsFoo { pub mBar: mozilla_StyleShapeSource, } @@ -55,7 +56,7 @@ impl Clone for nsFoo { fn clone(&self) -> Self { *self } } #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct mozilla_FragmentOrURL { pub mIsLocalRef: bool, } @@ -77,7 +78,7 @@ impl Clone for mozilla_FragmentOrURL { fn clone(&self) -> Self { *self } } #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct mozilla_Position { pub _address: u8, } @@ -92,19 +93,19 @@ impl Clone for mozilla_Position { fn clone(&self) -> Self { *self } } #[repr(C)] -#[derive(Debug, Default, Copy, Clone, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct mozilla_StyleShapeSource { pub __bindgen_anon_1: mozilla_StyleShapeSource__bindgen_ty_1, } #[repr(C)] -#[derive(Debug, Default, Copy, Clone, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] 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, Hash, PartialEq)] +#[derive(Debug, Copy, Hash, PartialEq, Eq)] pub struct Bar { pub mFoo: *mut nsFoo, } diff --git a/tests/expectations/tests/use-core.rs b/tests/expectations/tests/use-core.rs index 508e3b5d6c..6fe4a0ca2a 100644 --- a/tests/expectations/tests/use-core.rs +++ b/tests/expectations/tests/use-core.rs @@ -6,7 +6,7 @@ extern crate core; #[repr(C)] -#[derive(Debug, Copy, Hash, PartialEq)] +#[derive(Debug, Copy, Hash, PartialEq, Eq)] pub struct foo { pub a: ::std::os::raw::c_int, pub b: ::std::os::raw::c_int, diff --git a/tests/expectations/tests/use-core_1_0.rs b/tests/expectations/tests/use-core_1_0.rs index b382454af6..1e5ef33708 100644 --- a/tests/expectations/tests/use-core_1_0.rs +++ b/tests/expectations/tests/use-core_1_0.rs @@ -35,8 +35,9 @@ impl ::core::hash::Hash for __BindgenUnionField { impl ::core::cmp::PartialEq for __BindgenUnionField { fn eq(&self, _other: &__BindgenUnionField) -> bool { true } } +impl ::core::cmp::Eq for __BindgenUnionField { } #[repr(C)] -#[derive(Debug, Copy, Hash, PartialEq)] +#[derive(Debug, Copy, Hash, PartialEq, Eq)] pub struct foo { pub a: ::std::os::raw::c_int, pub b: ::std::os::raw::c_int, @@ -71,7 +72,7 @@ impl Default for foo { fn default() -> Self { unsafe { ::core::mem::zeroed() } } } #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] +#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] 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 2fb3e2f31b..235a994abe 100644 --- a/tests/headers/16-byte-alignment.h +++ b/tests/headers/16-byte-alignment.h @@ -1,4 +1,4 @@ -// bindgen-flags: --with-derive-hash --with-derive-partialeq +// bindgen-flags: --with-derive-hash --with-derive-partialeq --with-derive-eq typedef unsigned char uint8_t; typedef unsigned short uint16_t; diff --git a/tests/headers/16-byte-alignment_1_0.h b/tests/headers/16-byte-alignment_1_0.h index 89574e9fa4..8a9fd4910e 100644 --- a/tests/headers/16-byte-alignment_1_0.h +++ b/tests/headers/16-byte-alignment_1_0.h @@ -1,4 +1,4 @@ -// bindgen-flags: --rust-target 1.0 --with-derive-hash --with-derive-partialeq +// bindgen-flags: --rust-target 1.0 --with-derive-hash --with-derive-partialeq --with-derive-eq typedef unsigned char uint8_t; typedef unsigned short uint16_t; diff --git a/tests/headers/char.h b/tests/headers/char.h index 71bce5534e..7cffd865c0 100644 --- a/tests/headers/char.h +++ b/tests/headers/char.h @@ -1,4 +1,4 @@ -// bindgen-flags: --with-derive-hash --with-derive-partialeq +// bindgen-flags: --with-derive-hash --with-derive-partialeq --with-derive-eq // typedef char Char; typedef signed char SChar; diff --git a/tests/headers/issue-493.hpp b/tests/headers/issue-493.hpp index 7c58a35173..5d4cb4b8ba 100644 --- a/tests/headers/issue-493.hpp +++ b/tests/headers/issue-493.hpp @@ -1,4 +1,4 @@ -// bindgen-flags: --with-derive-hash --with-derive-partialeq +// bindgen-flags: --with-derive-hash --with-derive-partialeq --with-derive-eq template class basic_string { diff --git a/tests/headers/issue-493_1_0.hpp b/tests/headers/issue-493_1_0.hpp index 2f43b16e2d..4e383be334 100644 --- a/tests/headers/issue-493_1_0.hpp +++ b/tests/headers/issue-493_1_0.hpp @@ -1,4 +1,4 @@ -// bindgen-flags: --rust-target 1.0 --with-derive-hash --with-derive-partialeq +// bindgen-flags: --rust-target 1.0 --with-derive-hash --with-derive-partialeq --with-derive-eq template class basic_string diff --git a/tests/headers/issue-648-derive-debug-with-padding.h b/tests/headers/issue-648-derive-debug-with-padding.h index 2ef70e47c8..c9ec021043 100644 --- a/tests/headers/issue-648-derive-debug-with-padding.h +++ b/tests/headers/issue-648-derive-debug-with-padding.h @@ -11,8 +11,8 @@ struct NoDebug { } __attribute__((__aligned__(64))); /** - * This should derive Debug/Hash/PartialEq because the padding size is less than the max derive - * Debug/Hash/PartialEq impl for arrays. However, we conservatively don't derive Debug/Hash because + * This should derive Debug/Hash/PartialEq/Eq because the padding size is less than the max derive + * Debug/Hash/PartialEq/Eq impl for arrays. However, we conservatively don't derive Debug/Hash because * we determine Debug derive-ability before we compute padding, which happens at * codegen. (Again, we expect to get the alignment wrong for similar reasons.) */ diff --git a/tests/headers/typeref.hpp b/tests/headers/typeref.hpp index d0710bfb6a..bdc1b30281 100644 --- a/tests/headers/typeref.hpp +++ b/tests/headers/typeref.hpp @@ -1,4 +1,4 @@ -// bindgen-flags: --with-derive-hash --with-derive-partialeq +// bindgen-flags: --with-derive-hash --with-derive-partialeq --with-derive-eq struct nsFoo; namespace mozilla { diff --git a/tests/headers/typeref_1_0.hpp b/tests/headers/typeref_1_0.hpp index 0dad19b2ed..70dfc11fb1 100644 --- a/tests/headers/typeref_1_0.hpp +++ b/tests/headers/typeref_1_0.hpp @@ -1,4 +1,4 @@ -// bindgen-flags: --rust-target 1.0 --with-derive-hash --with-derive-partialeq +// bindgen-flags: --rust-target 1.0 --with-derive-hash --with-derive-partialeq --with-derive-eq struct nsFoo; diff --git a/tests/headers/use-core.h b/tests/headers/use-core.h index b5fd0515ab..b4135b44a7 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;" --with-derive-hash --with-derive-partialeq +// bindgen-flags: --use-core --raw-line "extern crate core;" --with-derive-hash --with-derive-partialeq --with-derive-eq struct foo { int a, b; diff --git a/tests/headers/use-core_1_0.h b/tests/headers/use-core_1_0.h index f525bccf66..40de9d158d 100644 --- a/tests/headers/use-core_1_0.h +++ b/tests/headers/use-core_1_0.h @@ -1,4 +1,4 @@ -// bindgen-flags: --rust-target 1.0 --use-core --raw-line "extern crate core;" --with-derive-hash --with-derive-partialeq +// bindgen-flags: --rust-target 1.0 --use-core --raw-line "extern crate core;" --with-derive-hash --with-derive-partialeq --with-derive-eq struct foo { int a, b; From ff9d000435b84220d91347592282a76cbf4942e2 Mon Sep 17 00:00:00 2001 From: Zhiting Zhu Date: Wed, 16 Aug 2017 21:26:01 -0500 Subject: [PATCH 12/12] Small tests for derive Eq --- .../tests/derive-hash-blacklisting.rs | 8 ++++---- .../derive-hash-struct-with-anon-struct-float.rs | 6 +++--- .../tests/derive-hash-struct-with-float-array.rs | 4 ++-- .../tests/derive-hash-struct-with-pointer.rs | 10 +++++----- .../tests/derive-hash-template-def-float.rs | 4 ++-- .../tests/derive-hash-template-inst-float.rs | 12 ++++++------ tests/headers/derive-hash-blacklisting.hpp | 16 ++++++++-------- .../derive-hash-struct-with-anon-struct-float.h | 4 ++-- .../derive-hash-struct-with-float-array.h | 4 ++-- tests/headers/derive-hash-struct-with-pointer.h | 4 ++-- tests/headers/derive-hash-template-def-float.hpp | 6 +++--- .../headers/derive-hash-template-inst-float.hpp | 10 +++++----- 12 files changed, 44 insertions(+), 44 deletions(-) diff --git a/tests/expectations/tests/derive-hash-blacklisting.rs b/tests/expectations/tests/derive-hash-blacklisting.rs index c345d1aa4a..d24586be71 100644 --- a/tests/expectations/tests/derive-hash-blacklisting.rs +++ b/tests/expectations/tests/derive-hash-blacklisting.rs @@ -3,10 +3,10 @@ #![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] -#[repr(C)] #[derive(Debug, Hash, Copy, Clone)] pub struct Blacklisted {t: T, pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell> } +#[repr(C)] #[derive(Debug, Hash, Copy, Clone, PartialEq, Eq)] pub struct Blacklisted {t: T, pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell> } -/// This would derive(Hash) if it didn't contain a blacklisted type, -/// causing us to conservatively avoid deriving hash for it. +/// This would derive(Hash, Eq, PartialEq) if it didn't contain a blacklisted type, +/// causing us to conservatively avoid deriving hash/Eq/PartialEq for it. #[repr(C)] #[derive(Debug, Copy)] pub struct WhitelistedOne { @@ -30,7 +30,7 @@ impl Clone for WhitelistedOne { impl Default for WhitelistedOne { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } -/// This can't derive(Hash) even if it didn't contain a blacklisted type. +/// This can't derive(Hash/Eq) even if it didn't contain a blacklisted type. #[repr(C)] #[derive(Debug, Copy)] pub struct WhitelistedTwo { diff --git a/tests/expectations/tests/derive-hash-struct-with-anon-struct-float.rs b/tests/expectations/tests/derive-hash-struct-with-anon-struct-float.rs index 051a3636ff..3457afef48 100644 --- a/tests/expectations/tests/derive-hash-struct-with-anon-struct-float.rs +++ b/tests/expectations/tests/derive-hash-struct-with-anon-struct-float.rs @@ -4,14 +4,14 @@ #![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] -/// A struct containing a struct containing a float that cannot derive hash. +/// A struct containing a struct containing a float that cannot derive hash/eq but can derive partial eq. #[repr(C)] -#[derive(Debug, Default, Copy)] +#[derive(Debug, Default, Copy, PartialEq)] pub struct foo { pub bar: foo__bindgen_ty_1, } #[repr(C)] -#[derive(Debug, Default, Copy)] +#[derive(Debug, Default, Copy, PartialEq)] pub struct foo__bindgen_ty_1 { pub a: f32, pub b: f32, diff --git a/tests/expectations/tests/derive-hash-struct-with-float-array.rs b/tests/expectations/tests/derive-hash-struct-with-float-array.rs index bb4a6b5d17..9ee6785c35 100644 --- a/tests/expectations/tests/derive-hash-struct-with-float-array.rs +++ b/tests/expectations/tests/derive-hash-struct-with-float-array.rs @@ -4,9 +4,9 @@ #![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] -/// A struct containing an array of floats that cannot derive hash. +/// A struct containing an array of floats that cannot derive hash/eq but can derive partialeq. #[repr(C)] -#[derive(Debug, Default, Copy)] +#[derive(Debug, Default, Copy, PartialEq)] pub struct foo { pub bar: [f32; 3usize], } diff --git a/tests/expectations/tests/derive-hash-struct-with-pointer.rs b/tests/expectations/tests/derive-hash-struct-with-pointer.rs index a11d738ffb..c29f9b1e4f 100644 --- a/tests/expectations/tests/derive-hash-struct-with-pointer.rs +++ b/tests/expectations/tests/derive-hash-struct-with-pointer.rs @@ -4,9 +4,9 @@ #![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] -/// Pointers can derive hash/PartialEq +/// Pointers can derive hash/PartialEq/Eq #[repr(C)] -#[derive(Debug, Copy, Hash, PartialEq)] +#[derive(Debug, Copy, Hash, PartialEq, Eq)] pub struct ConstPtrMutObj { pub bar: *const ::std::os::raw::c_int, } @@ -29,7 +29,7 @@ impl Default for ConstPtrMutObj { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } #[repr(C)] -#[derive(Debug, Copy, Hash, PartialEq)] +#[derive(Debug, Copy, Hash, PartialEq, Eq)] pub struct MutPtrMutObj { pub bar: *mut ::std::os::raw::c_int, } @@ -52,7 +52,7 @@ impl Default for MutPtrMutObj { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } #[repr(C)] -#[derive(Debug, Copy, Hash, PartialEq)] +#[derive(Debug, Copy, Hash, PartialEq, Eq)] pub struct MutPtrConstObj { pub bar: *const ::std::os::raw::c_int, } @@ -75,7 +75,7 @@ impl Default for MutPtrConstObj { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } #[repr(C)] -#[derive(Debug, Copy, Hash, PartialEq)] +#[derive(Debug, Copy, Hash, PartialEq, Eq)] pub struct ConstPtrConstObj { pub bar: *const ::std::os::raw::c_int, } diff --git a/tests/expectations/tests/derive-hash-template-def-float.rs b/tests/expectations/tests/derive-hash-template-def-float.rs index e1d7836c11..23bf702d38 100644 --- a/tests/expectations/tests/derive-hash-template-def-float.rs +++ b/tests/expectations/tests/derive-hash-template-def-float.rs @@ -4,9 +4,9 @@ #![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] -/// Template definition containing a float, which cannot derive hash. +/// Template definition containing a float, which cannot derive hash/eq but can derive partialeq. #[repr(C)] -#[derive(Debug, Copy, Clone)] +#[derive(Debug, Copy, Clone, PartialEq)] pub struct foo { pub data: T, pub b: f32, diff --git a/tests/expectations/tests/derive-hash-template-inst-float.rs b/tests/expectations/tests/derive-hash-template-inst-float.rs index dd18053f2a..58848f8798 100644 --- a/tests/expectations/tests/derive-hash-template-inst-float.rs +++ b/tests/expectations/tests/derive-hash-template-inst-float.rs @@ -4,9 +4,9 @@ #![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] -/// Template definition that doesn't contain float can derive hash +/// Template definition that doesn't contain float can derive hash/partialeq/eq #[repr(C)] -#[derive(Debug, Copy, Clone, Hash)] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct foo { pub data: T, pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>, @@ -14,9 +14,9 @@ pub struct foo { impl Default for foo { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } -/// Can derive hash when instantiated with int +/// Can derive hash/partialeq/eq when instantiated with int #[repr(C)] -#[derive(Debug, Copy, Hash)] +#[derive(Debug, Copy, Hash, PartialEq, Eq)] pub struct IntStr { pub a: foo<::std::os::raw::c_int>, } @@ -38,9 +38,9 @@ impl Clone for IntStr { impl Default for IntStr { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } -/// Cannot derive hash when instantiated with float +/// Cannot derive hash/eq when instantiated with float but can derive partialeq #[repr(C)] -#[derive(Debug, Copy)] +#[derive(Debug, Copy, PartialEq)] pub struct FloatStr { pub a: foo, } diff --git a/tests/headers/derive-hash-blacklisting.hpp b/tests/headers/derive-hash-blacklisting.hpp index ee819c1753..c39c31adcd 100644 --- a/tests/headers/derive-hash-blacklisting.hpp +++ b/tests/headers/derive-hash-blacklisting.hpp @@ -1,17 +1,17 @@ -// bindgen-flags: --with-derive-hash --whitelist-type 'Whitelisted.*' --blacklist-type Blacklisted --raw-line "#[repr(C)] #[derive(Debug, Hash, Copy, Clone)] pub struct Blacklisted {t: T, pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell> }" +// bindgen-flags: --with-derive-hash --with-derive-partialeq --with-derive-eq --whitelist-type 'Whitelisted.*' --blacklist-type Blacklisted --raw-line "#[repr(C)] #[derive(Debug, Hash, Copy, Clone, PartialEq, Eq)] pub struct Blacklisted {t: T, pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell> }" // -template +template struct Blacklisted { - T t; + T t; }; -/// This would derive(Hash) if it didn't contain a blacklisted type, -/// causing us to conservatively avoid deriving hash for it. +/// This would derive(Hash, Eq, PartialEq) if it didn't contain a blacklisted type, +/// causing us to conservatively avoid deriving hash/Eq/PartialEq for it. struct WhitelistedOne { - Blacklisted a; + Blacklisted a; }; -/// This can't derive(Hash) even if it didn't contain a blacklisted type. +/// This can't derive(Hash/Eq) even if it didn't contain a blacklisted type. struct WhitelistedTwo { - Blacklisted b; + Blacklisted b; }; diff --git a/tests/headers/derive-hash-struct-with-anon-struct-float.h b/tests/headers/derive-hash-struct-with-anon-struct-float.h index 2b76cd2371..64fe7fd937 100644 --- a/tests/headers/derive-hash-struct-with-anon-struct-float.h +++ b/tests/headers/derive-hash-struct-with-anon-struct-float.h @@ -1,6 +1,6 @@ -// bindgen-flags: --with-derive-hash +// bindgen-flags: --with-derive-hash --with-derive-partialeq --with-derive-eq // -/// A struct containing a struct containing a float that cannot derive hash. +/// A struct containing a struct containing a float that cannot derive hash/eq but can derive partial eq. struct foo { struct { float a; diff --git a/tests/headers/derive-hash-struct-with-float-array.h b/tests/headers/derive-hash-struct-with-float-array.h index 53f0c79da5..a34904f704 100644 --- a/tests/headers/derive-hash-struct-with-float-array.h +++ b/tests/headers/derive-hash-struct-with-float-array.h @@ -1,6 +1,6 @@ -// bindgen-flags: --with-derive-hash +// bindgen-flags: --with-derive-hash --with-derive-partialeq --with-derive-eq // -/// A struct containing an array of floats that cannot derive hash. +/// A struct containing an array of floats that cannot derive hash/eq but can derive partialeq. struct foo { float bar[3]; }; diff --git a/tests/headers/derive-hash-struct-with-pointer.h b/tests/headers/derive-hash-struct-with-pointer.h index ed5199d4cc..d7f18a6d66 100644 --- a/tests/headers/derive-hash-struct-with-pointer.h +++ b/tests/headers/derive-hash-struct-with-pointer.h @@ -1,6 +1,6 @@ -// bindgen-flags: --with-derive-hash --with-derive-partialeq +// bindgen-flags: --with-derive-hash --with-derive-partialeq --with-derive-eq // -/// Pointers can derive hash/PartialEq +/// Pointers can derive hash/PartialEq/Eq struct ConstPtrMutObj { int* const bar; }; diff --git a/tests/headers/derive-hash-template-def-float.hpp b/tests/headers/derive-hash-template-def-float.hpp index 28885ed109..8c1a14d1b4 100644 --- a/tests/headers/derive-hash-template-def-float.hpp +++ b/tests/headers/derive-hash-template-def-float.hpp @@ -1,7 +1,7 @@ -// bindgen-flags: --with-derive-hash +// bindgen-flags: --with-derive-hash --with-derive-partialeq --with-derive-eq // -/// Template definition containing a float, which cannot derive hash. -template +/// Template definition containing a float, which cannot derive hash/eq but can derive partialeq. +template struct foo { T data; float b; diff --git a/tests/headers/derive-hash-template-inst-float.hpp b/tests/headers/derive-hash-template-inst-float.hpp index 59af69bd89..14fd89a046 100644 --- a/tests/headers/derive-hash-template-inst-float.hpp +++ b/tests/headers/derive-hash-template-inst-float.hpp @@ -1,17 +1,17 @@ -// bindgen-flags: --with-derive-hash +// bindgen-flags: --with-derive-hash --with-derive-partialeq --with-derive-eq // -/// Template definition that doesn't contain float can derive hash -template +/// Template definition that doesn't contain float can derive hash/partialeq/eq +template struct foo { T data; }; -/// Can derive hash when instantiated with int +/// Can derive hash/partialeq/eq when instantiated with int struct IntStr { foo a; }; -/// Cannot derive hash when instantiated with float +/// Cannot derive hash/eq when instantiated with float but can derive partialeq struct FloatStr { foo a; };