File tree Expand file tree Collapse file tree 2 files changed +35
-3
lines changed Expand file tree Collapse file tree 2 files changed +35
-3
lines changed Original file line number Diff line number Diff line change @@ -16,6 +16,28 @@ test "zig fmt: preserves clobbers in inline asm with stray comma" {
16
16
);
17
17
}
18
18
19
+ test "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
+
19
41
test "zig fmt: respect line breaks in struct field value declaration" {
20
42
try testCanonical (
21
43
\\const Foo = struct {
Original file line number Diff line number Diff line change @@ -2114,9 +2114,19 @@ fn renderAsm(
2114
2114
return renderToken (ais , tree , tok_i + 1 , space );
2115
2115
},
2116
2116
.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
+ }
2120
2130
},
2121
2131
else = > unreachable ,
2122
2132
}
You can’t perform that action at this time.
0 commit comments