summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2016-12-22 00:38:12 -0800
committerGitHub <noreply@github.com>2016-12-22 00:38:12 -0800
commit4472e0a5e60765611e980795de7c3c3a7e244ad5 (patch)
tree2abc5dea5cdf1bc9e1d25c201632e0940f20c675
parent7615250f5d85688f0a4601c91c4984458961c54a (diff)
parenta336b01ec19045a7ea89dcfee588967df506a033 (diff)
Auto merge of #354 - Nashenas88:master, r=emilio
Followed Resolved Type Ref instead of panicking This could fix #353, but I would really want everyone to review in case I'm missing something important. The compilation continues for the code I'm working with. Also, should I add a regression test for this? I could simply use the code in the referenced issue.
-rw-r--r--libbindgen/src/codegen/mod.rs6
-rw-r--r--libbindgen/tests/expectations/tests/resolved_type_def_function.rs7
-rw-r--r--libbindgen/tests/headers/resolved_type_def_function.h2
3 files changed, 14 insertions, 1 deletions
diff --git a/libbindgen/src/codegen/mod.rs b/libbindgen/src/codegen/mod.rs
index 9734a520..192eb674 100644
--- a/libbindgen/src/codegen/mod.rs
+++ b/libbindgen/src/codegen/mod.rs
@@ -2013,7 +2013,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 00000000..fb308fa4
--- /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<unsafe extern "C" fn()>;
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 00000000..139b8c3e
--- /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