authorgravatar for wxsychi@163.comriChar <wxsychi@163.com> 2022-09-02 17:52:33+08:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2022-09-02 12:52:33+03:00
log0d96f1f4fb3b217e11253c33e71973c3cbfb2f96
tree6980b30806c5a99442b80e4c3c012f8869bcb212
parent36f4f32fad3e88a84b6a10d78df31a4ed2c24465
signaturebadge-question-mark Signed by PGP key 4AEE18F83AFDEB23

zig fmt: remove trailing comma at the end of assembly clobber


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

lib/std/zig/parser_test.zig+22
......@@ -16,6 +16,28 @@ test "zig fmt: preserves clobbers in inline asm with stray comma" {
1616 );
1717}
1818
19test "zig fmt: remove trailing comma at the end of assembly clobber" {
20 try testTransform(
21 \\fn foo() void {
22 \\ asm volatile (""
23 \\ : [_] "" (-> type),
24 \\ :
25 \\ : "clobber1", "clobber2",
26 \\ );
27 \\}
28 \\
29 ,
30 \\fn foo() void {
31 \\ asm volatile (""
32 \\ : [_] "" (-> type),
33 \\ :
34 \\ : "clobber1", "clobber2"
35 \\ );
36 \\}
37 \\
38 );
39}
40
1941test "zig fmt: respect line breaks in struct field value declaration" {
2042 try testCanonical(
2143 \\const Foo = struct {
lib/std/zig/render.zig+13-3
......@@ -2114,9 +2114,19 @@ fn renderAsm(
21142114 return renderToken(ais, tree, tok_i + 1, space);
21152115 },
21162116 .comma => {
2117 try renderToken(ais, tree, tok_i, .none);
2118 try renderToken(ais, tree, tok_i + 1, .space);
2119 tok_i += 2;
2117 switch (token_tags[tok_i + 2]) {
2118 .r_paren => {
2119 ais.setIndentDelta(indent_delta);
2120 ais.popIndent();
2121 try renderToken(ais, tree, tok_i, .newline);
2122 return renderToken(ais, tree, tok_i + 2, space);
2123 },
2124 else => {
2125 try renderToken(ais, tree, tok_i, .none);
2126 try renderToken(ais, tree, tok_i + 1, .space);
2127 tok_i += 2;
2128 },
2129 }
21202130 },
21212131 else => unreachable,
21222132 }