From 55e7d0514bf635667adfb938d2e17cd1de6531bb Mon Sep 17 00:00:00 2001 From: Cameron McCormack Date: Sat, 22 Oct 2016 19:39:37 +0800 Subject: [PATCH] Give vtables and anonymous items more stable generated names. --- Cargo.toml | 1 + src/codegen/mod.rs | 4 +- src/ir/item.rs | 82 +++++++++++++++---- src/lib.rs | 2 + tests/expectations/anon_enum.rs | 5 +- tests/expectations/anon_enum_whitelist.rs | 8 +- tests/expectations/anon_union.rs | 4 +- tests/expectations/class_with_inner_struct.rs | 67 +++++++-------- tests/expectations/const_enum_unnamed.rs | 13 ++- .../expectations/enum_and_vtable_mangling.rs | 11 ++- tests/expectations/jsval_layout_opaque.rs | 49 +++++------ tests/expectations/namespace.rs | 6 +- tests/expectations/nested_vtable.rs | 4 +- tests/expectations/ref_argument_array.rs | 4 +- tests/expectations/struct_with_anon_struct.rs | 14 ++-- .../struct_with_anon_struct_array.rs | 28 +++---- .../struct_with_anon_struct_pointer.rs | 14 ++-- tests/expectations/struct_with_anon_union.rs | 14 ++-- .../struct_with_anon_unnamed_struct.rs | 14 ++-- .../struct_with_anon_unnamed_union.rs | 14 ++-- tests/expectations/struct_with_nesting.rs | 42 ++++------ tests/expectations/struct_with_struct.rs | 14 ++-- tests/expectations/typeref.rs | 4 +- tests/expectations/union_fields.rs | 12 +-- tests/expectations/union_template.rs | 8 +- tests/expectations/union_with_anon_struct.rs | 14 ++-- .../union_with_anon_struct_bitfield.rs | 16 ++-- tests/expectations/union_with_anon_union.rs | 14 ++-- .../union_with_anon_unnamed_struct.rs | 14 ++-- .../union_with_anon_unnamed_union.rs | 14 ++-- tests/expectations/union_with_nesting.rs | 42 ++++------ tests/expectations/unknown_attr.rs | 6 +- tests/expectations/virtual_dtor.rs | 4 +- tests/expectations/virtual_overloaded.rs | 4 +- tests/expectations/vtable_recursive_sig.rs | 4 +- 35 files changed, 282 insertions(+), 288 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index cd32574bbf..dbbaf4a7d2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,6 +23,7 @@ quasi_codegen = "0.20" [dependencies] clang-sys = "0.8.0" +lazy_static = "0.1.*" libc = "0.2" log = "0.3" env_logger = "0.3" diff --git a/src/codegen/mod.rs b/src/codegen/mod.rs index 55312c3178..a88b3b605a 100644 --- a/src/codegen/mod.rs +++ b/src/codegen/mod.rs @@ -445,8 +445,8 @@ impl<'a> CodeGenerator for Vtable<'a> { } impl<'a> ItemCanonicalName for Vtable<'a> { - fn canonical_name(&self, _ctx: &BindgenContext) -> String { - format!("bindgen_vtable_{}", self.item_id) + fn canonical_name(&self, ctx: &BindgenContext) -> String { + format!("{}__bindgen_vtable", self.item_id.canonical_name(ctx)) } } diff --git a/src/ir/item.rs b/src/ir/item.rs index 18f912c132..6cb6d7c6b1 100644 --- a/src/ir/item.rs +++ b/src/ir/item.rs @@ -1,10 +1,11 @@ +use regex::Regex; use super::context::BindgenContext; use super::item_kind::ItemKind; use super::ty::{Type, TypeKind}; use super::function::Function; use super::module::Module; use super::annotations::Annotations; -use std::fmt; +use std::cell::Cell; use std::sync::atomic::{AtomicUsize, ATOMIC_USIZE_INIT, Ordering}; use parse::{ClangItemParser, ClangSubItemParser, ParseError, ParseResult}; use clang; @@ -46,13 +47,6 @@ pub trait ItemCanonicalPath { #[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct ItemId(usize); -impl fmt::Display for ItemId { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - try!(write!(fmt, "_bindgen_id_")); - self.0.fmt(fmt) - } -} - pub static NEXT_ITEM_ID: AtomicUsize = ATOMIC_USIZE_INIT; impl ItemId { @@ -96,6 +90,11 @@ impl ItemCanonicalPath for ItemId { pub struct Item { /// This item's id. id: ItemId, + /// The item's local id, unique only amongst its siblings. Only used + /// for anonymous items. Lazily initialized in local_id(). + local_id: Cell>, + /// The next local id to use for a child. + next_child_local_id: Cell, /// A doc comment over the item, if any. comment: Option, /// Annotations extracted from the doc comment, or the default ones @@ -120,6 +119,8 @@ impl Item { debug_assert!(id != parent_id || kind.is_module()); Item { id: id, + local_id: Cell::new(None), + next_child_local_id: Cell::new(1), parent_id: parent_id, comment: comment, annotations: annotations.unwrap_or_default(), @@ -147,6 +148,16 @@ impl Item { &mut self.kind } + pub fn local_id(&self, ctx: &BindgenContext) -> usize { + if self.local_id.get().is_none() { + let parent = ctx.resolve_item(self.parent_id); + let local_id = parent.next_child_local_id.get(); + parent.next_child_local_id.set(local_id + 1); + self.local_id.set(Some(local_id)); + } + self.local_id.get().unwrap() + } + /// Returns whether this item is a top-level item, from the point of view of /// bindgen. /// @@ -435,7 +446,6 @@ impl Item { ty.name() } }.map(ToOwned::to_owned) - .unwrap_or_else(|| format!("_bindgen_ty{}", self.id())) } ItemKind::Function(ref fun) => { let mut base = fun.name().to_owned(); @@ -464,30 +474,68 @@ impl Item { } } } - base + Some(base) } ItemKind::Var(ref var) => { - var.name().to_owned() + Some(var.name().to_owned()) } ItemKind::Module(ref module) => { module.name().map(ToOwned::to_owned) - .unwrap_or_else(|| format!("_bindgen_mod{}", self.id())) } }; let parent = ctx.resolve_item(self.parent_id()); let parent_is_namespace = parent.is_module(); + if self.is_toplevel(ctx) || (parent_is_namespace && count_namespaces) { + let base_name = self.make_exposed_name(None, base_name, ctx); return ctx.rust_mangle(&base_name).into_owned(); } // TODO: allow modification of the mangling functions, maybe even per // item type? - let parent = parent.canonical_name(ctx); - if parent.is_empty() { - base_name.to_owned() - } else { - format!("{}_{}", parent, base_name) + let parent_name = parent.canonical_name(ctx); + self.make_exposed_name(Some(parent_name), base_name, ctx) + } + + fn exposed_id(&self, ctx: &BindgenContext) -> String { + // Only use local ids for enums, classes, structs and union types. All + // other items use their global id. + let ty_kind = self.kind().as_type().map(|t| t.kind()); + if let Some(ty_kind) = ty_kind { + match *ty_kind { + TypeKind::Comp(..) | + TypeKind::Enum(..) => return self.local_id(ctx).to_string(), + _ => {} + } + } + format!("id_{}", self.id().0) + } + + fn make_exposed_name(&self, + parent_name: Option, + base_name: Option, + ctx: &BindgenContext) -> String { + lazy_static! { + static ref RE_ENDS_WITH_BINDGEN_TY: Regex = Regex::new(r"_bindgen_ty(_\d+)+$").unwrap(); + static ref RE_ENDS_WITH_BINDGEN_MOD: Regex = Regex::new(r"_bindgen_mod(_\d+)+$").unwrap(); + } + let (re, kind) = match *self.kind() { + ItemKind::Module(..) => (&*RE_ENDS_WITH_BINDGEN_MOD, "mod"), + _ => (&*RE_ENDS_WITH_BINDGEN_TY, "ty"), + }; + let parent_name = parent_name.and_then(|n| if n.is_empty() { None } else { Some(n) }); + match (parent_name, base_name) { + (Some(parent), Some(base)) => format!("{}_{}", parent, base), + (Some(parent), None) => { + if re.is_match(parent.as_str()) { + format!("{}_{}", parent, self.exposed_id(ctx)) + } else { + format!("{}__bindgen_{}_{}", parent, kind, self.exposed_id(ctx)) + } + } + (None, Some(base)) => base, + (None, None) => format!("_bindgen_{}_{}", kind, self.exposed_id(ctx)), } } diff --git a/src/lib.rs b/src/lib.rs index 44cadb4d73..a578784026 100755 --- a/src/lib.rs +++ b/src/lib.rs @@ -16,6 +16,8 @@ extern crate libc; extern crate regex; #[macro_use] extern crate log; +#[macro_use] +extern crate lazy_static; mod clangll; mod clang; diff --git a/tests/expectations/anon_enum.rs b/tests/expectations/anon_enum.rs index 17212c12b6..075830e6dc 100644 --- a/tests/expectations/anon_enum.rs +++ b/tests/expectations/anon_enum.rs @@ -10,11 +10,10 @@ pub struct Test { pub foo: ::std::os::raw::c_int, pub bar: f32, } -pub const Test_T_NONE: Test__bindgen_ty_bindgen_id_6 = - Test__bindgen_ty_bindgen_id_6::T_NONE; +pub const Test_T_NONE: Test__bindgen_ty_1 = Test__bindgen_ty_1::T_NONE; #[repr(u32)] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] -pub enum Test__bindgen_ty_bindgen_id_6 { T_NONE = 0, } +pub enum Test__bindgen_ty_1 { T_NONE = 0, } #[test] fn bindgen_test_layout_Test() { assert_eq!(::std::mem::size_of::() , 8usize); diff --git a/tests/expectations/anon_enum_whitelist.rs b/tests/expectations/anon_enum_whitelist.rs index 62c1f1a5e1..b32396a035 100644 --- a/tests/expectations/anon_enum_whitelist.rs +++ b/tests/expectations/anon_enum_whitelist.rs @@ -4,10 +4,8 @@ #![allow(non_snake_case)] -pub const NODE_FLAG_FOO: _bindgen_ty_bindgen_id_1 = - _bindgen_ty_bindgen_id_1::NODE_FLAG_FOO; -pub const NODE_FLAG_BAR: _bindgen_ty_bindgen_id_1 = - _bindgen_ty_bindgen_id_1::NODE_FLAG_BAR; +pub const NODE_FLAG_FOO: _bindgen_ty_1 = _bindgen_ty_1::NODE_FLAG_FOO; +pub const NODE_FLAG_BAR: _bindgen_ty_1 = _bindgen_ty_1::NODE_FLAG_BAR; #[repr(u32)] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] -pub enum _bindgen_ty_bindgen_id_1 { NODE_FLAG_FOO = 0, NODE_FLAG_BAR = 1, } +pub enum _bindgen_ty_1 { NODE_FLAG_FOO = 0, NODE_FLAG_BAR = 1, } diff --git a/tests/expectations/anon_union.rs b/tests/expectations/anon_union.rs index 731d1dd990..0b1da364a2 100644 --- a/tests/expectations/anon_union.rs +++ b/tests/expectations/anon_union.rs @@ -28,7 +28,7 @@ impl ::std::marker::Copy for __BindgenUnionField { } #[derive(Debug, Copy, Clone)] pub struct TErrorResult { pub mResult: ::std::os::raw::c_int, - pub __bindgen_anon_1: TErrorResult__bindgen_ty_bindgen_id_10, + pub __bindgen_anon_1: TErrorResult__bindgen_ty_1, pub mMightHaveUnreported: bool, pub mUnionState: TErrorResult_UnionState, pub _phantom_0: ::std::marker::PhantomData, @@ -52,7 +52,7 @@ pub struct TErrorResult_DOMExceptionInfo { } #[repr(C)] #[derive(Debug, Copy, Clone)] -pub struct TErrorResult__bindgen_ty_bindgen_id_10 { +pub struct TErrorResult__bindgen_ty_1 { pub mMessage: __BindgenUnionField<*mut TErrorResult_Message>, pub mDOMExceptionInfo: __BindgenUnionField<*mut TErrorResult_DOMExceptionInfo>, pub bindgen_union_field: u64, diff --git a/tests/expectations/class_with_inner_struct.rs b/tests/expectations/class_with_inner_struct.rs index 98c0505ab7..ca8eb73b09 100644 --- a/tests/expectations/class_with_inner_struct.rs +++ b/tests/expectations/class_with_inner_struct.rs @@ -28,8 +28,8 @@ impl ::std::marker::Copy for __BindgenUnionField { } #[derive(Debug, Copy)] pub struct A { pub c: ::std::os::raw::c_uint, - pub named_union: A__bindgen_ty_bindgen_id_9, - pub __bindgen_anon_1: A__bindgen_ty_bindgen_id_14, + pub named_union: A__bindgen_ty_1, + pub __bindgen_anon_1: A__bindgen_ty_2, } #[repr(C)] #[derive(Debug, Copy)] @@ -47,31 +47,30 @@ impl Clone for A_Segment { } #[repr(C)] #[derive(Debug, Copy)] -pub struct A__bindgen_ty_bindgen_id_9 { +pub struct A__bindgen_ty_1 { pub f: __BindgenUnionField<::std::os::raw::c_int>, pub bindgen_union_field: u32, } #[test] -fn bindgen_test_layout_A__bindgen_ty_bindgen_id_9() { - assert_eq!(::std::mem::size_of::() , 4usize); - assert_eq!(::std::mem::align_of::() , 4usize); +fn bindgen_test_layout_A__bindgen_ty_1() { + assert_eq!(::std::mem::size_of::() , 4usize); + assert_eq!(::std::mem::align_of::() , 4usize); } -impl Clone for A__bindgen_ty_bindgen_id_9 { +impl Clone for A__bindgen_ty_1 { fn clone(&self) -> Self { *self } } #[repr(C)] #[derive(Debug, Copy)] -pub struct A__bindgen_ty_bindgen_id_14 { +pub struct A__bindgen_ty_2 { pub d: __BindgenUnionField<::std::os::raw::c_int>, pub bindgen_union_field: u32, } #[test] -fn bindgen_test_layout_A__bindgen_ty_bindgen_id_14() { - assert_eq!(::std::mem::size_of::() , 4usize); - assert_eq!(::std::mem::align_of::() , - 4usize); +fn bindgen_test_layout_A__bindgen_ty_2() { + assert_eq!(::std::mem::size_of::() , 4usize); + assert_eq!(::std::mem::align_of::() , 4usize); } -impl Clone for A__bindgen_ty_bindgen_id_14 { +impl Clone for A__bindgen_ty_2 { fn clone(&self) -> Self { *self } } #[test] @@ -121,57 +120,51 @@ pub enum StepSyntax { #[derive(Debug, Copy)] pub struct C { pub d: ::std::os::raw::c_uint, - pub __bindgen_anon_1: C__bindgen_ty_bindgen_id_31, + pub __bindgen_anon_1: C__bindgen_ty_1, } #[repr(C)] #[derive(Debug, Copy)] -pub struct C__bindgen_ty_bindgen_id_31 { - pub mFunc: __BindgenUnionField, - pub __bindgen_anon_1: __BindgenUnionField, +pub struct C__bindgen_ty_1 { + pub mFunc: __BindgenUnionField, + pub __bindgen_anon_1: __BindgenUnionField, pub bindgen_union_field: [u32; 4usize], } #[repr(C)] #[derive(Debug, Copy)] -pub struct C__bindgen_ty_bindgen_id_31__bindgen_ty_bindgen_id_32 { +pub struct C__bindgen_ty_1_1 { pub mX1: f32, pub mY1: f32, pub mX2: f32, pub mY2: f32, } #[test] -fn bindgen_test_layout_C__bindgen_ty_bindgen_id_31__bindgen_ty_bindgen_id_32() { - assert_eq!(::std::mem::size_of::() - , 16usize); - assert_eq!(::std::mem::align_of::() - , 4usize); +fn bindgen_test_layout_C__bindgen_ty_1_1() { + assert_eq!(::std::mem::size_of::() , 16usize); + assert_eq!(::std::mem::align_of::() , 4usize); } -impl Clone for C__bindgen_ty_bindgen_id_31__bindgen_ty_bindgen_id_32 { +impl Clone for C__bindgen_ty_1_1 { fn clone(&self) -> Self { *self } } #[repr(C)] #[derive(Debug, Copy)] -pub struct C__bindgen_ty_bindgen_id_31__bindgen_ty_bindgen_id_43 { +pub struct C__bindgen_ty_1_2 { pub mStepSyntax: StepSyntax, pub mSteps: ::std::os::raw::c_uint, } #[test] -fn bindgen_test_layout_C__bindgen_ty_bindgen_id_31__bindgen_ty_bindgen_id_43() { - assert_eq!(::std::mem::size_of::() - , 8usize); - assert_eq!(::std::mem::align_of::() - , 4usize); +fn bindgen_test_layout_C__bindgen_ty_1_2() { + assert_eq!(::std::mem::size_of::() , 8usize); + assert_eq!(::std::mem::align_of::() , 4usize); } -impl Clone for C__bindgen_ty_bindgen_id_31__bindgen_ty_bindgen_id_43 { +impl Clone for C__bindgen_ty_1_2 { fn clone(&self) -> Self { *self } } #[test] -fn bindgen_test_layout_C__bindgen_ty_bindgen_id_31() { - assert_eq!(::std::mem::size_of::() , - 16usize); - assert_eq!(::std::mem::align_of::() , - 4usize); +fn bindgen_test_layout_C__bindgen_ty_1() { + assert_eq!(::std::mem::size_of::() , 16usize); + assert_eq!(::std::mem::align_of::() , 4usize); } -impl Clone for C__bindgen_ty_bindgen_id_31 { +impl Clone for C__bindgen_ty_1 { fn clone(&self) -> Self { *self } } #[repr(C)] diff --git a/tests/expectations/const_enum_unnamed.rs b/tests/expectations/const_enum_unnamed.rs index e16dc405ee..0bd3987a3b 100644 --- a/tests/expectations/const_enum_unnamed.rs +++ b/tests/expectations/const_enum_unnamed.rs @@ -4,23 +4,20 @@ #![allow(non_snake_case)] -pub const FOO_BAR: _bindgen_ty_bindgen_id_1 = - _bindgen_ty_bindgen_id_1::FOO_BAR; -pub const FOO_BAZ: _bindgen_ty_bindgen_id_1 = - _bindgen_ty_bindgen_id_1::FOO_BAZ; +pub const FOO_BAR: _bindgen_ty_1 = _bindgen_ty_1::FOO_BAR; +pub const FOO_BAZ: _bindgen_ty_1 = _bindgen_ty_1::FOO_BAZ; #[repr(u32)] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] -pub enum _bindgen_ty_bindgen_id_1 { FOO_BAR = 0, FOO_BAZ = 1, } +pub enum _bindgen_ty_1 { FOO_BAR = 0, FOO_BAZ = 1, } #[repr(C)] #[derive(Debug, Copy)] pub struct Foo { pub _address: u8, } -pub const Foo_FOO_BAR: Foo__bindgen_ty_bindgen_id_5 = - Foo__bindgen_ty_bindgen_id_5::FOO_BAR; +pub const Foo_FOO_BAR: Foo__bindgen_ty_1 = Foo__bindgen_ty_1::FOO_BAR; #[repr(u32)] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] -pub enum Foo__bindgen_ty_bindgen_id_5 { FOO_BAR = 10, } +pub enum Foo__bindgen_ty_1 { FOO_BAR = 10, } #[test] fn bindgen_test_layout_Foo() { assert_eq!(::std::mem::size_of::() , 1usize); diff --git a/tests/expectations/enum_and_vtable_mangling.rs b/tests/expectations/enum_and_vtable_mangling.rs index 3c7d5370d4..a55c344e50 100644 --- a/tests/expectations/enum_and_vtable_mangling.rs +++ b/tests/expectations/enum_and_vtable_mangling.rs @@ -4,19 +4,18 @@ #![allow(non_snake_case)] -pub const match_: _bindgen_ty_bindgen_id_1 = _bindgen_ty_bindgen_id_1::match_; -pub const whatever_else: _bindgen_ty_bindgen_id_1 = - _bindgen_ty_bindgen_id_1::whatever_else; +pub const match_: _bindgen_ty_1 = _bindgen_ty_1::match_; +pub const whatever_else: _bindgen_ty_1 = _bindgen_ty_1::whatever_else; #[repr(u32)] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] -pub enum _bindgen_ty_bindgen_id_1 { match_ = 0, whatever_else = 1, } +pub enum _bindgen_ty_1 { match_ = 0, whatever_else = 1, } #[repr(C)] -pub struct bindgen_vtable__bindgen_id_4 { +pub struct C__bindgen_vtable { } #[repr(C)] #[derive(Debug, Copy)] pub struct C { - pub vtable_: *const bindgen_vtable__bindgen_id_4, + pub vtable_: *const C__bindgen_vtable, pub i: ::std::os::raw::c_int, } #[test] diff --git a/tests/expectations/jsval_layout_opaque.rs b/tests/expectations/jsval_layout_opaque.rs index dc0ecad5de..f3c1014e45 100644 --- a/tests/expectations/jsval_layout_opaque.rs +++ b/tests/expectations/jsval_layout_opaque.rs @@ -94,8 +94,8 @@ pub enum JSWhyMagic { #[derive(Debug, Copy)] pub struct jsval_layout { pub asBits: __BindgenUnionField, - pub debugView: __BindgenUnionField, - pub s: __BindgenUnionField, + pub debugView: __BindgenUnionField, + pub s: __BindgenUnionField, pub asDouble: __BindgenUnionField, pub asPtr: __BindgenUnionField<*mut ::std::os::raw::c_void>, pub asWord: __BindgenUnionField, @@ -104,20 +104,18 @@ pub struct jsval_layout { } #[repr(C)] #[derive(Debug, Copy)] -pub struct jsval_layout__bindgen_ty_bindgen_id_90 { +pub struct jsval_layout__bindgen_ty_1 { pub _bitfield_1: u64, } #[test] -fn bindgen_test_layout_jsval_layout__bindgen_ty_bindgen_id_90() { - assert_eq!(::std::mem::size_of::() - , 8usize); - assert_eq!(::std::mem::align_of::() - , 8usize); +fn bindgen_test_layout_jsval_layout__bindgen_ty_1() { + assert_eq!(::std::mem::size_of::() , 8usize); + assert_eq!(::std::mem::align_of::() , 8usize); } -impl Clone for jsval_layout__bindgen_ty_bindgen_id_90 { +impl Clone for jsval_layout__bindgen_ty_1 { fn clone(&self) -> Self { *self } } -impl jsval_layout__bindgen_ty_bindgen_id_90 { +impl jsval_layout__bindgen_ty_1 { #[inline] pub fn payload47(&self) -> u64 { unsafe { @@ -150,36 +148,33 @@ impl jsval_layout__bindgen_ty_bindgen_id_90 { } #[repr(C)] #[derive(Debug, Copy)] -pub struct jsval_layout__bindgen_ty_bindgen_id_97 { - pub payload: jsval_layout__bindgen_ty_bindgen_id_97__bindgen_ty_bindgen_id_98, +pub struct jsval_layout__bindgen_ty_2 { + pub payload: jsval_layout__bindgen_ty_2_1, } #[repr(C)] #[derive(Debug, Copy)] -pub struct jsval_layout__bindgen_ty_bindgen_id_97__bindgen_ty_bindgen_id_98 { +pub struct jsval_layout__bindgen_ty_2_1 { pub i32: __BindgenUnionField, pub u32: __BindgenUnionField, pub why: __BindgenUnionField, pub bindgen_union_field: u32, } #[test] -fn bindgen_test_layout_jsval_layout__bindgen_ty_bindgen_id_97__bindgen_ty_bindgen_id_98() { - assert_eq!(::std::mem::size_of::() - , 4usize); - assert_eq!(::std::mem::align_of::() - , 4usize); -} -impl Clone for - jsval_layout__bindgen_ty_bindgen_id_97__bindgen_ty_bindgen_id_98 { +fn bindgen_test_layout_jsval_layout__bindgen_ty_2_1() { + assert_eq!(::std::mem::size_of::() , + 4usize); + assert_eq!(::std::mem::align_of::() , + 4usize); +} +impl Clone for jsval_layout__bindgen_ty_2_1 { fn clone(&self) -> Self { *self } } #[test] -fn bindgen_test_layout_jsval_layout__bindgen_ty_bindgen_id_97() { - assert_eq!(::std::mem::size_of::() - , 4usize); - assert_eq!(::std::mem::align_of::() - , 4usize); +fn bindgen_test_layout_jsval_layout__bindgen_ty_2() { + assert_eq!(::std::mem::size_of::() , 4usize); + assert_eq!(::std::mem::align_of::() , 4usize); } -impl Clone for jsval_layout__bindgen_ty_bindgen_id_97 { +impl Clone for jsval_layout__bindgen_ty_2 { fn clone(&self) -> Self { *self } } impl Clone for jsval_layout { diff --git a/tests/expectations/namespace.rs b/tests/expectations/namespace.rs index ed0ca603e2..bc8bae681b 100644 --- a/tests/expectations/namespace.rs +++ b/tests/expectations/namespace.rs @@ -18,7 +18,7 @@ pub mod root { pub fn in_whatever(); } } - pub mod _bindgen_mod_bindgen_id_13 { + pub mod _bindgen_mod_id_13 { use root; pub mod empty { use root; @@ -44,7 +44,7 @@ pub mod root { #[repr(C)] #[derive(Debug)] pub struct C { - pub _base: root::_bindgen_mod_bindgen_id_13::A, + pub _base: root::_bindgen_mod_id_13::A, pub m_c: T, pub m_c_ptr: *mut T, pub m_c_arr: [T; 10usize], @@ -78,7 +78,7 @@ extern "C" { #[repr(C)] #[derive(Debug)] pub struct C { - pub _base: root::_bindgen_mod_bindgen_id_13::A, + pub _base: root::_bindgen_mod_id_13::A, pub m_c: T, pub m_c_ptr: *mut T, pub m_c_arr: [T; 10usize], diff --git a/tests/expectations/nested_vtable.rs b/tests/expectations/nested_vtable.rs index 0c4f7dbe7c..d74ad55f36 100644 --- a/tests/expectations/nested_vtable.rs +++ b/tests/expectations/nested_vtable.rs @@ -5,12 +5,12 @@ #[repr(C)] -pub struct bindgen_vtable__bindgen_id_1 { +pub struct nsISupports__bindgen_vtable { } #[repr(C)] #[derive(Debug, Copy)] pub struct nsISupports { - pub vtable_: *const bindgen_vtable__bindgen_id_1, + pub vtable_: *const nsISupports__bindgen_vtable, } #[test] fn bindgen_test_layout_nsISupports() { diff --git a/tests/expectations/ref_argument_array.rs b/tests/expectations/ref_argument_array.rs index 5cfac9d81e..c88492d778 100644 --- a/tests/expectations/ref_argument_array.rs +++ b/tests/expectations/ref_argument_array.rs @@ -6,12 +6,12 @@ pub const NSID_LENGTH: ::std::os::raw::c_uint = 10; #[repr(C)] -pub struct bindgen_vtable__bindgen_id_4 { +pub struct nsID__bindgen_vtable { } #[repr(C)] #[derive(Debug, Copy)] pub struct nsID { - pub vtable_: *const bindgen_vtable__bindgen_id_4, + pub vtable_: *const nsID__bindgen_vtable, } #[test] fn bindgen_test_layout_nsID() { diff --git a/tests/expectations/struct_with_anon_struct.rs b/tests/expectations/struct_with_anon_struct.rs index e28c4fc097..1c49675d53 100644 --- a/tests/expectations/struct_with_anon_struct.rs +++ b/tests/expectations/struct_with_anon_struct.rs @@ -7,22 +7,20 @@ #[repr(C)] #[derive(Debug, Copy)] pub struct foo { - pub bar: foo__bindgen_ty_bindgen_id_2, + pub bar: foo__bindgen_ty_1, } #[repr(C)] #[derive(Debug, Copy)] -pub struct foo__bindgen_ty_bindgen_id_2 { +pub struct foo__bindgen_ty_1 { pub a: ::std::os::raw::c_int, pub b: ::std::os::raw::c_int, } #[test] -fn bindgen_test_layout_foo__bindgen_ty_bindgen_id_2() { - assert_eq!(::std::mem::size_of::() , - 8usize); - assert_eq!(::std::mem::align_of::() , - 4usize); +fn bindgen_test_layout_foo__bindgen_ty_1() { + assert_eq!(::std::mem::size_of::() , 8usize); + assert_eq!(::std::mem::align_of::() , 4usize); } -impl Clone for foo__bindgen_ty_bindgen_id_2 { +impl Clone for foo__bindgen_ty_1 { fn clone(&self) -> Self { *self } } #[test] diff --git a/tests/expectations/struct_with_anon_struct_array.rs b/tests/expectations/struct_with_anon_struct_array.rs index c87605de11..6e1c03158f 100644 --- a/tests/expectations/struct_with_anon_struct_array.rs +++ b/tests/expectations/struct_with_anon_struct_array.rs @@ -7,39 +7,35 @@ #[repr(C)] #[derive(Debug, Copy)] pub struct foo { - pub bar: [foo__bindgen_ty_bindgen_id_2; 2usize], - pub baz: [[[foo__bindgen_ty_bindgen_id_8; 4usize]; 3usize]; 2usize], + pub bar: [foo__bindgen_ty_1; 2usize], + pub baz: [[[foo__bindgen_ty_2; 4usize]; 3usize]; 2usize], } #[repr(C)] #[derive(Debug, Copy)] -pub struct foo__bindgen_ty_bindgen_id_2 { +pub struct foo__bindgen_ty_1 { pub a: ::std::os::raw::c_int, pub b: ::std::os::raw::c_int, } #[test] -fn bindgen_test_layout_foo__bindgen_ty_bindgen_id_2() { - assert_eq!(::std::mem::size_of::() , - 8usize); - assert_eq!(::std::mem::align_of::() , - 4usize); +fn bindgen_test_layout_foo__bindgen_ty_1() { + assert_eq!(::std::mem::size_of::() , 8usize); + assert_eq!(::std::mem::align_of::() , 4usize); } -impl Clone for foo__bindgen_ty_bindgen_id_2 { +impl Clone for foo__bindgen_ty_1 { fn clone(&self) -> Self { *self } } #[repr(C)] #[derive(Debug, Copy)] -pub struct foo__bindgen_ty_bindgen_id_8 { +pub struct foo__bindgen_ty_2 { pub a: ::std::os::raw::c_int, pub b: ::std::os::raw::c_int, } #[test] -fn bindgen_test_layout_foo__bindgen_ty_bindgen_id_8() { - assert_eq!(::std::mem::size_of::() , - 8usize); - assert_eq!(::std::mem::align_of::() , - 4usize); +fn bindgen_test_layout_foo__bindgen_ty_2() { + assert_eq!(::std::mem::size_of::() , 8usize); + assert_eq!(::std::mem::align_of::() , 4usize); } -impl Clone for foo__bindgen_ty_bindgen_id_8 { +impl Clone for foo__bindgen_ty_2 { fn clone(&self) -> Self { *self } } #[test] diff --git a/tests/expectations/struct_with_anon_struct_pointer.rs b/tests/expectations/struct_with_anon_struct_pointer.rs index a4b693a730..aa77d4b693 100644 --- a/tests/expectations/struct_with_anon_struct_pointer.rs +++ b/tests/expectations/struct_with_anon_struct_pointer.rs @@ -7,22 +7,20 @@ #[repr(C)] #[derive(Debug, Copy)] pub struct foo { - pub bar: *mut foo__bindgen_ty_bindgen_id_2, + pub bar: *mut foo__bindgen_ty_1, } #[repr(C)] #[derive(Debug, Copy)] -pub struct foo__bindgen_ty_bindgen_id_2 { +pub struct foo__bindgen_ty_1 { pub a: ::std::os::raw::c_int, pub b: ::std::os::raw::c_int, } #[test] -fn bindgen_test_layout_foo__bindgen_ty_bindgen_id_2() { - assert_eq!(::std::mem::size_of::() , - 8usize); - assert_eq!(::std::mem::align_of::() , - 4usize); +fn bindgen_test_layout_foo__bindgen_ty_1() { + assert_eq!(::std::mem::size_of::() , 8usize); + assert_eq!(::std::mem::align_of::() , 4usize); } -impl Clone for foo__bindgen_ty_bindgen_id_2 { +impl Clone for foo__bindgen_ty_1 { fn clone(&self) -> Self { *self } } #[test] diff --git a/tests/expectations/struct_with_anon_union.rs b/tests/expectations/struct_with_anon_union.rs index 889bccf7af..7c4a7d82d4 100644 --- a/tests/expectations/struct_with_anon_union.rs +++ b/tests/expectations/struct_with_anon_union.rs @@ -27,23 +27,21 @@ impl ::std::marker::Copy for __BindgenUnionField { } #[repr(C)] #[derive(Debug, Copy)] pub struct foo { - pub bar: foo__bindgen_ty_bindgen_id_2, + pub bar: foo__bindgen_ty_1, } #[repr(C)] #[derive(Debug, Copy)] -pub struct foo__bindgen_ty_bindgen_id_2 { +pub struct foo__bindgen_ty_1 { pub a: __BindgenUnionField<::std::os::raw::c_uint>, pub b: __BindgenUnionField<::std::os::raw::c_ushort>, pub bindgen_union_field: u32, } #[test] -fn bindgen_test_layout_foo__bindgen_ty_bindgen_id_2() { - assert_eq!(::std::mem::size_of::() , - 4usize); - assert_eq!(::std::mem::align_of::() , - 4usize); +fn bindgen_test_layout_foo__bindgen_ty_1() { + assert_eq!(::std::mem::size_of::() , 4usize); + assert_eq!(::std::mem::align_of::() , 4usize); } -impl Clone for foo__bindgen_ty_bindgen_id_2 { +impl Clone for foo__bindgen_ty_1 { fn clone(&self) -> Self { *self } } #[test] diff --git a/tests/expectations/struct_with_anon_unnamed_struct.rs b/tests/expectations/struct_with_anon_unnamed_struct.rs index ca590b1bd6..1b77fccca4 100644 --- a/tests/expectations/struct_with_anon_unnamed_struct.rs +++ b/tests/expectations/struct_with_anon_unnamed_struct.rs @@ -7,22 +7,20 @@ #[repr(C)] #[derive(Debug, Copy)] pub struct foo { - pub __bindgen_anon_1: foo__bindgen_ty_bindgen_id_2, + pub __bindgen_anon_1: foo__bindgen_ty_1, } #[repr(C)] #[derive(Debug, Copy)] -pub struct foo__bindgen_ty_bindgen_id_2 { +pub struct foo__bindgen_ty_1 { pub a: ::std::os::raw::c_uint, pub b: ::std::os::raw::c_uint, } #[test] -fn bindgen_test_layout_foo__bindgen_ty_bindgen_id_2() { - assert_eq!(::std::mem::size_of::() , - 8usize); - assert_eq!(::std::mem::align_of::() , - 4usize); +fn bindgen_test_layout_foo__bindgen_ty_1() { + assert_eq!(::std::mem::size_of::() , 8usize); + assert_eq!(::std::mem::align_of::() , 4usize); } -impl Clone for foo__bindgen_ty_bindgen_id_2 { +impl Clone for foo__bindgen_ty_1 { fn clone(&self) -> Self { *self } } #[test] diff --git a/tests/expectations/struct_with_anon_unnamed_union.rs b/tests/expectations/struct_with_anon_unnamed_union.rs index 013a9184f9..0763f5907a 100644 --- a/tests/expectations/struct_with_anon_unnamed_union.rs +++ b/tests/expectations/struct_with_anon_unnamed_union.rs @@ -27,23 +27,21 @@ impl ::std::marker::Copy for __BindgenUnionField { } #[repr(C)] #[derive(Debug, Copy)] pub struct foo { - pub __bindgen_anon_1: foo__bindgen_ty_bindgen_id_2, + pub __bindgen_anon_1: foo__bindgen_ty_1, } #[repr(C)] #[derive(Debug, Copy)] -pub struct foo__bindgen_ty_bindgen_id_2 { +pub struct foo__bindgen_ty_1 { pub a: __BindgenUnionField<::std::os::raw::c_uint>, pub b: __BindgenUnionField<::std::os::raw::c_ushort>, pub bindgen_union_field: u32, } #[test] -fn bindgen_test_layout_foo__bindgen_ty_bindgen_id_2() { - assert_eq!(::std::mem::size_of::() , - 4usize); - assert_eq!(::std::mem::align_of::() , - 4usize); +fn bindgen_test_layout_foo__bindgen_ty_1() { + assert_eq!(::std::mem::size_of::() , 4usize); + assert_eq!(::std::mem::align_of::() , 4usize); } -impl Clone for foo__bindgen_ty_bindgen_id_2 { +impl Clone for foo__bindgen_ty_1 { fn clone(&self) -> Self { *self } } #[test] diff --git a/tests/expectations/struct_with_nesting.rs b/tests/expectations/struct_with_nesting.rs index 9eeeb56ef4..0aacb6b3d3 100644 --- a/tests/expectations/struct_with_nesting.rs +++ b/tests/expectations/struct_with_nesting.rs @@ -28,58 +28,52 @@ impl ::std::marker::Copy for __BindgenUnionField { } #[derive(Debug, Copy)] pub struct foo { pub a: ::std::os::raw::c_uint, - pub __bindgen_anon_1: foo__bindgen_ty_bindgen_id_4, + pub __bindgen_anon_1: foo__bindgen_ty_1, } #[repr(C)] #[derive(Debug, Copy)] -pub struct foo__bindgen_ty_bindgen_id_4 { +pub struct foo__bindgen_ty_1 { pub b: __BindgenUnionField<::std::os::raw::c_uint>, - pub __bindgen_anon_1: __BindgenUnionField, - pub __bindgen_anon_2: __BindgenUnionField, + pub __bindgen_anon_1: __BindgenUnionField, + pub __bindgen_anon_2: __BindgenUnionField, pub bindgen_union_field: u32, } #[repr(C)] #[derive(Debug, Copy)] -pub struct foo__bindgen_ty_bindgen_id_4__bindgen_ty_bindgen_id_7 { +pub struct foo__bindgen_ty_1_1 { pub c1: ::std::os::raw::c_ushort, pub c2: ::std::os::raw::c_ushort, } #[test] -fn bindgen_test_layout_foo__bindgen_ty_bindgen_id_4__bindgen_ty_bindgen_id_7() { - assert_eq!(::std::mem::size_of::() - , 4usize); - assert_eq!(::std::mem::align_of::() - , 2usize); +fn bindgen_test_layout_foo__bindgen_ty_1_1() { + assert_eq!(::std::mem::size_of::() , 4usize); + assert_eq!(::std::mem::align_of::() , 2usize); } -impl Clone for foo__bindgen_ty_bindgen_id_4__bindgen_ty_bindgen_id_7 { +impl Clone for foo__bindgen_ty_1_1 { fn clone(&self) -> Self { *self } } #[repr(C)] #[derive(Debug, Copy)] -pub struct foo__bindgen_ty_bindgen_id_4__bindgen_ty_bindgen_id_12 { +pub struct foo__bindgen_ty_1_2 { pub d1: ::std::os::raw::c_uchar, pub d2: ::std::os::raw::c_uchar, pub d3: ::std::os::raw::c_uchar, pub d4: ::std::os::raw::c_uchar, } #[test] -fn bindgen_test_layout_foo__bindgen_ty_bindgen_id_4__bindgen_ty_bindgen_id_12() { - assert_eq!(::std::mem::size_of::() - , 4usize); - assert_eq!(::std::mem::align_of::() - , 1usize); +fn bindgen_test_layout_foo__bindgen_ty_1_2() { + assert_eq!(::std::mem::size_of::() , 4usize); + assert_eq!(::std::mem::align_of::() , 1usize); } -impl Clone for foo__bindgen_ty_bindgen_id_4__bindgen_ty_bindgen_id_12 { +impl Clone for foo__bindgen_ty_1_2 { fn clone(&self) -> Self { *self } } #[test] -fn bindgen_test_layout_foo__bindgen_ty_bindgen_id_4() { - assert_eq!(::std::mem::size_of::() , - 4usize); - assert_eq!(::std::mem::align_of::() , - 4usize); +fn bindgen_test_layout_foo__bindgen_ty_1() { + assert_eq!(::std::mem::size_of::() , 4usize); + assert_eq!(::std::mem::align_of::() , 4usize); } -impl Clone for foo__bindgen_ty_bindgen_id_4 { +impl Clone for foo__bindgen_ty_1 { fn clone(&self) -> Self { *self } } #[test] diff --git a/tests/expectations/struct_with_struct.rs b/tests/expectations/struct_with_struct.rs index 27ff4795e3..c8cdc927f0 100644 --- a/tests/expectations/struct_with_struct.rs +++ b/tests/expectations/struct_with_struct.rs @@ -7,22 +7,20 @@ #[repr(C)] #[derive(Debug, Copy)] pub struct foo { - pub bar: foo__bindgen_ty_bindgen_id_2, + pub bar: foo__bindgen_ty_1, } #[repr(C)] #[derive(Debug, Copy)] -pub struct foo__bindgen_ty_bindgen_id_2 { +pub struct foo__bindgen_ty_1 { pub x: ::std::os::raw::c_uint, pub y: ::std::os::raw::c_uint, } #[test] -fn bindgen_test_layout_foo__bindgen_ty_bindgen_id_2() { - assert_eq!(::std::mem::size_of::() , - 8usize); - assert_eq!(::std::mem::align_of::() , - 4usize); +fn bindgen_test_layout_foo__bindgen_ty_1() { + assert_eq!(::std::mem::size_of::() , 8usize); + assert_eq!(::std::mem::align_of::() , 4usize); } -impl Clone for foo__bindgen_ty_bindgen_id_2 { +impl Clone for foo__bindgen_ty_1 { fn clone(&self) -> Self { *self } } #[test] diff --git a/tests/expectations/typeref.rs b/tests/expectations/typeref.rs index 50795077c8..a8fe14cdbe 100644 --- a/tests/expectations/typeref.rs +++ b/tests/expectations/typeref.rs @@ -79,12 +79,12 @@ impl Clone for Bar { #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct StyleShapeSource { - pub __bindgen_anon_1: StyleShapeSource__bindgen_ty_bindgen_id_14, + pub __bindgen_anon_1: StyleShapeSource__bindgen_ty_1, pub _phantom_0: ::std::marker::PhantomData, } #[repr(C)] #[derive(Debug, Copy, Clone)] -pub struct StyleShapeSource__bindgen_ty_bindgen_id_14 { +pub struct StyleShapeSource__bindgen_ty_1 { pub mPosition: __BindgenUnionField<*mut Position>, pub mFragmentOrURL: __BindgenUnionField<*mut FragmentOrURL>, pub bindgen_union_field: u64, diff --git a/tests/expectations/union_fields.rs b/tests/expectations/union_fields.rs index 684a9e047e..49bdca13b3 100644 --- a/tests/expectations/union_fields.rs +++ b/tests/expectations/union_fields.rs @@ -26,18 +26,18 @@ impl ::std::clone::Clone for __BindgenUnionField { impl ::std::marker::Copy for __BindgenUnionField { } #[repr(C)] #[derive(Debug, Copy)] -pub struct _bindgen_ty_bindgen_id_1 { +pub struct _bindgen_ty_1 { pub mInt: __BindgenUnionField<::std::os::raw::c_int>, pub mFloat: __BindgenUnionField, pub mPointer: __BindgenUnionField<*mut ::std::os::raw::c_void>, pub bindgen_union_field: u64, } #[test] -fn bindgen_test_layout__bindgen_ty_bindgen_id_1() { - assert_eq!(::std::mem::size_of::<_bindgen_ty_bindgen_id_1>() , 8usize); - assert_eq!(::std::mem::align_of::<_bindgen_ty_bindgen_id_1>() , 8usize); +fn bindgen_test_layout__bindgen_ty_1() { + assert_eq!(::std::mem::size_of::<_bindgen_ty_1>() , 8usize); + assert_eq!(::std::mem::align_of::<_bindgen_ty_1>() , 8usize); } -impl Clone for _bindgen_ty_bindgen_id_1 { +impl Clone for _bindgen_ty_1 { fn clone(&self) -> Self { *self } } -pub type nsStyleUnion = _bindgen_ty_bindgen_id_1; +pub type nsStyleUnion = _bindgen_ty_1; diff --git a/tests/expectations/union_template.rs b/tests/expectations/union_template.rs index 1e3cf17ecb..0114e30663 100644 --- a/tests/expectations/union_template.rs +++ b/tests/expectations/union_template.rs @@ -28,13 +28,13 @@ impl ::std::marker::Copy for __BindgenUnionField { } #[derive(Debug, Copy, Clone)] pub struct NastyStruct { pub mIsSome: bool, - pub mStorage: NastyStruct__bindgen_ty_bindgen_id_6, - pub __bindgen_anon_1: NastyStruct__bindgen_ty_bindgen_id_12, + pub mStorage: NastyStruct__bindgen_ty_1, + pub __bindgen_anon_1: NastyStruct__bindgen_ty_2, pub _phantom_0: ::std::marker::PhantomData, } #[repr(C)] #[derive(Debug, Copy, Clone)] -pub struct NastyStruct__bindgen_ty_bindgen_id_6 { +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, @@ -42,7 +42,7 @@ pub struct NastyStruct__bindgen_ty_bindgen_id_6 { } #[repr(C)] #[derive(Debug, Copy, Clone)] -pub struct NastyStruct__bindgen_ty_bindgen_id_12 { +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, diff --git a/tests/expectations/union_with_anon_struct.rs b/tests/expectations/union_with_anon_struct.rs index f216b0bf72..406dd231ed 100644 --- a/tests/expectations/union_with_anon_struct.rs +++ b/tests/expectations/union_with_anon_struct.rs @@ -27,23 +27,21 @@ impl ::std::marker::Copy for __BindgenUnionField { } #[repr(C)] #[derive(Debug, Copy)] pub struct foo { - pub bar: __BindgenUnionField, + pub bar: __BindgenUnionField, pub bindgen_union_field: [u32; 2usize], } #[repr(C)] #[derive(Debug, Copy)] -pub struct foo__bindgen_ty_bindgen_id_2 { +pub struct foo__bindgen_ty_1 { pub a: ::std::os::raw::c_uint, pub b: ::std::os::raw::c_uint, } #[test] -fn bindgen_test_layout_foo__bindgen_ty_bindgen_id_2() { - assert_eq!(::std::mem::size_of::() , - 8usize); - assert_eq!(::std::mem::align_of::() , - 4usize); +fn bindgen_test_layout_foo__bindgen_ty_1() { + assert_eq!(::std::mem::size_of::() , 8usize); + assert_eq!(::std::mem::align_of::() , 4usize); } -impl Clone for foo__bindgen_ty_bindgen_id_2 { +impl Clone for foo__bindgen_ty_1 { fn clone(&self) -> Self { *self } } #[test] diff --git a/tests/expectations/union_with_anon_struct_bitfield.rs b/tests/expectations/union_with_anon_struct_bitfield.rs index 1332d92e44..91d9fa5974 100644 --- a/tests/expectations/union_with_anon_struct_bitfield.rs +++ b/tests/expectations/union_with_anon_struct_bitfield.rs @@ -28,25 +28,23 @@ impl ::std::marker::Copy for __BindgenUnionField { } #[derive(Debug, Copy)] pub struct foo { pub a: __BindgenUnionField<::std::os::raw::c_int>, - pub __bindgen_anon_1: __BindgenUnionField, + pub __bindgen_anon_1: __BindgenUnionField, pub bindgen_union_field: u32, } #[repr(C)] #[derive(Debug, Copy)] -pub struct foo__bindgen_ty_bindgen_id_4 { +pub struct foo__bindgen_ty_1 { pub _bitfield_1: u32, } #[test] -fn bindgen_test_layout_foo__bindgen_ty_bindgen_id_4() { - assert_eq!(::std::mem::size_of::() , - 4usize); - assert_eq!(::std::mem::align_of::() , - 4usize); +fn bindgen_test_layout_foo__bindgen_ty_1() { + assert_eq!(::std::mem::size_of::() , 4usize); + assert_eq!(::std::mem::align_of::() , 4usize); } -impl Clone for foo__bindgen_ty_bindgen_id_4 { +impl Clone for foo__bindgen_ty_1 { fn clone(&self) -> Self { *self } } -impl foo__bindgen_ty_bindgen_id_4 { +impl foo__bindgen_ty_1 { #[inline] pub fn b(&self) -> ::std::os::raw::c_int { unsafe { diff --git a/tests/expectations/union_with_anon_union.rs b/tests/expectations/union_with_anon_union.rs index e7f43cbe48..c7ca3411c6 100644 --- a/tests/expectations/union_with_anon_union.rs +++ b/tests/expectations/union_with_anon_union.rs @@ -27,24 +27,22 @@ impl ::std::marker::Copy for __BindgenUnionField { } #[repr(C)] #[derive(Debug, Copy)] pub struct foo { - pub bar: __BindgenUnionField, + pub bar: __BindgenUnionField, pub bindgen_union_field: u32, } #[repr(C)] #[derive(Debug, Copy)] -pub struct foo__bindgen_ty_bindgen_id_2 { +pub struct foo__bindgen_ty_1 { pub a: __BindgenUnionField<::std::os::raw::c_uint>, pub b: __BindgenUnionField<::std::os::raw::c_ushort>, pub bindgen_union_field: u32, } #[test] -fn bindgen_test_layout_foo__bindgen_ty_bindgen_id_2() { - assert_eq!(::std::mem::size_of::() , - 4usize); - assert_eq!(::std::mem::align_of::() , - 4usize); +fn bindgen_test_layout_foo__bindgen_ty_1() { + assert_eq!(::std::mem::size_of::() , 4usize); + assert_eq!(::std::mem::align_of::() , 4usize); } -impl Clone for foo__bindgen_ty_bindgen_id_2 { +impl Clone for foo__bindgen_ty_1 { fn clone(&self) -> Self { *self } } #[test] diff --git a/tests/expectations/union_with_anon_unnamed_struct.rs b/tests/expectations/union_with_anon_unnamed_struct.rs index defbe66bc6..33d75affb6 100644 --- a/tests/expectations/union_with_anon_unnamed_struct.rs +++ b/tests/expectations/union_with_anon_unnamed_struct.rs @@ -28,25 +28,23 @@ impl ::std::marker::Copy for __BindgenUnionField { } #[derive(Debug, Copy)] pub struct pixel { pub rgba: __BindgenUnionField<::std::os::raw::c_uint>, - pub __bindgen_anon_1: __BindgenUnionField, + pub __bindgen_anon_1: __BindgenUnionField, pub bindgen_union_field: u32, } #[repr(C)] #[derive(Debug, Copy)] -pub struct pixel__bindgen_ty_bindgen_id_4 { +pub struct pixel__bindgen_ty_1 { pub r: ::std::os::raw::c_uchar, pub g: ::std::os::raw::c_uchar, pub b: ::std::os::raw::c_uchar, pub a: ::std::os::raw::c_uchar, } #[test] -fn bindgen_test_layout_pixel__bindgen_ty_bindgen_id_4() { - assert_eq!(::std::mem::size_of::() , - 4usize); - assert_eq!(::std::mem::align_of::() , - 1usize); +fn bindgen_test_layout_pixel__bindgen_ty_1() { + assert_eq!(::std::mem::size_of::() , 4usize); + assert_eq!(::std::mem::align_of::() , 1usize); } -impl Clone for pixel__bindgen_ty_bindgen_id_4 { +impl Clone for pixel__bindgen_ty_1 { fn clone(&self) -> Self { *self } } #[test] diff --git a/tests/expectations/union_with_anon_unnamed_union.rs b/tests/expectations/union_with_anon_unnamed_union.rs index 519bf61964..c47850f59e 100644 --- a/tests/expectations/union_with_anon_unnamed_union.rs +++ b/tests/expectations/union_with_anon_unnamed_union.rs @@ -28,24 +28,22 @@ impl ::std::marker::Copy for __BindgenUnionField { } #[derive(Debug, Copy)] pub struct foo { pub a: __BindgenUnionField<::std::os::raw::c_uint>, - pub __bindgen_anon_1: __BindgenUnionField, + pub __bindgen_anon_1: __BindgenUnionField, pub bindgen_union_field: u32, } #[repr(C)] #[derive(Debug, Copy)] -pub struct foo__bindgen_ty_bindgen_id_4 { +pub struct foo__bindgen_ty_1 { pub b: __BindgenUnionField<::std::os::raw::c_ushort>, pub c: __BindgenUnionField<::std::os::raw::c_uchar>, pub bindgen_union_field: u16, } #[test] -fn bindgen_test_layout_foo__bindgen_ty_bindgen_id_4() { - assert_eq!(::std::mem::size_of::() , - 2usize); - assert_eq!(::std::mem::align_of::() , - 2usize); +fn bindgen_test_layout_foo__bindgen_ty_1() { + assert_eq!(::std::mem::size_of::() , 2usize); + assert_eq!(::std::mem::align_of::() , 2usize); } -impl Clone for foo__bindgen_ty_bindgen_id_4 { +impl Clone for foo__bindgen_ty_1 { fn clone(&self) -> Self { *self } } #[test] diff --git a/tests/expectations/union_with_nesting.rs b/tests/expectations/union_with_nesting.rs index d7fc780a5b..6ed81adb49 100644 --- a/tests/expectations/union_with_nesting.rs +++ b/tests/expectations/union_with_nesting.rs @@ -28,57 +28,51 @@ impl ::std::marker::Copy for __BindgenUnionField { } #[derive(Debug, Copy)] pub struct foo { pub a: __BindgenUnionField<::std::os::raw::c_uint>, - pub __bindgen_anon_1: __BindgenUnionField, + pub __bindgen_anon_1: __BindgenUnionField, pub bindgen_union_field: u32, } #[repr(C)] #[derive(Debug, Copy)] -pub struct foo__bindgen_ty_bindgen_id_4 { - pub __bindgen_anon_1: foo__bindgen_ty_bindgen_id_4__bindgen_ty_bindgen_id_5, - pub __bindgen_anon_2: foo__bindgen_ty_bindgen_id_4__bindgen_ty_bindgen_id_10, +pub struct foo__bindgen_ty_1 { + pub __bindgen_anon_1: foo__bindgen_ty_1_1, + pub __bindgen_anon_2: foo__bindgen_ty_1_2, } #[repr(C)] #[derive(Debug, Copy)] -pub struct foo__bindgen_ty_bindgen_id_4__bindgen_ty_bindgen_id_5 { +pub struct foo__bindgen_ty_1_1 { pub b1: __BindgenUnionField<::std::os::raw::c_ushort>, pub b2: __BindgenUnionField<::std::os::raw::c_ushort>, pub bindgen_union_field: u16, } #[test] -fn bindgen_test_layout_foo__bindgen_ty_bindgen_id_4__bindgen_ty_bindgen_id_5() { - assert_eq!(::std::mem::size_of::() - , 2usize); - assert_eq!(::std::mem::align_of::() - , 2usize); +fn bindgen_test_layout_foo__bindgen_ty_1_1() { + assert_eq!(::std::mem::size_of::() , 2usize); + assert_eq!(::std::mem::align_of::() , 2usize); } -impl Clone for foo__bindgen_ty_bindgen_id_4__bindgen_ty_bindgen_id_5 { +impl Clone for foo__bindgen_ty_1_1 { fn clone(&self) -> Self { *self } } #[repr(C)] #[derive(Debug, Copy)] -pub struct foo__bindgen_ty_bindgen_id_4__bindgen_ty_bindgen_id_10 { +pub struct foo__bindgen_ty_1_2 { pub c1: __BindgenUnionField<::std::os::raw::c_ushort>, pub c2: __BindgenUnionField<::std::os::raw::c_ushort>, pub bindgen_union_field: u16, } #[test] -fn bindgen_test_layout_foo__bindgen_ty_bindgen_id_4__bindgen_ty_bindgen_id_10() { - assert_eq!(::std::mem::size_of::() - , 2usize); - assert_eq!(::std::mem::align_of::() - , 2usize); +fn bindgen_test_layout_foo__bindgen_ty_1_2() { + assert_eq!(::std::mem::size_of::() , 2usize); + assert_eq!(::std::mem::align_of::() , 2usize); } -impl Clone for foo__bindgen_ty_bindgen_id_4__bindgen_ty_bindgen_id_10 { +impl Clone for foo__bindgen_ty_1_2 { fn clone(&self) -> Self { *self } } #[test] -fn bindgen_test_layout_foo__bindgen_ty_bindgen_id_4() { - assert_eq!(::std::mem::size_of::() , - 4usize); - assert_eq!(::std::mem::align_of::() , - 2usize); +fn bindgen_test_layout_foo__bindgen_ty_1() { + assert_eq!(::std::mem::size_of::() , 4usize); + assert_eq!(::std::mem::align_of::() , 2usize); } -impl Clone for foo__bindgen_ty_bindgen_id_4 { +impl Clone for foo__bindgen_ty_1 { fn clone(&self) -> Self { *self } } #[test] diff --git a/tests/expectations/unknown_attr.rs b/tests/expectations/unknown_attr.rs index 06da6a3c4e..fd9cce4593 100644 --- a/tests/expectations/unknown_attr.rs +++ b/tests/expectations/unknown_attr.rs @@ -6,11 +6,11 @@ #[repr(C)] #[derive(Debug, Copy)] -pub struct _bindgen_ty_bindgen_id_1 { +pub struct _bindgen_ty_1 { pub __clang_max_align_nonce1: ::std::os::raw::c_longlong, pub __clang_max_align_nonce2: f64, } -impl Clone for _bindgen_ty_bindgen_id_1 { +impl Clone for _bindgen_ty_1 { fn clone(&self) -> Self { *self } } -pub type max_align_t = _bindgen_ty_bindgen_id_1; +pub type max_align_t = _bindgen_ty_1; diff --git a/tests/expectations/virtual_dtor.rs b/tests/expectations/virtual_dtor.rs index 99e0a535ed..9571f084b9 100644 --- a/tests/expectations/virtual_dtor.rs +++ b/tests/expectations/virtual_dtor.rs @@ -5,12 +5,12 @@ #[repr(C)] -pub struct bindgen_vtable__bindgen_id_1 { +pub struct nsSlots__bindgen_vtable { } #[repr(C)] #[derive(Debug)] pub struct nsSlots { - pub vtable_: *const bindgen_vtable__bindgen_id_1, + pub vtable_: *const nsSlots__bindgen_vtable, } #[test] fn bindgen_test_layout_nsSlots() { diff --git a/tests/expectations/virtual_overloaded.rs b/tests/expectations/virtual_overloaded.rs index d395fed01c..7833cdbfa4 100644 --- a/tests/expectations/virtual_overloaded.rs +++ b/tests/expectations/virtual_overloaded.rs @@ -5,12 +5,12 @@ #[repr(C)] -pub struct bindgen_vtable__bindgen_id_1 { +pub struct C__bindgen_vtable { } #[repr(C)] #[derive(Debug, Copy)] pub struct C { - pub vtable_: *const bindgen_vtable__bindgen_id_1, + pub vtable_: *const C__bindgen_vtable, } #[test] fn bindgen_test_layout_C() { diff --git a/tests/expectations/vtable_recursive_sig.rs b/tests/expectations/vtable_recursive_sig.rs index 1044c4e46a..ce62eeb0fc 100644 --- a/tests/expectations/vtable_recursive_sig.rs +++ b/tests/expectations/vtable_recursive_sig.rs @@ -18,12 +18,12 @@ impl Clone for Derived { fn clone(&self) -> Self { *self } } #[repr(C)] -pub struct bindgen_vtable__bindgen_id_2 { +pub struct Base__bindgen_vtable { } #[repr(C)] #[derive(Debug, Copy)] pub struct Base { - pub vtable_: *const bindgen_vtable__bindgen_id_2, + pub vtable_: *const Base__bindgen_vtable, } #[test] fn bindgen_test_layout_Base() {