summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmilio Cobos Álvarez <ecoal95@gmail.com>2016-11-08 14:29:42 +0100
committerEmilio Cobos Álvarez <ecoal95@gmail.com>2016-11-08 14:30:24 +0100
commit6645bbc660ad573da8edee574b1cdae9a92691dc (patch)
treec4821254c6d15cacda8fb9a83721e272b5885d6e
parent108c4ca68769e7acad2a503001a156e0c51a7a8b (diff)
Fix --use-core for functions, since we used the aster helper.
Signed-off-by: Emilio Cobos Álvarez <ecoal95@gmail.com>
-rwxr-xr-xsrc/codegen/mod.rs3
-rw-r--r--tests/expectations/tests/use-core.rs2
-rw-r--r--tests/headers/use-core.h2
3 files changed, 6 insertions, 1 deletions
diff --git a/src/codegen/mod.rs b/src/codegen/mod.rs
index bf6af82b..7fa8b19c 100755
--- a/src/codegen/mod.rs
+++ b/src/codegen/mod.rs
@@ -1489,7 +1489,8 @@ impl ToRustTy for Type {
}
TypeKind::Function(ref fs) => {
let ty = fs.to_rust_ty(ctx, item);
- aster::AstBuilder::new().ty().option().build(ty)
+ let prefix = ctx.trait_prefix();
+ quote_ty!(ctx.ext_cx(), ::$prefix::option::Option<$ty>)
}
TypeKind::Array(item, len) => {
let inner = item.to_rust_ty(ctx);
diff --git a/tests/expectations/tests/use-core.rs b/tests/expectations/tests/use-core.rs
index 484105ea..b0900f5f 100644
--- a/tests/expectations/tests/use-core.rs
+++ b/tests/expectations/tests/use-core.rs
@@ -20,3 +20,5 @@ fn bindgen_test_layout_foo() {
impl Clone for foo {
fn clone(&self) -> Self { *self }
}
+pub type fooFunction =
+ ::core::option::Option<unsafe extern "C" fn(bar: ::std::os::raw::c_int)>;
diff --git a/tests/headers/use-core.h b/tests/headers/use-core.h
index 535d2b15..42bb10d9 100644
--- a/tests/headers/use-core.h
+++ b/tests/headers/use-core.h
@@ -4,3 +4,5 @@ struct foo {
int a, b;
void* bar;
};
+
+typedef void (*fooFunction)(int bar);