diff options
author | Jyun-Yan You <jyyou.tw@gmail.com> | 2016-01-13 19:03:05 +0800 |
---|---|---|
committer | Jyun-Yan You <jyyou.tw@gmail.com> | 2016-01-13 19:03:05 +0800 |
commit | 3d2f57cabe8fbb9ce098e04b55450d9a52d92946 (patch) | |
tree | 78871dc60539ce9bf68b91605f8d45401596602c | |
parent | d1c73522ada363393eb528248502c46a1a6b7527 (diff) | |
parent | 9dbcc76dd6c83b538e4cb86076f7e96a8f7b53f7 (diff) |
Merge pull request #249 from nox/void-return
Generate better func decls for void returns
-rw-r--r-- | src/gen.rs | 14 | ||||
-rw-r--r-- | tests/test_func.rs | 4 |
2 files changed, 7 insertions, 11 deletions
@@ -955,14 +955,10 @@ fn cfuncty_to_rs(ctx: &mut GenCtx, aty: &[(String, Type)], var: bool) -> ast::FnDecl { - let ret = P(match *rty { - TVoid => ast::Ty { - id: ast::DUMMY_NODE_ID, - node: ast::TyTup(vec![]), - span: ctx.span - }, - _ => cty_to_rs(ctx, rty) - }); + let ret = match *rty { + TVoid => ast::DefaultReturn(ctx.span), + _ => ast::Return(P(cty_to_rs(ctx, rty))) + }; let mut unnamed: usize = 0; let args: Vec<ast::Arg> = aty.iter().map(|arg| { @@ -1003,7 +999,7 @@ fn cfuncty_to_rs(ctx: &mut GenCtx, let var = !args.is_empty() && var; return ast::FnDecl { inputs: args, - output: ast::Return(ret), + output: ret, variadic: var }; } diff --git a/tests/test_func.rs b/tests/test_func.rs index 6f809a38..996808be 100644 --- a/tests/test_func.rs +++ b/tests/test_func.rs @@ -43,7 +43,7 @@ fn func_proto() { fn with_func_ptr_arg() { assert_bind_eq("headers/func_with_func_ptr_arg.h", " extern \"C\" { - pub fn foo(bar: ::std::option::Option<extern \"C\" fn() -> () >) -> (); + pub fn foo(bar: ::std::option::Option<extern \"C\" fn()>); } "); } @@ -52,7 +52,7 @@ fn with_func_ptr_arg() { fn with_array_arg() { assert_bind_eq("headers/func_with_array_arg.h", " extern \"C\" { - pub fn f(x: *mut ::libc::c_int) -> (); + pub fn f(x: *mut ::libc::c_int); } "); } |