authorgravatar for 47984692+luehmann@users.noreply.github.comPhilipp Lühmann <47984692+luehmann@users.noreply.github.com> 2021-09-14 11:36:26+02:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2021-09-14 11:36:26+02:00
logd1908c9f661abebb2879b02c8ea3ac823fec27e7
tree196949e92aa12da9ba30512acebb6505047c264a
parent264acfdf3caef663cddc39c2bf83818abb0e0073
signaturebadge-question-mark Signed by PGP key 4AEE18F83AFDEB23

zig fmt: Keep callconv(.Inline) on function pointer types

Co-authored-by: Philipp Lühmann <mail@philipp.lu>

2 files changed, 6 insertions(+), 3 deletions(-)

lib/std/zig/parser_test.zig+3
......@@ -2879,6 +2879,9 @@ test "zig fmt: functions" {
28792879 \\pub export fn puts(s: *const u8) align(2 + 2) c_int;
28802880 \\pub inline fn puts(s: *const u8) align(2 + 2) c_int;
28812881 \\pub noinline fn puts(s: *const u8) align(2 + 2) c_int;
2882 \\pub fn callInlineFn(func: fn () callconv(.Inline) void) void {
2883 \\ func();
2884 \\}
28822885 \\
28832886 );
28842887}
lib/std/zig/render.zig+3-3
......@@ -1417,9 +1417,9 @@ fn renderFnProto(gpa: *Allocator, ais: *Ais, tree: Ast, fn_proto: Ast.full.FnPro
14171417 try renderToken(ais, tree, section_rparen, .space); // )
14181418 }
14191419
1420 if (fn_proto.ast.callconv_expr != 0 and
1421 !mem.eql(u8, "Inline", tree.tokenSlice(tree.nodes.items(.main_token)[fn_proto.ast.callconv_expr])))
1422 {
1420 const is_callconv_inline = mem.eql(u8, "Inline", tree.tokenSlice(tree.nodes.items(.main_token)[fn_proto.ast.callconv_expr]));
1421 const is_declaration = fn_proto.name_token != null;
1422 if (fn_proto.ast.callconv_expr != 0 and !(is_declaration and is_callconv_inline)) {
14231423 const callconv_lparen = tree.firstToken(fn_proto.ast.callconv_expr) - 1;
14241424 const callconv_rparen = tree.lastToken(fn_proto.ast.callconv_expr) + 1;
14251425