diff --git a/libbindgen/src/codegen/mod.rs b/libbindgen/src/codegen/mod.rs index 2f18036a92..be95b72648 100644 --- a/libbindgen/src/codegen/mod.rs +++ b/libbindgen/src/codegen/mod.rs @@ -2005,7 +2005,11 @@ impl CodeGenerator for Function { let signature = signature_item.kind().expect_type(); let signature = match *signature.kind() { TypeKind::Function(ref sig) => sig, - _ => panic!("How?"), + TypeKind::ResolvedTypeRef(ref item_id) => { + let item = ctx.resolve_item(*item_id); + return self.codegen(ctx, result, _whitelisted_items, item); + }, + _ => panic!("How?") }; let fndecl = utils::rust_fndecl_from_signature(ctx, signature_item); diff --git a/libbindgen/tests/expectations/tests/resolved_type_def_function.rs b/libbindgen/tests/expectations/tests/resolved_type_def_function.rs new file mode 100644 index 0000000000..fb308fa47d --- /dev/null +++ b/libbindgen/tests/expectations/tests/resolved_type_def_function.rs @@ -0,0 +1,7 @@ +/* automatically generated by rust-bindgen */ + + +#![allow(non_snake_case)] + + +pub type FuncType = ::std::option::Option; diff --git a/libbindgen/tests/headers/resolved_type_def_function.h b/libbindgen/tests/headers/resolved_type_def_function.h new file mode 100644 index 0000000000..139b8c3e85 --- /dev/null +++ b/libbindgen/tests/headers/resolved_type_def_function.h @@ -0,0 +1,2 @@ +typedef void (FuncType) (); +extern FuncType Func; \ No newline at end of file