mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-09 15:19:07 +00:00
zig fmt: for loop with ptr payload and index
This commit is contained in:
parent
988f1c6a6f
commit
4420fe97be
2 changed files with 15 additions and 3 deletions
|
|
@ -4152,6 +4152,18 @@ test "zig fmt: space after top level doc comment" {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
test "zig fmt: for loop with ptr payload and index" {
|
||||||
|
try testCanonical(
|
||||||
|
\\test {
|
||||||
|
\\ for (self.entries.items) |*item, i| {}
|
||||||
|
\\ for (self.entries.items) |*item, i|
|
||||||
|
\\ a = b;
|
||||||
|
\\ for (self.entries.items) |*item, i| a = b;
|
||||||
|
\\}
|
||||||
|
\\
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
test "zig fmt: error for invalid bit range" {
|
test "zig fmt: error for invalid bit range" {
|
||||||
try testError(
|
try testError(
|
||||||
\\var x: []align(0:0:0)u8 = bar;
|
\\var x: []align(0:0:0)u8 = bar;
|
||||||
|
|
|
||||||
|
|
@ -1040,7 +1040,7 @@ fn renderWhile(gpa: *Allocator, ais: *Ais, tree: ast.Tree, while_node: ast.full.
|
||||||
if (token_tags[ident + 1] == .comma) {
|
if (token_tags[ident + 1] == .comma) {
|
||||||
try renderToken(ais, tree, ident + 1, .space); // ,
|
try renderToken(ais, tree, ident + 1, .space); // ,
|
||||||
try renderToken(ais, tree, ident + 2, .none); // index
|
try renderToken(ais, tree, ident + 2, .none); // index
|
||||||
break :blk payload_token + 3;
|
break :blk ident + 3;
|
||||||
} else {
|
} else {
|
||||||
break :blk ident + 1;
|
break :blk ident + 1;
|
||||||
}
|
}
|
||||||
|
|
@ -1102,7 +1102,7 @@ fn renderWhile(gpa: *Allocator, ais: *Ais, tree: ast.Tree, while_node: ast.full.
|
||||||
if (token_tags[ident + 1] == .comma) {
|
if (token_tags[ident + 1] == .comma) {
|
||||||
try renderToken(ais, tree, ident + 1, .space); // ,
|
try renderToken(ais, tree, ident + 1, .space); // ,
|
||||||
try renderToken(ais, tree, ident + 2, .none); // index
|
try renderToken(ais, tree, ident + 2, .none); // index
|
||||||
break :blk payload_token + 3;
|
break :blk ident + 3;
|
||||||
} else {
|
} else {
|
||||||
break :blk ident + 1;
|
break :blk ident + 1;
|
||||||
}
|
}
|
||||||
|
|
@ -1177,7 +1177,7 @@ fn renderWhile(gpa: *Allocator, ais: *Ais, tree: ast.Tree, while_node: ast.full.
|
||||||
if (token_tags[ident + 1] == .comma) {
|
if (token_tags[ident + 1] == .comma) {
|
||||||
try renderToken(ais, tree, ident + 1, .space); // ,
|
try renderToken(ais, tree, ident + 1, .space); // ,
|
||||||
try renderToken(ais, tree, ident + 2, .none); // index
|
try renderToken(ais, tree, ident + 2, .none); // index
|
||||||
break :blk payload_token + 3;
|
break :blk ident + 3;
|
||||||
} else {
|
} else {
|
||||||
break :blk ident + 1;
|
break :blk ident + 1;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue