rust-lang / rust-bindgen

Automatically generates Rust FFI bindings to C (and some C++) libraries.
https://rust-lang.github.io/rust-bindgen/
BSD 3-Clause "New" or "Revised" License
4.43k stars 695 forks source link

bindgen generates incorrect Rust code for C functions which accept callbacks #1167

Closed drake-amz closed 6 years ago

drake-amz commented 6 years ago

I am trying to use bindgen to generate Rust bindings to a C library. This library's header file define various functions. Some of the defined functions accept a function pointer as a callback parameter. The callback functions themselves also take parameters.

Although bindgen exits successfully, the produced Rust code is invalid. There are multiple instances of C functions not being generated in the Rust code, although the extern "C" { } block is generated. See below for a reduced version of the problem that demonstrates a minimal reproduction. This issue only affects C functions which accept callback function pointers. Other functions without function pointer parameters are generated correctly.

Reduced version of the problem:

$ clang --version
Apple LLVM version 9.0.0 (clang-900.0.38)
Target: x86_64-apple-darwin16.7.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
$ bindgen --version
bindgen 0.31.3
$ cat example.h
int failure_example(void (*callback)(int some_arg));
$ bindgen example.h -o bindings.rs
$ cat bindings.rs
/* automatically generated by rust-bindgen */

extern "C" {
 # [ link_name = "\u{1}_failure_example" ]
    ;
}

Attempting to compile the produced bindings.rs file fails, because bindgen for some reason did not generate a function in the extern block.

$ cargo build
   Compiling example v0.1.0 (file:///Users/drakeat/projects/example)
error: expected item after attributes
 --> src/bindings.rs:4:42
  |
4 |  # [ link_name = "\u{1}_failure_example" ]
  |                                          ^

error: expected one of `crate`, `fn`, `pub`, `static`, `type`, or `}`, found `;`
 --> src/bindings.rs:5:5
  |
4 |  # [ link_name = "\u{1}_failure_example" ]
  |                                           - expected one of `crate`, `fn`, `pub`, `static`, `type`, or `}` here
5 |     ;
  |     ^ unexpected token

error: Could not compile `example`.

Through experimentation I discovered that removing all parameters from the callback function pointer causes bindgen to start defining the failure_example function properly. Unfortunately this is not a useful solution for my real problem because the library is third party and can't be so modified.

Example of how removing the int some_arg parameter to the callback function causes bindgen to start working:

$ clang --version
Apple LLVM version 9.0.0 (clang-900.0.38)
Target: x86_64-apple-darwin16.7.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
$ bindgen --version
bindgen 0.31.3
$ cat example.h
int failure_example(void (*callback)());
$ bindgen example.h -o bindings.rs
$ cat bindings.rs
/* automatically generated by rust-bindgen */

extern "C" {
 # [ link_name = "\u{1}_failure_example" ]
    pub fn failure_example(callback: ::std::option::Option<unsafe extern "C" fn()>)
                           -> ::std::os::raw::c_int;
}
drake-amz commented 6 years ago

Here is the result of enabling debug logging when running bindgen. Of possible interest is the line WARN:bindgen: Using clang (4, 0), expected (3, 9) - could using a later version than 3.9 cause problems?

$ RUST_LOG=bindgen bindgen example.h -o bindings.rs
INFO:bindgen: Clang Version: clang version 4.0.1 (tags/RELEASE_401/final)
WARN:bindgen: Using clang (4, 0), expected (3, 9)
DEBUG:bindgen::ir::context: BindgenContext::add_item(Item { id: ItemId(0), local_id: Cell { value: None }, next_child_local_id: Cell { value: 1 }, canonical_name_cache: RefCell { value: None }, comment: None, annotations: Annotations { opaque: false, hide: false, use_instead_of: None, disallow_copy: false, private_fields: None, accessor_kind: None, constify_enum_variant: false }, parent_id: ItemId(0), kind: Module(Module { name: Some("root"), kind: Normal, children: {} }) }, declaration: None, loc: None
DEBUG:bindgen::ir::function: Function::parse(Cursor(failure_example kind: FunctionDecl, loc: example.h:1:5, usr: Some("c:@F@failure_example")), Type(int (void (*)(int)), kind: FunctionProto, cconv: 1, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None)))
DEBUG:bindgen::ir::item: Item::from_ty_with_id: ItemId(1)
    ty = Type(int (void (*)(int)), kind: FunctionProto, cconv: 1, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None)),
    location = Cursor(failure_example kind: FunctionDecl, loc: example.h:1:5, usr: Some("c:@F@failure_example"))
DEBUG:bindgen::ir::context: builtin_or_resolved_ty: Type(int (void (*)(int)), kind: FunctionProto, cconv: 1, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None)), Some(Cursor(failure_example kind: FunctionDecl, loc: example.h:1:5, usr: Some("c:@F@failure_example"))), None
DEBUG:bindgen::ir::context: Not resolved, maybe builtin?
DEBUG:bindgen::ir::context: builtin_or_resolved_ty: Type(int (void (*)(int)), kind: FunctionProto, cconv: 1, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None)), Some(Cursor(failure_example kind: FunctionDecl, loc: example.h:1:5, usr: Some("c:@F@failure_example"))), None
DEBUG:bindgen::ir::context: Not resolved, maybe builtin?
DEBUG:bindgen::ir::ty: from_clang_ty: ItemId(1), ty: Type(int (void (*)(int)), kind: FunctionProto, cconv: 1, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None)), loc: Cursor(failure_example kind: FunctionDecl, loc: example.h:1:5, usr: Some("c:@F@failure_example"))
DEBUG:bindgen::ir::ty: currently_parsed_types: []
DEBUG:bindgen::ir::function: FunctionSig::from_ty Type(int (void (*)(int)), kind: FunctionProto, cconv: 1, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None)) Cursor(failure_example kind: FunctionDecl, loc: example.h:1:5, usr: Some("c:@F@failure_example"))
DEBUG:bindgen::ir::item: from_ty_or_ref_with_id: ItemId(2) Type(void (*)(int), kind: Pointer, cconv: 100, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None)), Cursor(callback kind: ParmDecl, loc: example.h:1:28, usr: Some("c:example.h@20@F@failure_example@callback")), None
DEBUG:bindgen::ir::context: builtin_or_resolved_ty: Type(void (*)(int), kind: Pointer, cconv: 100, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None)), Some(Cursor(callback kind: ParmDecl, loc: example.h:1:28, usr: Some("c:example.h@20@F@failure_example@callback"))), None
DEBUG:bindgen::ir::context: Not resolved, maybe builtin?
DEBUG:bindgen::ir::item: New unresolved type reference: Type(void (*)(int), kind: Pointer, cconv: 100, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None)), Cursor(callback kind: ParmDecl, loc: example.h:1:28, usr: Some("c:example.h@20@F@failure_example@callback"))
DEBUG:bindgen::ir::context: BindgenContext::add_item(Item { id: ItemId(2), local_id: Cell { value: None }, next_child_local_id: Cell { value: 1 }, canonical_name_cache: RefCell { value: None }, comment: None, annotations: Annotations { opaque: false, hide: false, use_instead_of: None, disallow_copy: false, private_fields: None, accessor_kind: None, constify_enum_variant: false }, parent_id: ItemId(0), kind: Type(Type { name: None, layout: None, kind: UnresolvedTypeRef(Type(void (*)(int), kind: Pointer, cconv: 100, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None)), Cursor(callback kind: ParmDecl, loc: example.h:1:28, usr: Some("c:example.h@20@F@failure_example@callback")), None), is_const: false }) }, declaration: Some(Cursor( kind: InvalidFile, loc: builtin definitions, usr: None)), loc: None
DEBUG:bindgen::ir::context: add_item_to_module: adding ItemId(2) as child of parent module ItemId(0)
DEBUG:bindgen::ir::context: Invalid declaration Cursor( kind: InvalidFile, loc: builtin definitions, usr: None) found for type Type { name: None, layout: None, kind: UnresolvedTypeRef(Type(void (*)(int), kind: Pointer, cconv: 100, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None)), Cursor(callback kind: ParmDecl, loc: example.h:1:28, usr: Some("c:example.h@20@F@failure_example@callback")), None), is_const: false }
DEBUG:bindgen::ir::item: from_ty_or_ref_with_id: ItemId(3) Type(int, kind: Int, cconv: 100, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None)), Cursor(failure_example kind: FunctionDecl, loc: example.h:1:5, usr: Some("c:@F@failure_example")), None
DEBUG:bindgen::ir::context: builtin_or_resolved_ty: Type(int, kind: Int, cconv: 100, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None)), Some(Cursor(failure_example kind: FunctionDecl, loc: example.h:1:5, usr: Some("c:@F@failure_example"))), None
DEBUG:bindgen::ir::context: Not resolved, maybe builtin?
DEBUG:bindgen::ir::context: add_builtin_item: item = Item { id: ItemId(4), local_id: Cell { value: None }, next_child_local_id: Cell { value: 1 }, canonical_name_cache: RefCell { value: None }, comment: None, annotations: Annotations { opaque: false, hide: false, use_instead_of: None, disallow_copy: false, private_fields: None, accessor_kind: None, constify_enum_variant: false }, parent_id: ItemId(0), kind: Type(Type { name: Some("int"), layout: Some(Layout { size: 4, align: 4, packed: false }), kind: Int(Int), is_const: false }) }
DEBUG:bindgen::ir::context: add_item_to_module: adding ItemId(4) as child of parent module ItemId(0)
DEBUG:bindgen::ir::item: TypeId(ItemId(4)) already resolved: Cursor(failure_example kind: FunctionDecl, loc: example.h:1:5, usr: Some("c:@F@failure_example"))
DEBUG:bindgen::ir::context: BindgenContext::add_item(Item { id: ItemId(1), local_id: Cell { value: None }, next_child_local_id: Cell { value: 1 }, canonical_name_cache: RefCell { value: None }, comment: None, annotations: Annotations { opaque: false, hide: false, use_instead_of: None, disallow_copy: false, private_fields: None, accessor_kind: None, constify_enum_variant: false }, parent_id: ItemId(0), kind: Type(Type { name: None, layout: Some(Layout { size: 1, align: 4, packed: false }), kind: Function(FunctionSig { return_type: TypeId(ItemId(4)), argument_types: [(Some("callback"), TypeId(ItemId(2)))], is_variadic: false, abi: C }), is_const: false }) }, declaration: Some(Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None)), loc: Some(Cursor(failure_example kind: FunctionDecl, loc: example.h:1:5, usr: Some("c:@F@failure_example")))
DEBUG:bindgen::ir::context: add_item_to_module: adding ItemId(1) as child of parent module ItemId(0)
DEBUG:bindgen::ir::context: Invalid declaration Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None) found for type Type { name: None, layout: Some(Layout { size: 1, align: 4, packed: false }), kind: Function(FunctionSig { return_type: TypeId(ItemId(4)), argument_types: [(Some("callback"), TypeId(ItemId(2)))], is_variadic: false, abi: C }), is_const: false }
DEBUG:bindgen::ir::context: BindgenContext::add_item(Item { id: ItemId(5), local_id: Cell { value: None }, next_child_local_id: Cell { value: 1 }, canonical_name_cache: RefCell { value: None }, comment: None, annotations: Annotations { opaque: false, hide: false, use_instead_of: None, disallow_copy: false, private_fields: None, accessor_kind: None, constify_enum_variant: false }, parent_id: ItemId(0), kind: Function(Function { name: "failure_example", mangled_name: Some("_failure_example"), signature: TypeId(ItemId(1)), comment: None, kind: Function, linkage: External }) }, declaration: Some(Cursor(failure_example kind: FunctionDecl, loc: example.h:1:5, usr: Some("c:@F@failure_example"))), loc: Some(Cursor(failure_example kind: FunctionDecl, loc: example.h:1:5, usr: Some("c:@F@failure_example")))
DEBUG:bindgen::ir::context: add_item_to_module: adding ItemId(5) as child of parent module ItemId(0)
DEBUG:bindgen::ir::item: Item::from_ty_with_id: ItemId(6)
    ty = Type(void (*)(int), kind: Pointer, cconv: 100, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None)),
    location = Cursor(callback kind: ParmDecl, loc: example.h:1:28, usr: Some("c:example.h@20@F@failure_example@callback"))
DEBUG:bindgen::ir::context: builtin_or_resolved_ty: Type(void (*)(int), kind: Pointer, cconv: 100, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None)), Some(Cursor(callback kind: ParmDecl, loc: example.h:1:28, usr: Some("c:example.h@20@F@failure_example@callback"))), None
DEBUG:bindgen::ir::context: Not resolved, maybe builtin?
DEBUG:bindgen::ir::context: builtin_or_resolved_ty: Type(void (*)(int), kind: Pointer, cconv: 100, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None)), Some(Cursor(callback kind: ParmDecl, loc: example.h:1:28, usr: Some("c:example.h@20@F@failure_example@callback"))), None
DEBUG:bindgen::ir::context: Not resolved, maybe builtin?
DEBUG:bindgen::ir::ty: from_clang_ty: ItemId(6), ty: Type(void (*)(int), kind: Pointer, cconv: 100, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None)), loc: Cursor(callback kind: ParmDecl, loc: example.h:1:28, usr: Some("c:example.h@20@F@failure_example@callback"))
DEBUG:bindgen::ir::ty: currently_parsed_types: []
DEBUG:bindgen::ir::item: from_ty_or_ref_with_id: ItemId(7) Type(void (int), kind: Unexposed, cconv: 1, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None)), Cursor(callback kind: ParmDecl, loc: example.h:1:28, usr: Some("c:example.h@20@F@failure_example@callback")), None
DEBUG:bindgen::ir::item: refs already collected, resolving directly
DEBUG:bindgen::ir::item: Item::from_ty_with_id: ItemId(7)
    ty = Type(void (int), kind: Unexposed, cconv: 1, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None)),
    location = Cursor(callback kind: ParmDecl, loc: example.h:1:28, usr: Some("c:example.h@20@F@failure_example@callback"))
DEBUG:bindgen::ir::item: Item::type_param:
    with_id = Some(ItemId(7)),
    ty = void (*)(int) Type(void (*)(int), kind: Pointer, cconv: 100, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None)),
    location: Cursor(callback kind: ParmDecl, loc: example.h:1:28, usr: Some("c:example.h@20@F@failure_example@callback"))
DEBUG:bindgen::ir::context: builtin_or_resolved_ty: Type(void (int), kind: Unexposed, cconv: 1, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None)), Some(Cursor(callback kind: ParmDecl, loc: example.h:1:28, usr: Some("c:example.h@20@F@failure_example@callback"))), None
DEBUG:bindgen::ir::context: Not resolved, maybe builtin?
DEBUG:bindgen::ir::context: builtin_or_resolved_ty: Type(void (int), kind: Unexposed, cconv: 1, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None)), Some(Cursor(callback kind: ParmDecl, loc: example.h:1:28, usr: Some("c:example.h@20@F@failure_example@callback"))), None
DEBUG:bindgen::ir::context: Not resolved, maybe builtin?
DEBUG:bindgen::ir::ty: from_clang_ty: ItemId(7), ty: Type(void (int), kind: Unexposed, cconv: 1, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None)), loc: Cursor(callback kind: ParmDecl, loc: example.h:1:28, usr: Some("c:example.h@20@F@failure_example@callback"))
DEBUG:bindgen::ir::ty: currently_parsed_types: []
DEBUG:bindgen::ir::function: FunctionSig::from_ty Type(void (int), kind: Unexposed, cconv: 1, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None)) Cursor(callback kind: ParmDecl, loc: example.h:1:28, usr: Some("c:example.h@20@F@failure_example@callback"))
DEBUG:bindgen::ir::item: from_ty_or_ref_with_id: ItemId(8) Type(int, kind: Int, cconv: 100, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None)), Cursor(some_arg kind: ParmDecl, loc: example.h:1:42, usr: Some("c:example.h@some_arg")), None
DEBUG:bindgen::ir::item: refs already collected, resolving directly
DEBUG:bindgen::ir::item: Item::from_ty_with_id: ItemId(8)
    ty = Type(int, kind: Int, cconv: 100, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None)),
    location = Cursor(some_arg kind: ParmDecl, loc: example.h:1:42, usr: Some("c:example.h@some_arg"))
DEBUG:bindgen::ir::context: builtin_or_resolved_ty: Type(int, kind: Int, cconv: 100, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None)), Some(Cursor(some_arg kind: ParmDecl, loc: example.h:1:42, usr: Some("c:example.h@some_arg"))), None
DEBUG:bindgen::ir::context: Not resolved, maybe builtin?
DEBUG:bindgen::ir::context: add_builtin_item: item = Item { id: ItemId(9), local_id: Cell { value: None }, next_child_local_id: Cell { value: 1 }, canonical_name_cache: RefCell { value: None }, comment: None, annotations: Annotations { opaque: false, hide: false, use_instead_of: None, disallow_copy: false, private_fields: None, accessor_kind: None, constify_enum_variant: false }, parent_id: ItemId(0), kind: Type(Type { name: Some("int"), layout: Some(Layout { size: 4, align: 4, packed: false }), kind: Int(Int), is_const: false }) }
DEBUG:bindgen::ir::context: add_item_to_module: adding ItemId(9) as child of parent module ItemId(0)
DEBUG:bindgen::ir::item: from_ty_or_ref_with_id: ItemId(10) Type(void, kind: Void, cconv: 100, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None)), Cursor(callback kind: ParmDecl, loc: example.h:1:28, usr: Some("c:example.h@20@F@failure_example@callback")), None
DEBUG:bindgen::ir::item: refs already collected, resolving directly
DEBUG:bindgen::ir::item: Item::from_ty_with_id: ItemId(10)
    ty = Type(void, kind: Void, cconv: 100, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None)),
    location = Cursor(callback kind: ParmDecl, loc: example.h:1:28, usr: Some("c:example.h@20@F@failure_example@callback"))
