mirror of
https://github.com/ziglang/zig.git
synced 2026-02-12 20:37:54 +00:00
zig fmt: remove trailing comma at the end of assembly clobber
This commit is contained in:
parent
36f4f32fad
commit
0d96f1f4fb
@ -16,6 +16,28 @@ test "zig fmt: preserves clobbers in inline asm with stray comma" {
|
||||
);
|
||||
}
|
||||
|
||||
test "zig fmt: remove trailing comma at the end of assembly clobber" {
|
||||
try testTransform(
|
||||
\\fn foo() void {
|
||||
\\ asm volatile (""
|
||||
\\ : [_] "" (-> type),
|
||||
\\ :
|
||||
\\ : "clobber1", "clobber2",
|
||||
\\ );
|
||||
\\}
|
||||
\\
|
||||
,
|
||||
\\fn foo() void {
|
||||
\\ asm volatile (""
|
||||
\\ : [_] "" (-> type),
|
||||
\\ :
|
||||
\\ : "clobber1", "clobber2"
|
||||
\\ );
|
||||
\\}
|
||||
\\
|
||||
);
|
||||
}
|
||||
|
||||
test "zig fmt: respect line breaks in struct field value declaration" {
|
||||
try testCanonical(
|
||||
\\const Foo = struct {
|
||||
|
||||
@ -2114,9 +2114,19 @@ fn renderAsm(
|
||||
return renderToken(ais, tree, tok_i + 1, space);
|
||||
},
|
||||
.comma => {
|
||||
try renderToken(ais, tree, tok_i, .none);
|
||||
try renderToken(ais, tree, tok_i + 1, .space);
|
||||
tok_i += 2;
|
||||
switch (token_tags[tok_i + 2]) {
|
||||
.r_paren => {
|
||||
ais.setIndentDelta(indent_delta);
|
||||
ais.popIndent();
|
||||
try renderToken(ais, tree, tok_i, .newline);
|
||||
return renderToken(ais, tree, tok_i + 2, space);
|
||||
},
|
||||
else => {
|
||||
try renderToken(ais, tree, tok_i, .none);
|
||||
try renderToken(ais, tree, tok_i + 1, .space);
|
||||
tok_i += 2;
|
||||
},
|
||||
}
|
||||
},
|
||||
else => unreachable,
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user