| author | |
| committer | |
| log | c6efb23796053a4409b0cf7b6abb4044719779aa |
| tree | 2c83d31549f52fa7287817f80d1b6085e49c4125 |
| parent | 878e99d580faf27aba2fbd782cb664da5d460614 |
2 files changed, 20 insertions(+), 14 deletions(-)
lib/std/zig/parser_test.zig+10-14| ... | ... | @@ -4,18 +4,16 @@ |
| 4 | 4 | // The MIT license requires this copyright notice to be included in all copies |
| 5 | 5 | // and substantial portions of the software. |
| 6 | 6 | |
| 7 | // TODO Remove this after zig 0.8.0 is released. | |
| 8 | // TODO need to add the logic to make this test pass. it was added in master | |
| 9 | // but was not added in the ast-memory-layout branch yet. | |
| 10 | //test "zig fmt: rewrite inline functions as callconv(.Inline)" { | |
| 11 | // try testTransform( | |
| 12 | // \\inline fn foo() void {} | |
| 13 | // \\ | |
| 14 | // , | |
| 15 | // \\fn foo() callconv(.Inline) void {} | |
| 16 | // \\ | |
| 17 | // ); | |
| 18 | //} | |
| 7 | // TODO Remove this after zig 0.9.0 is released. | |
| 8 | test "zig fmt: rewrite inline functions as callconv(.Inline)" { | |
| 9 | try testTransform( | |
| 10 | \\inline fn foo() void {} | |
| 11 | \\ | |
| 12 | , | |
| 13 | \\fn foo() callconv(.Inline) void {} | |
| 14 | \\ | |
| 15 | ); | |
| 16 | } | |
| 19 | 17 | |
| 20 | 18 | test "zig fmt: simple top level comptime block" { |
| 21 | 19 | try testCanonical( |
| ... | ... | @@ -2490,8 +2488,6 @@ test "zig fmt: function attributes" { |
| 2490 | 2488 | \\pub extern fn foo() void; |
| 2491 | 2489 | \\extern "c" fn foo() void; |
| 2492 | 2490 | \\pub extern "c" fn foo() void; |
| 2493 | \\inline fn foo() void {} | |
| 2494 | \\pub inline fn foo() void {} | |
| 2495 | 2491 | \\noinline fn foo() void {} |
| 2496 | 2492 | \\pub noinline fn foo() void {} |
| 2497 | 2493 | \\ |
lib/std/zig/render.zig+10| ... | ... | @@ -79,6 +79,11 @@ fn renderMember(ais: *Ais, tree: ast.Tree, decl: ast.Node.Index, space: Space) E |
| 79 | 79 | } |
| 80 | 80 | } |
| 81 | 81 | while (i < fn_token) : (i += 1) { |
| 82 | if (token_tags[i] == .keyword_inline) { | |
| 83 | // TODO remove this special case when 0.9.0 is released. | |
| 84 | // See the commit that introduced this comment for more details. | |
| 85 | continue; | |
| 86 | } | |
| 82 | 87 | try renderToken(ais, tree, i, .space); |
| 83 | 88 | } |
| 84 | 89 | assert(datas[decl].rhs != 0); |
| ... | ... | @@ -1260,6 +1265,9 @@ fn renderFnProto(ais: *Ais, tree: ast.Tree, fn_proto: ast.full.FnProto, space: S |
| 1260 | 1265 | const token_tags = tree.tokens.items(.tag); |
| 1261 | 1266 | const token_starts = tree.tokens.items(.start); |
| 1262 | 1267 | |
| 1268 | const is_inline = fn_proto.ast.fn_token > 0 and | |
| 1269 | token_tags[fn_proto.ast.fn_token - 1] == .keyword_inline; | |
| 1270 | ||
| 1263 | 1271 | const after_fn_token = fn_proto.ast.fn_token + 1; |
| 1264 | 1272 | const lparen = if (token_tags[after_fn_token] == .identifier) blk: { |
| 1265 | 1273 | try renderToken(ais, tree, fn_proto.ast.fn_token, .space); // fn |
| ... | ... | @@ -1435,6 +1443,8 @@ fn renderFnProto(ais: *Ais, tree: ast.Tree, fn_proto: ast.full.FnProto, space: S |
| 1435 | 1443 | try renderToken(ais, tree, callconv_lparen, .none); // ( |
| 1436 | 1444 | try renderExpression(ais, tree, fn_proto.ast.callconv_expr, .none); |
| 1437 | 1445 | try renderToken(ais, tree, callconv_rparen, .space); // ) |
| 1446 | } else if (is_inline) { | |
| 1447 | try ais.writer().writeAll("callconv(.Inline) "); | |
| 1438 | 1448 | } |
| 1439 | 1449 | |
| 1440 | 1450 | if (token_tags[maybe_bang] == .bang) { |