DEBUG:bindgen::ir::context: builtin_or_resolved_ty: Type(void, kind: Void, cconv: 100, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None)), Some(Cursor(callback kind: ParmDecl, loc: example.h:1:28, usr: Some("c:example.h@20@F@failure_example@callback"))), None
DEBUG:bindgen::ir::context: Not resolved, maybe builtin?
DEBUG:bindgen::ir::context: add_builtin_item: item = Item { id: ItemId(11), local_id: Cell { value: None }, next_child_local_id: Cell { value: 1 }, canonical_name_cache: RefCell { value: None }, comment: None, annotations: Annotations { opaque: false, hide: false, use_instead_of: None, disallow_copy: false, private_fields: None, accessor_kind: None, constify_enum_variant: false }, parent_id: ItemId(0), kind: Type(Type { name: Some("void"), layout: None, kind: Void, is_const: false }) }
DEBUG:bindgen::ir::context: add_item_to_module: adding ItemId(11) as child of parent module ItemId(0)
DEBUG:bindgen::ir::context: BindgenContext::add_item(Item { id: ItemId(7), local_id: Cell { value: None }, next_child_local_id: Cell { value: 1 }, canonical_name_cache: RefCell { value: None }, comment: None, annotations: Annotations { opaque: false, hide: false, use_instead_of: None, disallow_copy: false, private_fields: None, accessor_kind: None, constify_enum_variant: false }, parent_id: ItemId(0), kind: Type(Type { name: None, layout: Some(Layout { size: 1, align: 4, packed: false }), kind: Function(FunctionSig { return_type: TypeId(ItemId(11)), argument_types: [(Some("some_arg"), TypeId(ItemId(9)))], is_variadic: false, abi: C }), is_const: false }) }, declaration: Some(Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None)), loc: Some(Cursor(callback kind: ParmDecl, loc: example.h:1:28, usr: Some("c:example.h@20@F@failure_example@callback")))
DEBUG:bindgen::ir::context: add_item_to_module: adding ItemId(7) as child of parent module ItemId(0)
DEBUG:bindgen::ir::context: Invalid declaration Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None) found for type Type { name: None, layout: Some(Layout { size: 1, align: 4, packed: false }), kind: Function(FunctionSig { return_type: TypeId(ItemId(11)), argument_types: [(Some("some_arg"), TypeId(ItemId(9)))], is_variadic: false, abi: C }), is_const: false }
DEBUG:bindgen::ir::context: BindgenContext::add_item(Item { id: ItemId(6), local_id: Cell { value: None }, next_child_local_id: Cell { value: 1 }, canonical_name_cache: RefCell { value: None }, comment: None, annotations: Annotations { opaque: false, hide: false, use_instead_of: None, disallow_copy: false, private_fields: None, accessor_kind: None, constify_enum_variant: false }, parent_id: ItemId(0), kind: Type(Type { name: None, layout: Some(Layout { size: 8, align: 8, packed: false }), kind: Pointer(TypeId(ItemId(7))), is_const: false }) }, declaration: Some(Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None)), loc: Some(Cursor(callback kind: ParmDecl, loc: example.h:1:28, usr: Some("c:example.h@20@F@failure_example@callback")))
DEBUG:bindgen::ir::context: add_item_to_module: adding ItemId(6) as child of parent module ItemId(0)
DEBUG:bindgen::ir::context: Invalid declaration Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None) found for type Type { name: None, layout: Some(Layout { size: 8, align: 8, packed: false }), kind: Pointer(TypeId(ItemId(7))), is_const: false }
DEBUG:bindgen::ir::context: No replacements to process
TRACE:bindgen::ir::analysis::has_vtable: constrain ItemId(11)
TRACE:bindgen::ir::analysis::has_vtable: constrain ItemId(9)
TRACE:bindgen::ir::analysis::has_vtable: constrain ItemId(7)
TRACE:bindgen::ir::analysis::has_vtable: constrain ItemId(6)
TRACE:bindgen::ir::analysis::has_vtable: constrain ItemId(5)
TRACE:bindgen::ir::analysis::has_vtable: constrain ItemId(4)
TRACE:bindgen::ir::analysis::has_vtable: constrain ItemId(2)
TRACE:bindgen::ir::analysis::has_vtable:     aliases and references forward to their inner type
TRACE:bindgen::ir::analysis::has_vtable: constrain ItemId(1)
TRACE:bindgen::ir::analysis::has_vtable: constrain ItemId(0)
TRACE:bindgen::ir::analysis::sizedness: constrain TypeId(ItemId(11))
TRACE:bindgen::ir::analysis::sizedness:     void is zero-sized
TRACE:bindgen::ir::analysis::sizedness: inserting ZeroSized for TypeId(ItemId(11))
TRACE:bindgen::ir::analysis::sizedness: constrain TypeId(ItemId(9))
TRACE:bindgen::ir::analysis::sizedness:     Int(Int) is known not to be zero-sized
TRACE:bindgen::ir::analysis::sizedness: inserting NonZeroSized for TypeId(ItemId(9))
TRACE:bindgen::ir::analysis::sizedness: constrain TypeId(ItemId(7))
TRACE:bindgen::ir::analysis::sizedness:     Function(FunctionSig { return_type: TypeId(ItemId(11)), argument_types: [(Some("some_arg"), TypeId(ItemId(9)))], is_variadic: false, abi: C }) is known not to be zero-sized
TRACE:bindgen::ir::analysis::sizedness: inserting NonZeroSized for TypeId(ItemId(7))
TRACE:bindgen::ir::analysis::sizedness: enqueue TypeId(ItemId(6)) into worklist
TRACE:bindgen::ir::analysis::sizedness: constrain TypeId(ItemId(6))
TRACE:bindgen::ir::analysis::sizedness:     Pointer(TypeId(ItemId(7))) is known not to be zero-sized
TRACE:bindgen::ir::analysis::sizedness: inserting NonZeroSized for TypeId(ItemId(6))
TRACE:bindgen::ir::analysis::sizedness: enqueue TypeId(ItemId(2)) into worklist
TRACE:bindgen::ir::analysis::sizedness: constrain TypeId(ItemId(2))
TRACE:bindgen::ir::analysis::sizedness:     aliases and type refs forward to their inner type
TRACE:bindgen::ir::analysis::sizedness: inserting NonZeroSized for TypeId(ItemId(2))
TRACE:bindgen::ir::analysis::sizedness: constrain TypeId(ItemId(6))
TRACE:bindgen::ir::analysis::sizedness:     already know it is not zero-sized
TRACE:bindgen::ir::analysis::sizedness: constrain TypeId(ItemId(4))
TRACE:bindgen::ir::analysis::sizedness:     Int(Int) is known not to be zero-sized
TRACE:bindgen::ir::analysis::sizedness: inserting NonZeroSized for TypeId(ItemId(4))
TRACE:bindgen::ir::analysis::sizedness: constrain TypeId(ItemId(2))
TRACE:bindgen::ir::analysis::sizedness:     already know it is not zero-sized
TRACE:bindgen::ir::analysis::sizedness: constrain TypeId(ItemId(1))
TRACE:bindgen::ir::analysis::sizedness:     Function(FunctionSig { return_type: TypeId(ItemId(4)), argument_types: [(Some("callback"), TypeId(ItemId(2)))], is_variadic: false, abi: C }) is known not to be zero-sized
TRACE:bindgen::ir::analysis::sizedness: inserting NonZeroSized for TypeId(ItemId(1))
TRACE:bindgen::ir::analysis::template_params: constrain ItemId(11)
TRACE:bindgen::ir::analysis::template_params:   initially, used set is {}
TRACE:bindgen::ir::analysis::template_params:     other item: join with successors' usage
TRACE:bindgen::ir::analysis::template_params:   finally, used set is {}
TRACE:bindgen::ir::analysis::template_params: constrain ItemId(9)
TRACE:bindgen::ir::analysis::template_params:   initially, used set is {}
TRACE:bindgen::ir::analysis::template_params:     other item: join with successors' usage
TRACE:bindgen::ir::analysis::template_params:   finally, used set is {}
TRACE:bindgen::ir::analysis::template_params: constrain ItemId(9)
TRACE:bindgen::ir::analysis::template_params:   initially, used set is {}
TRACE:bindgen::ir::analysis::template_params:     other item: join with successors' usage
TRACE:bindgen::ir::analysis::template_params:   finally, used set is {}
TRACE:bindgen::ir::analysis::template_params: constrain ItemId(11)
TRACE:bindgen::ir::analysis::template_params:   initially, used set is {}
TRACE:bindgen::ir::analysis::template_params:     other item: join with successors' usage
TRACE:bindgen::ir::analysis::template_params:   finally, used set is {}
TRACE:bindgen::ir::analysis::template_params: constrain ItemId(7)
TRACE:bindgen::ir::analysis::template_params:   initially, used set is {}
TRACE:bindgen::ir::analysis::template_params:     other item: join with successors' usage
TRACE:bindgen::ir::analysis::template_params:       union with ItemId(11)'s usage: []
TRACE:bindgen::ir::analysis::template_params:       union with ItemId(9)'s usage: []
TRACE:bindgen::ir::analysis::template_params:   finally, used set is {}
TRACE:bindgen::ir::analysis::template_params: constrain ItemId(7)
TRACE:bindgen::ir::analysis::template_params:   initially, used set is {}
TRACE:bindgen::ir::analysis::template_params:     other item: join with successors' usage
TRACE:bindgen::ir::analysis::template_params:       union with ItemId(11)'s usage: []
TRACE:bindgen::ir::analysis::template_params:       union with ItemId(9)'s usage: []
TRACE:bindgen::ir::analysis::template_params:   finally, used set is {}
TRACE:bindgen::ir::analysis::template_params: constrain ItemId(6)
TRACE:bindgen::ir::analysis::template_params:   initially, used set is {}
TRACE:bindgen::ir::analysis::template_params:     other item: join with successors' usage
TRACE:bindgen::ir::analysis::template_params:       union with ItemId(7)'s usage: []
TRACE:bindgen::ir::analysis::template_params:   finally, used set is {}
TRACE:bindgen::ir::analysis::template_params: constrain ItemId(1)
TRACE:bindgen::ir::analysis::template_params:   initially, used set is {}
TRACE:bindgen::ir::analysis::template_params:     other item: join with successors' usage
TRACE:bindgen::ir::analysis::template_params:       union with ItemId(4)'s usage: []
TRACE:bindgen::ir::analysis::template_params:       union with ItemId(2)'s usage: []
TRACE:bindgen::ir::analysis::template_params:   finally, used set is {}
TRACE:bindgen::ir::analysis::template_params: constrain ItemId(5)
TRACE:bindgen::ir::analysis::template_params:   initially, used set is {}
TRACE:bindgen::ir::analysis::template_params:     other item: join with successors' usage
TRACE:bindgen::ir::analysis::template_params:   finally, used set is {}
TRACE:bindgen::ir::analysis::template_params: constrain ItemId(4)
TRACE:bindgen::ir::analysis::template_params:   initially, used set is {}
TRACE:bindgen::ir::analysis::template_params:     other item: join with successors' usage
TRACE:bindgen::ir::analysis::template_params:   finally, used set is {}
TRACE:bindgen::ir::analysis::template_params: constrain ItemId(6)
TRACE:bindgen::ir::analysis::template_params:   initially, used set is {}
TRACE:bindgen::ir::analysis::template_params:     other item: join with successors' usage
TRACE:bindgen::ir::analysis::template_params:       union with ItemId(7)'s usage: []
TRACE:bindgen::ir::analysis::template_params:   finally, used set is {}
TRACE:bindgen::ir::analysis::template_params: constrain ItemId(2)
TRACE:bindgen::ir::analysis::template_params:   initially, used set is {}
TRACE:bindgen::ir::analysis::template_params:     other item: join with successors' usage
TRACE:bindgen::ir::analysis::template_params:       union with ItemId(6)'s usage: []
TRACE:bindgen::ir::analysis::template_params:   finally, used set is {}
TRACE:bindgen::ir::analysis::template_params: constrain ItemId(2)
TRACE:bindgen::ir::analysis::template_params:   initially, used set is {}
TRACE:bindgen::ir::analysis::template_params:     other item: join with successors' usage
TRACE:bindgen::ir::analysis::template_params:       union with ItemId(6)'s usage: []
TRACE:bindgen::ir::analysis::template_params:   finally, used set is {}
TRACE:bindgen::ir::analysis::template_params: constrain ItemId(4)
TRACE:bindgen::ir::analysis::template_params:   initially, used set is {}
TRACE:bindgen::ir::analysis::template_params:     other item: join with successors' usage
TRACE:bindgen::ir::analysis::template_params:   finally, used set is {}
TRACE:bindgen::ir::analysis::template_params: constrain ItemId(1)
TRACE:bindgen::ir::analysis::template_params:   initially, used set is {}
TRACE:bindgen::ir::analysis::template_params:     other item: join with successors' usage
TRACE:bindgen::ir::analysis::template_params:       union with ItemId(4)'s usage: []
TRACE:bindgen::ir::analysis::template_params:       union with ItemId(2)'s usage: []
TRACE:bindgen::ir::analysis::template_params:   finally, used set is {}
TRACE:bindgen::ir::analysis::template_params: constrain ItemId(0)
TRACE:bindgen::ir::analysis::template_params:   initially, used set is {}
TRACE:bindgen::ir::analysis::template_params:     other item: join with successors' usage
TRACE:bindgen::ir::analysis::template_params:   finally, used set is {}
TRACE:bindgen::ir::analysis::derive_debug: constrain: ItemId(11)
TRACE:bindgen::ir::analysis::derive_debug:     simple type that can always derive Debug
TRACE:bindgen::ir::analysis::derive_debug: constrain: ItemId(9)
TRACE:bindgen::ir::analysis::derive_debug:     simple type that can always derive Debug
TRACE:bindgen::ir::analysis::derive_debug: constrain: ItemId(7)
TRACE:bindgen::ir::analysis::derive_debug:     simple type that can always derive Debug
TRACE:bindgen::ir::analysis::derive_debug: constrain: ItemId(6)
TRACE:bindgen::ir::analysis::derive_debug:     pointers can derive Debug
TRACE:bindgen::ir::analysis::derive_debug: constrain: ItemId(5)
TRACE:bindgen::ir::analysis::derive_debug:     not a type; ignoring
TRACE:bindgen::ir::analysis::derive_debug: constrain: ItemId(4)
TRACE:bindgen::ir::analysis::derive_debug:     simple type that can always derive Debug
TRACE:bindgen::ir::analysis::derive_debug: constrain: ItemId(2)
TRACE:bindgen::ir::analysis::derive_debug:     aliases and type refs to T which can derive Debug can also derive Debug
TRACE:bindgen::ir::analysis::derive_debug: constrain: ItemId(1)
TRACE:bindgen::ir::analysis::derive_debug:     simple type that can always derive Debug
TRACE:bindgen::ir::analysis::derive_debug: constrain: ItemId(0)
TRACE:bindgen::ir::analysis::derive_debug:     not a type; ignoring
TRACE:bindgen::ir::analysis::derive_copy: constrain: ItemId(11)
TRACE:bindgen::ir::analysis::derive_copy:     simple type that can always derive Copy
TRACE:bindgen::ir::analysis::derive_copy: constrain: ItemId(9)
TRACE:bindgen::ir::analysis::derive_copy:     simple type that can always derive Copy
TRACE:bindgen::ir::analysis::derive_copy: constrain: ItemId(7)
TRACE:bindgen::ir::analysis::derive_copy:     simple type that can always derive Copy
TRACE:bindgen::ir::analysis::derive_copy: constrain: ItemId(6)
TRACE:bindgen::ir::analysis::derive_copy:     simple type that can always derive Copy
TRACE:bindgen::ir::analysis::derive_copy: constrain: ItemId(5)
TRACE:bindgen::ir::analysis::derive_copy:     not a type; ignoring
TRACE:bindgen::ir::analysis::derive_copy: constrain: ItemId(4)
TRACE:bindgen::ir::analysis::derive_copy:     simple type that can always derive Copy
TRACE:bindgen::ir::analysis::derive_copy: constrain: ItemId(2)
TRACE:bindgen::ir::analysis::derive_copy:     aliases and type refs to T which can derive Copy can also derive Copy
TRACE:bindgen::ir::analysis::derive_copy: constrain: ItemId(1)
TRACE:bindgen::ir::analysis::derive_copy:     simple type that can always derive Copy
TRACE:bindgen::ir::analysis::derive_copy: constrain: ItemId(0)
TRACE:bindgen::ir::analysis::derive_copy:     not a type; ignoring
TRACE:bindgen::ir::analysis::has_type_param_in_array: constrain: ItemId(11)
TRACE:bindgen::ir::analysis::has_type_param_in_array:     simple type that do not have array
TRACE:bindgen::ir::analysis::has_type_param_in_array: constrain: ItemId(9)
TRACE:bindgen::ir::analysis::has_type_param_in_array:     simple type that do not have array
TRACE:bindgen::ir::analysis::has_type_param_in_array: constrain: ItemId(7)
TRACE:bindgen::ir::analysis::has_type_param_in_array:     simple type that do not have array
TRACE:bindgen::ir::analysis::has_type_param_in_array: constrain: ItemId(6)
TRACE:bindgen::ir::analysis::has_type_param_in_array:     simple type that do not have array
TRACE:bindgen::ir::analysis::has_type_param_in_array: constrain: ItemId(5)
TRACE:bindgen::ir::analysis::has_type_param_in_array:     not a type; ignoring
TRACE:bindgen::ir::analysis::has_type_param_in_array: constrain: ItemId(4)
TRACE:bindgen::ir::analysis::has_type_param_in_array:     simple type that do not have array
TRACE:bindgen::ir::analysis::has_type_param_in_array: constrain: ItemId(2)
TRACE:bindgen::ir::analysis::has_type_param_in_array:     aliases and type refs to T which do not have array also do not have array
TRACE:bindgen::ir::analysis::has_type_param_in_array: constrain: ItemId(1)
TRACE:bindgen::ir::analysis::has_type_param_in_array:     simple type that do not have array
TRACE:bindgen::ir::analysis::has_type_param_in_array: constrain: ItemId(0)
TRACE:bindgen::ir::analysis::has_type_param_in_array:     not a type; ignoring
DEBUG:bindgen::codegen: codegen: BindgenOptions { blacklisted_types: RegexSet { items: [], set: Some(RegexSet([])) }, opaque_types: RegexSet { items: [], set: Some(RegexSet([])) }, whitelisted_types: RegexSet { items: [], set: Some(RegexSet([])) }, whitelisted_functions: RegexSet { items: [], set: Some(RegexSet([])) }, whitelisted_vars: RegexSet { items: [], set: Some(RegexSet([])) }, bitfield_enums: RegexSet { items: [], set: Some(RegexSet([])) }, rustified_enums: RegexSet { items: [], set: Some(RegexSet([])) }, constified_enum_modules: RegexSet { items: [], set: Some(RegexSet([])) }, builtins: false, links: [], emit_ast: false, emit_ir: false, emit_ir_graphviz: None, enable_cxx_namespaces: false, disable_name_namespacing: false, layout_tests: true, impl_debug: false, impl_partialeq: false, derive_copy: true, derive_debug: true, derive_default: false, derive_hash: false, derive_partialord: false, derive_ord: false, derive_partialeq: false, derive_eq: false, use_core: false, ctypes_prefix: None, time_phases: false, namespaced_constants: true, msvc_mangling: false, convert_floats: true, raw_lines: [], clang_args: ["-isystem", "/Library/Developer/CommandLineTools/usr/include/c++/v1", "-isystem", "/usr/local/include", "-isystem", "/Library/Developer/CommandLineTools/usr/lib/clang/9.0.0/include", "-isystem", "/Library/Developer/CommandLineTools/usr/include", "-isystem", "/usr/include", "-isystem", "/System/Library/Frameworks", "-isystem", "/Library/Frameworks", "example.h"], input_header: Some("example.h"), input_unsaved_files: [], parse_callbacks: None, codegen_config: CodegenConfig { functions: true, types: true, vars: true, methods: true, constructors: true, destructors: true }, conservative_inline_namespaces: false, generate_comments: true, generate_inline_functions: true, whitelist_recursively: true, objc_extern_crate: false, enable_mangling: true, prepend_enum_name: true, rust_target: Stable_1_21, rust_features: RustFeatures { untagged_union: true, const_fn: false, thiscall_abi: false, builtin_clone_impls: true }, rustfmt_bindings: true, rustfmt_configuration_file: None, no_partialeq_types: RegexSet { items: [], set: Some(RegexSet([])) }, no_copy_types: RegexSet { items: [], set: Some(RegexSet([])) }, no_hash_types: RegexSet { items: [], set: Some(RegexSet([])) } }
DEBUG:bindgen::codegen: <Item as CodeGenerator>::codegen: self = Item { id: ItemId(0), local_id: Cell { value: None }, next_child_local_id: Cell { value: 1 }, canonical_name_cache: RefCell { value: None }, comment: None, annotations: Annotations { opaque: false, hide: false, use_instead_of: None, disallow_copy: false, private_fields: None, accessor_kind: None, constify_enum_variant: false }, parent_id: ItemId(0), kind: Module(Module { name: Some("root"), kind: Normal, children: {ItemId(1), ItemId(2), ItemId(4), ItemId(5), ItemId(6), ItemId(7), ItemId(9), ItemId(11)} }) }
DEBUG:bindgen::codegen: <Module as CodeGenerator>::codegen: item = Item { id: ItemId(0), local_id: Cell { value: None }, next_child_local_id: Cell { value: 1 }, canonical_name_cache: RefCell { value: None }, comment: None, annotations: Annotations { opaque: false, hide: false, use_instead_of: None, disallow_copy: false, private_fields: None, accessor_kind: None, constify_enum_variant: false }, parent_id: ItemId(0), kind: Module(Module { name: Some("root"), kind: Normal, children: {ItemId(1), ItemId(2), ItemId(4), ItemId(5), ItemId(6), ItemId(7), ItemId(9), ItemId(11)} }) }
DEBUG:bindgen::codegen: <Item as CodeGenerator>::codegen: self = Item { id: ItemId(1), local_id: Cell { value: None }, next_child_local_id: Cell { value: 1 }, canonical_name_cache: RefCell { value: None }, comment: None, annotations: Annotations { opaque: false, hide: false, use_instead_of: None, disallow_copy: false, private_fields: None, accessor_kind: None, constify_enum_variant: false }, parent_id: ItemId(0), kind: Type(Type { name: None, layout: Some(Layout { size: 1, align: 4, packed: false }), kind: Function(FunctionSig { return_type: TypeId(ItemId(4)), argument_types: [(Some("callback"), TypeId(ItemId(2)))], is_variadic: false, abi: C }), is_const: false }) }
DEBUG:bindgen::codegen: <Type as CodeGenerator>::codegen: item = Item { id: ItemId(1), local_id: Cell { value: None }, next_child_local_id: Cell { value: 1 }, canonical_name_cache: RefCell { value: None }, comment: None, annotations: Annotations { opaque: false, hide: false, use_instead_of: None, disallow_copy: false, private_fields: None, accessor_kind: None, constify_enum_variant: false }, parent_id: ItemId(0), kind: Type(Type { name: None, layout: Some(Layout { size: 1, align: 4, packed: false }), kind: Function(FunctionSig { return_type: TypeId(ItemId(4)), argument_types: [(Some("callback"), TypeId(ItemId(2)))], is_variadic: false, abi: C }), is_const: false }) }
DEBUG:bindgen::codegen: <Item as CodeGenerator>::codegen: self = Item { id: ItemId(2), local_id: Cell { value: None }, next_child_local_id: Cell { value: 1 }, canonical_name_cache: RefCell { value: None }, comment: None, annotations: Annotations { opaque: false, hide: false, use_instead_of: None, disallow_copy: false, private_fields: None, accessor_kind: None, constify_enum_variant: false }, parent_id: ItemId(0), kind: Type(Type { name: None, layout: None, kind: ResolvedTypeRef(TypeId(ItemId(6))), is_const: false }) }
DEBUG:bindgen::codegen: <Type as CodeGenerator>::codegen: item = Item { id: ItemId(2), local_id: Cell { value: None }, next_child_local_id: Cell { value: 1 }, canonical_name_cache: RefCell { value: None }, comment: None, annotations: Annotations { opaque: false, hide: false, use_instead_of: None, disallow_copy: false, private_fields: None, accessor_kind: None, constify_enum_variant: false }, parent_id: ItemId(0), kind: Type(Type { name: None, layout: None, kind: ResolvedTypeRef(TypeId(ItemId(6))), is_const: false }) }
DEBUG:bindgen::codegen: <Item as CodeGenerator>::codegen: self = Item { id: ItemId(4), local_id: Cell { value: None }, next_child_local_id: Cell { value: 1 }, canonical_name_cache: RefCell { value: None }, comment: None, annotations: Annotations { opaque: false, hide: false, use_instead_of: None, disallow_copy: false, private_fields: None, accessor_kind: None, constify_enum_variant: false }, parent_id: ItemId(0), kind: Type(Type { name: Some("int"), layout: Some(Layout { size: 4, align: 4, packed: false }), kind: Int(Int), is_const: false }) }
DEBUG:bindgen::codegen: <Type as CodeGenerator>::codegen: item = Item { id: ItemId(4), local_id: Cell { value: None }, next_child_local_id: Cell { value: 1 }, canonical_name_cache: RefCell { value: None }, comment: None, annotations: Annotations { opaque: false, hide: false, use_instead_of: None, disallow_copy: false, private_fields: None, accessor_kind: None, constify_enum_variant: false }, parent_id: ItemId(0), kind: Type(Type { name: Some("int"), layout: Some(Layout { size: 4, align: 4, packed: false }), kind: Int(Int), is_const: false }) }
DEBUG:bindgen::codegen: <Item as CodeGenerator>::codegen: self = Item { id: ItemId(5), local_id: Cell { value: None }, next_child_local_id: Cell { value: 1 }, canonical_name_cache: RefCell { value: None }, comment: None, annotations: Annotations { opaque: false, hide: false, use_instead_of: None, disallow_copy: false, private_fields: None, accessor_kind: None, constify_enum_variant: false }, parent_id: ItemId(0), kind: Function(Function { name: "failure_example", mangled_name: Some("_failure_example"), signature: TypeId(ItemId(1)), comment: None, kind: Function, linkage: External }) }
DEBUG:bindgen::codegen: <Function as CodeGenerator>::codegen: item = Item { id: ItemId(5), local_id: Cell { value: None }, next_child_local_id: Cell { value: 1 }, canonical_name_cache: RefCell { value: None }, comment: None, annotations: Annotations { opaque: false, hide: false, use_instead_of: None, disallow_copy: false, private_fields: None, accessor_kind: None, constify_enum_variant: false }, parent_id: ItemId(0), kind: Function(Function { name: "failure_example", mangled_name: Some("_failure_example"), signature: TypeId(ItemId(1)), comment: None, kind: Function, linkage: External }) }
DEBUG:bindgen::codegen: <Item as CodeGenerator>::codegen: self = Item { id: ItemId(6), local_id: Cell { value: None }, next_child_local_id: Cell { value: 1 }, canonical_name_cache: RefCell { value: None }, comment: None, annotations: Annotations { opaque: false, hide: false, use_instead_of: None, disallow_copy: false, private_fields: None, accessor_kind: None, constify_enum_variant: false }, parent_id: ItemId(0), kind: Type(Type { name: None, layout: Some(Layout { size: 8, align: 8, packed: false }), kind: Pointer(TypeId(ItemId(7))), is_const: false }) }
DEBUG:bindgen::codegen: <Type as CodeGenerator>::codegen: item = Item { id: ItemId(6), local_id: Cell { value: None }, next_child_local_id: Cell { value: 1 }, canonical_name_cache: RefCell { value: None }, comment: None, annotations: Annotations { opaque: false, hide: false, use_instead_of: None, disallow_copy: false, private_fields: None, accessor_kind: None, constify_enum_variant: false }, parent_id: ItemId(0), kind: Type(Type { name: None, layout: Some(Layout { size: 8, align: 8, packed: false }), kind: Pointer(TypeId(ItemId(7))), is_const: false }) }
DEBUG:bindgen::codegen: <Item as CodeGenerator>::codegen: self = Item { id: ItemId(7), local_id: Cell { value: None }, next_child_local_id: Cell { value: 1 }, canonical_name_cache: RefCell { value: None }, comment: None, annotations: Annotations { opaque: false, hide: false, use_instead_of: None, disallow_copy: false, private_fields: None, accessor_kind: None, constify_enum_variant: false }, parent_id: ItemId(0), kind: Type(Type { name: None, layout: Some(Layout { size: 1, align: 4, packed: false }), kind: Function(FunctionSig { return_type: TypeId(ItemId(11)), argument_types: [(Some("some_arg"), TypeId(ItemId(9)))], is_variadic: false, abi: C }), is_const: false }) }
DEBUG:bindgen::codegen: <Type as CodeGenerator>::codegen: item = Item { id: ItemId(7), local_id: Cell { value: None }, next_child_local_id: Cell { value: 1 }, canonical_name_cache: RefCell { value: None }, comment: None, annotations: Annotations { opaque: false, hide: false, use_instead_of: None, disallow_copy: false, private_fields: None, accessor_kind: None, constify_enum_variant: false }, parent_id: ItemId(0), kind: Type(Type { name: None, layout: Some(Layout { size: 1, align: 4, packed: false }), kind: Function(FunctionSig { return_type: TypeId(ItemId(11)), argument_types: [(Some("some_arg"), TypeId(ItemId(9)))], is_variadic: false, abi: C }), is_const: false }) }
DEBUG:bindgen::codegen: <Item as CodeGenerator>::codegen: self = Item { id: ItemId(9), local_id: Cell { value: None }, next_child_local_id: Cell { value: 1 }, canonical_name_cache: RefCell { value: None }, comment: None, annotations: Annotations { opaque: false, hide: false, use_instead_of: None, disallow_copy: false, private_fields: None, accessor_kind: None, constify_enum_variant: false }, parent_id: ItemId(0), kind: Type(Type { name: Some("int"), layout: Some(Layout { size: 4, align: 4, packed: false }), kind: Int(Int), is_const: false }) }
DEBUG:bindgen::codegen: <Type as CodeGenerator>::codegen: item = Item { id: ItemId(9), local_id: Cell { value: None }, next_child_local_id: Cell { value: 1 }, canonical_name_cache: RefCell { value: None }, comment: None, annotations: Annotations { opaque: false, hide: false, use_instead_of: None, disallow_copy: false, private_fields: None, accessor_kind: None, constify_enum_variant: false }, parent_id: ItemId(0), kind: Type(Type { name: Some("int"), layout: Some(Layout { size: 4, align: 4, packed: false }), kind: Int(Int), is_const: false }) }
DEBUG:bindgen::codegen: <Item as CodeGenerator>::codegen: self = Item { id: ItemId(11), local_id: Cell { value: None }, next_child_local_id: Cell { value: 1 }, canonical_name_cache: RefCell { value: None }, comment: None, annotations: Annotations { opaque: false, hide: false, use_instead_of: None, disallow_copy: false, private_fields: None, accessor_kind: None, constify_enum_variant: false }, parent_id: ItemId(0), kind: Type(Type { name: Some("void"), layout: None, kind: Void, is_const: false }) }
DEBUG:bindgen::codegen: <Type as CodeGenerator>::codegen: item = Item { id: ItemId(11), local_id: Cell { value: None }, next_child_local_id: Cell { value: 1 }, canonical_name_cache: RefCell { value: None }, comment: None, annotations: Annotations { opaque: false, hide: false, use_instead_of: None, disallow_copy: false, private_fields: None, accessor_kind: None, constify_enum_variant: false }, parent_id: ItemId(0), kind: Type(Type { name: Some("void"), layout: None, kind: Void, is_const: false }) }
emilio commented 6 years ago

That looks a lot like rustfmt messing out, mind updating rustfmt or using rustfmt_bindings(false)?

drake-amz commented 6 years ago

That solved it, thanks!

$ bindgen --no-rustfmt-bindings example.h -o bindings.rs
$ cat bindings.rs
/* automatically generated by rust-bindgen */

extern "C" {
 # [ link_name = "\u{1}_failure_example" ]
 pub fn failure_example ( callback : :: std :: option :: Option < unsafe extern "C" fn ( some_arg : :: std :: os :: raw :: c_int ) > , ) -> :: std :: os :: raw :: c_int ;
}

Also confirmed that when I run rustfmt directly on the bindings.rs file, rustfmt removes the function declaration line. I'll file a follow up issue on the rustfmt repo.

fitzgen commented 6 years ago

Yep, need to make sure rustfmt is up-to-date, or alternatively live with un-pretty-printed bindings and disable rustfmting.

Thanks for filing an issue!