mirror of
https://github.com/ziglang/zig.git
synced 2024-11-22 20:30:17 +00:00
Revert "Trailing comma is respected for builtin calls"
This reverts commit afd0290918
.
This caused test failures.
This commit is contained in:
parent
e9536ca10f
commit
f83411b0b1
@ -26,27 +26,6 @@ test "zig fmt: c pointer type" {
|
||||
);
|
||||
}
|
||||
|
||||
test "zig fmt: builtin call with trailing comma" {
|
||||
try testCanonical(
|
||||
\\pub fn main() void {
|
||||
\\ _ = @intToPtr(
|
||||
\\ a,
|
||||
\\ b,
|
||||
\\ );
|
||||
\\ _ = @ptrCast(
|
||||
\\ a,
|
||||
\\ b,
|
||||
\\ );
|
||||
\\ _ = @call(
|
||||
\\ a,
|
||||
\\ b,
|
||||
\\ c,
|
||||
\\ );
|
||||
\\}
|
||||
\\
|
||||
);
|
||||
}
|
||||
|
||||
test "zig fmt: asm expression with comptime content" {
|
||||
try testCanonical(
|
||||
\\comptime {
|
||||
|
@ -1263,40 +1263,17 @@ fn renderExpression(
|
||||
try renderToken(tree, stream, builtin_call.builtin_token, indent, start_col, Space.None); // @name
|
||||
}
|
||||
|
||||
const src_params_trailing_comma = blk: {
|
||||
const maybe_comma = tree.prevToken(builtin_call.rparen_token);
|
||||
break :blk tree.tokens.at(maybe_comma).id == .Comma;
|
||||
};
|
||||
try renderToken(tree, stream, tree.nextToken(builtin_call.builtin_token), indent, start_col, Space.None); // (
|
||||
|
||||
const lparen = tree.nextToken(builtin_call.builtin_token);
|
||||
var it = builtin_call.params.iterator(0);
|
||||
while (it.next()) |param_node| {
|
||||
try renderExpression(allocator, stream, tree, indent, start_col, param_node.*, Space.None);
|
||||
|
||||
if (!src_params_trailing_comma) {
|
||||
try renderToken(tree, stream, lparen, indent, start_col, Space.None); // (
|
||||
|
||||
// render all on one line, no trailing comma
|
||||
var it = builtin_call.params.iterator(0);
|
||||
while (it.next()) |param_node| {
|
||||
try renderExpression(allocator, stream, tree, indent, start_col, param_node.*, Space.None);
|
||||
// try renderParamDecl(allocator, stream, tree, indent, start_col, param_node.*, Space.None);
|
||||
|
||||
if (it.peek() != null) {
|
||||
const comma_token = tree.nextToken(param_node.*.lastToken());
|
||||
try renderToken(tree, stream, comma_token, indent, start_col, Space.Space); // ,
|
||||
}
|
||||
if (it.peek() != null) {
|
||||
const comma_token = tree.nextToken(param_node.*.lastToken());
|
||||
try renderToken(tree, stream, comma_token, indent, start_col, Space.Space); // ,
|
||||
}
|
||||
} else {
|
||||
// one param per line
|
||||
const new_indent = indent + indent_delta;
|
||||
try renderToken(tree, stream, lparen, new_indent, start_col, Space.Newline); // (
|
||||
|
||||
var it = builtin_call.params.iterator(0);
|
||||
while (it.next()) |param_node| {
|
||||
try stream.writeByteNTimes(' ', new_indent);
|
||||
try renderExpression(allocator, stream, tree, indent, start_col, param_node.*, Space.Comma);
|
||||
}
|
||||
try stream.writeByteNTimes(' ', indent);
|
||||
}
|
||||
|
||||
return renderToken(tree, stream, builtin_call.rparen_token, indent, start_col, space); // )
|
||||
},
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user