From 9dbcc76dd6c83b538e4cb86076f7e96a8f7b53f7 Mon Sep 17 00:00:00 2001 From: Michael Wu Date: Fri, 27 Mar 2015 06:00:16 -0400 Subject: Generate better func decls for void returns --- src/gen.rs | 14 +++++--------- tests/test_func.rs | 4 ++-- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/src/gen.rs b/src/gen.rs index c49cd0d5..7c2d1c9e 100644 --- a/src/gen.rs +++ b/src/gen.rs @@ -889,14 +889,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 = aty.iter().map(|arg| { @@ -937,7 +933,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 () >) -> (); + pub fn foo(bar: ::std::option::Option); } "); } @@ -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); } "); } -- cgit v1.2.3